summary refs log tree commit diff stats
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix79
1 files changed, 48 insertions, 31 deletions
diff --git a/flake.nix b/flake.nix
index 73cd4b7..950835d 100644
--- a/flake.nix
+++ b/flake.nix
@@ -48,6 +48,12 @@
         flake-utils.follows = "flake-utils";
       };
     };
+    treefmt-nix = {
+      url = "github:numtide/treefmt-nix";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+      };
+    };
 
     # data
     essay = {
@@ -71,6 +77,7 @@
         flake-utils.follows = "flake-utils";
         flake_version_update.follows = "flake_version_update";
         lpm.follows = "lpm";
+        treefmt-nix.follows = "treefmt-nix";
         nixpkgs.follows = "nixpkgs";
         rust-overlay.follows = "rust-overlay";
         systems.follows = "systems";
@@ -83,6 +90,7 @@
         flake-compat.follows = "flake-compat";
         flake-utils.follows = "flake-utils";
         flake_version_update.follows = "flake_version_update";
+        treefmt-nix.follows = "treefmt-nix";
         lpm.follows = "lpm";
         nixpkgs.follows = "nixpkgs";
         rust-overlay.follows = "rust-overlay";
@@ -92,51 +100,60 @@
   };
 
   outputs = {
-    nixpkgs,
-    flake-utils,
+    self,
     essay,
-    facharbeit,
     essens_analyse,
+    facharbeit,
+    flake-utils,
+    nixpkgs,
+    treefmt-nix,
     ...
   }:
     flake-utils.lib.eachDefaultSystem (
       system: let
         pkgs = nixpkgs.legacyPackages.${system};
-      in {
-        packages = {
-          default = pkgs.stdenv.mkDerivation {
-            pname = "b-peetz.de";
-            version = "v1.0";
-            src = ./src;
+        treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};
+        build = pkgs.stdenv.mkDerivation {
+          pname = "b-peetz.de";
+          version = "v1.0";
+          src = ./src;
 
-            # Run local
-            preferLocalBuild = true;
-            allowSubstitutes = false;
+          # Run local
+          preferLocalBuild = true;
+          allowSubstitutes = false;
 
-            nativeBuildInputs = [];
-            buildPhase = ''
-              install -D ${essay.outputs.packages."${system}".default}/philosophy/kant_and_free_software.pdf ./dead-trees/philosophy/kant_and_free_software.pdf
-              # NOTE: This link is for backward compatibility, as I have given out links with that url <2024-07-13>
-              ln --symbolic --relative ./dead-trees/philosophy/kant_and_free_software.pdf ./dead-trees/kant_and_free_software.pdf
+          nativeBuildInputs = [];
+          buildPhase = ''
+            install -D ${essay.outputs.packages."${system}".default}/philosophy/kant_and_free_software.pdf ./dead-trees/philosophy/kant_and_free_software.pdf
+            # NOTE: This link is for backward compatibility, as I have given out links with that url <2024-07-13>
+            ln --symbolic --relative ./dead-trees/philosophy/kant_and_free_software.pdf ./dead-trees/kant_and_free_software.pdf
 
-              install -D ${facharbeit.outputs.packages."${system}".default}/chemistry/facharbeit.pdf ./dead-trees/chemistry/facharbeit.pdf
-              # NOTE: This link is for backward compatibility, as I have given out links with that url <2024-07-13>
-              ln --symbolic --relative ./dead-trees/chemistry/facharbeit.pdf ./dead-trees/raman_spectrometer.pdf
+            install -D ${facharbeit.outputs.packages."${system}".default}/chemistry/facharbeit.pdf ./dead-trees/chemistry/facharbeit.pdf
+            # NOTE: This link is for backward compatibility, as I have given out links with that url <2024-07-13>
+            ln --symbolic --relative ./dead-trees/chemistry/facharbeit.pdf ./dead-trees/raman_spectrometer.pdf
 
-              install -D ${essens_analyse.outputs.packages."${system}".default}/chemistry/essens_analyse.pdf ./dead-trees/chemistry/essens_analyse.pdf
-            '';
-            installPhase = ''
-              install -d $out/
-              cp --recursive . $out/
-            '';
-          };
+            install -D ${essens_analyse.outputs.packages."${system}".default}/chemistry/essens_analyse.pdf ./dead-trees/chemistry/essens_analyse.pdf
+          '';
+          installPhase = ''
+            install -d $out/
+            cp --recursive . $out/
+          '';
+        };
+      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; [
-              alejandra
-              nodePackages_latest.prettier
-            ];
+            packages = [];
           };
         };
       }