about summary refs log tree commit diff
path: root/flake.nix
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-12-08 15:34:45 -0800
committerFranck Cuny <franck@fcuny.net>2024-12-08 15:36:35 -0800
commit9b4116e8f895834edada6b7c1efe787038fc0f3e (patch)
tree5648a0cfedbdfcad5f797cc3f39ecd0a33feb342 /flake.nix
parentmore refactoring (diff)
downloadworld-9b4116e8f895834edada6b7c1efe787038fc0f3e.tar.gz
add support for devshell and pre-commit-hooks again
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix54
1 files changed, 50 insertions, 4 deletions
diff --git a/flake.nix b/flake.nix
index e82e17f..e69d64c 100644
--- a/flake.nix
+++ b/flake.nix
@@ -18,32 +18,78 @@
       url = "github:numtide/treefmt-nix";
       inputs.nixpkgs.follows = "nixpkgs";
     };
+
+    flake-utils.url = "github:numtide/flake-utils";
+    pre-commit-hooks = {
+      url = "github:cachix/pre-commit-hooks.nix";
+      inputs.nixpkgs.follows = "nixpkgs";
+    };
+    devshell.url = "github:numtide/devshell";
+    devshell.inputs.nixpkgs.follows = "nixpkgs";
   };
 
   # Output config, or config for NixOS system
-  outputs = { nixpkgs, darwin, ... }@inputs:
-    let mkSystem = import ./nix/lib/mkSystem.nix { inherit nixpkgs inputs; };
-    in {
+  outputs =
+    { self
+    , nixpkgs
+    , darwin
+    , flake-utils
+    , pre-commit-hooks
+    , devshell
+    , ...
+    }@inputs:
+    flake-utils.lib.eachDefaultSystem (system:
+    let
+      pkgs = import nixpkgs {
+        inherit system;
+        overlays = [ devshell.overlays.default ];
+      };
+      mkSystem = import ./nix/lib/mkSystem.nix { inherit nixpkgs inputs; };
+    in
+    {
+      checks = {
+        pre-commit-check = pre-commit-hooks.lib.${system}.run {
+          src = ./.;
+          hooks = {
+            nixpkgs-fmt.enable = true;
+            check-merge-conflicts.enable = true;
+            end-of-file-fixer.enable = true;
+          };
+        };
+      };
+
+      devShells.default = pkgs.devshell.mkShell {
+        packages = with pkgs; [ just ];
+        env = [{
+          name = "DEVSHELL_NO_MOTD";
+          value = "1";
+        }];
+      };
+
+      # a VM running on the MacBook Air
       nixosConfigurations.vm-aarch64 = mkSystem "vm-aarch64" {
         system = "aarch64-linux";
         user = "fcuny";
       };
 
+      # a VM running on the synology DS923+
       nixosConfigurations.vm-synology = mkSystem "vm-synology" {
         system = "x86_64-linux";
         user = "fcuny";
       };
 
+      # my personal MacBook Air
       darwinConfigurations.macbook-air-m2 = mkSystem "macbook-air-m2" {
         system = "aarch64-darwin";
         user = "fcuny";
         darwin = true;
       };
 
+      # my work MacBook Pro
       darwinConfigurations.macbook-pro-intel = mkSystem "macbook-pro-intel" {
         system = "x86_64-darwin";
         user = "fcuny";
         darwin = true;
       };
-    };
+    });
 }