about summary refs log tree commit diff stats
path: root/templates/latex/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--templates/latex/flake.nix (renamed from latex/flake.nix)91
1 files changed, 57 insertions, 34 deletions
diff --git a/latex/flake.nix b/templates/latex/flake.nix
index 52f7353..ca4edeb 100644
--- a/latex/flake.nix
+++ b/templates/latex/flake.nix
@@ -1,64 +1,71 @@
 {
-  description = ""; # TODO
+  description = "TODO";
 
   inputs = {
     nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
-    # inputs for following
-    systems = {
-      url = "github:nix-systems/x86_64-linux"; # only evaluate for this system
-    };
-    flake-compat = {
-      url = "github:edolstra/flake-compat";
-      flake = false;
-    };
-    crane = {
-      url = "github:ipetkov/crane";
+
+    treefmt-nix = {
+      url = "github:numtide/treefmt-nix";
       inputs = {
         nixpkgs.follows = "nixpkgs";
-        flake-compat.follows = "flake-compat";
-        flake-utils.follows = "flake-utils";
-        rust-overlay.follows = "rust-overlay";
       };
     };
-    flake-utils = {
-      url = "github:numtide/flake-utils";
+    flake_version_update = {
+      url = "git+https://codeberg.org/soispha/flake_version_update.git";
       inputs = {
         systems.follows = "systems";
+        nixpkgs.follows = "nixpkgs";
+        flake-utils.follows = "flake-utils";
       };
     };
-    rust-overlay = {
-      url = "github:oxalica/rust-overlay";
+    lpm = {
+      url = "git+https://codeberg.org/Soispha/lpm.git";
       inputs = {
         nixpkgs.follows = "nixpkgs";
+        flake-compat.follows = "flake-compat";
         flake-utils.follows = "flake-utils";
+        rust-overlay.follows = "rust-overlay";
+        crane.follows = "crane";
+        systems.follows = "systems";
       };
     };
 
-    # bins
-    flake_version_update = {
-      url = "git+https://codeberg.org/soispha/flake_version_update.git";
+    # inputs for following
+    systems = {
+      url = "github:nix-systems/x86_64-linux"; # only evaluate for this system
+    };
+    flake-compat = {
+      url = "github:edolstra/flake-compat";
+      flake = false;
+    };
+    flake-utils = {
+      url = "github:numtide/flake-utils";
       inputs = {
         systems.follows = "systems";
+      };
+    };
+    crane = {
+      url = "github:ipetkov/crane";
+      inputs = {
         nixpkgs.follows = "nixpkgs";
-        flake-utils.follows = "flake-utils";
       };
     };
-    lpm = {
-      url = "git+https://codeberg.org/Soispha/lpm.git";
+    rust-overlay = {
+      url = "github:oxalica/rust-overlay";
       inputs = {
         nixpkgs.follows = "nixpkgs";
-        flake-compat.follows = "flake-compat";
         flake-utils.follows = "flake-utils";
-        rust-overlay.follows = "rust-overlay";
       };
     };
   };
 
   outputs = {
+    self,
     nixpkgs,
     flake-utils,
-    flake_version_update,
+    treefmt-nix,
     lpm,
+    flake_version_update,
     ...
   }:
     flake-utils.lib.eachDefaultSystem (system: let
@@ -69,9 +76,11 @@
 
       # TODO reduce to the needed ones
       texlive = pkgs.texlive.combined.scheme-full;
-    in {
-      packages.default = pkgs.stdenv.mkDerivation {
-        pname = ""; # TODO
+
+      treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};
+
+      build = pkgs.stdenv.mkDerivation {
+        pname = "TODO";
         inherit version;
         src = ./.;
 
@@ -79,17 +88,33 @@
           texlive
         ];
 
+        # Run local
+        preferLocalBuild = true;
+        allowSubstitutes = false;
+
         buildPhase = ''
-          latexmk -file-line-error main.tex
+          # TODO: I have no idea, why calling it with `./build.sh` does not work <2024-03-20>
+          bash ./build.sh
         '';
 
         installPhase = ''
-          install -D $scr/build/*.pdf $out/;
+          install -D ./build/main.pdf $out/TODO;
         '';
       };
+    in {
+      packages.default = build;
+
+      checks = {
+        inherit build;
+        formatting = treefmtEval.config.build.check self;
+      };
+
+      formatter = treefmtEval.config.build.wrapper;
+
       devShells.default = pkgs.mkShell {
         packages = with pkgs; [
           cocogitto
+          licensure
           flake_version_update.packages."${system}".default
           lpm.packages."${system}".default
           texlive
@@ -99,5 +124,3 @@
       };
     });
 }
-# vim: ts=2
-