diff --git a/flake.lock b/flake.lock index 4d6c5b5..fb5a7ac 100644 --- a/flake.lock +++ b/flake.lock @@ -152,6 +152,27 @@ "type": "github" } }, + "devshell": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "systems": "systems" + }, + "locked": { + "lastModified": 1693818812, + "narHash": "sha256-KlLB94/Rt4l8/gdTOsSB5+YtsfKUqLTuM/DcsdpliLo=", + "owner": "numtide", + "repo": "devshell", + "rev": "c6add4ff593de4ce67095e500a5e3113636da839", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "disko": { "inputs": { "nixpkgs": [ @@ -262,7 +283,7 @@ }, "flake-utils": { "inputs": { - "systems": "systems" + "systems": "systems_2" }, "locked": { "lastModified": 1685518550, @@ -280,7 +301,7 @@ }, "flake-utils_2": { "inputs": { - "systems": "systems_2" + "systems": "systems_3" }, "locked": { "lastModified": 1687709756, @@ -298,7 +319,7 @@ }, "flake-utils_3": { "inputs": { - "systems": "systems_3" + "systems": "systems_4" }, "locked": { "lastModified": 1692799911, @@ -606,6 +627,7 @@ "agenix": "agenix", "agenix-rekey": "agenix-rekey", "colmena": "colmena", + "devshell": "devshell", "disko": "disko", "elewrap": "elewrap", "flake-utils": "flake-utils_3", @@ -709,6 +731,21 @@ "type": "github" } }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "templates": { "locked": { "lastModified": 1691421369, diff --git a/flake.nix b/flake.nix index 872ab17..299985f 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,11 @@ inputs.flake-utils.follows = "flake-utils"; }; + devshell = { + url = "github:numtide/devshell"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + disko = { url = "github:nix-community/disko"; inputs.nixpkgs.follows = "nixpkgs"; @@ -74,6 +79,7 @@ self, agenix-rekey, colmena, + devshell, elewrap, flake-utils, microvm, @@ -136,6 +142,7 @@ ++ [ microvm.overlay elewrap.overlays.default + devshell.overlays.default ]; }; @@ -174,21 +181,56 @@ }; # `nix develop` - devShells.default = pkgs.mkShell { + devShells.default = pkgs.devshell.mkShell { name = "nix-config"; packages = with pkgs; [ - # Nix - alejandra - cachix - deadnix - nix-tree - statix - update-nix-fetchgit + nix # Always use the nix version from this flake's nixpkgs versios, so that nix-plugins (below) doesn't fail because of different nix versions. ]; - shellHook = '' - ${self.checks.${system}.pre-commit-hooks.shellHook} - ''; + commands = with pkgs; [ + { + package = colmena.packages.${system}.colmena; + help = "Build and deploy this nix config to nodes"; + } + { + package = alejandra; + help = "Format nix code"; + } + { + package = statix; + help = "Lint nix code"; + } + { + package = deadnix; + help = "Find unused expressions in nix code"; + } + { + package = update-nix-fetchgit; + help = "Update fetcher hashes inside nix files"; + } + { + package = nix-tree; + help = "Interactively browse dependency graphs of Nix derivations"; + } + { + package = nix-diff; + help = "Explain why two Nix derivations differ"; + } + ]; + + devshell.startup.pre-commit.text = self.checks.${system}.pre-commit-hooks.shellHook; + + env = [ + { + # Additionally configure nix-plugins with our extra builtins file. + # We need this for our repo secrets. + name = "NIX_CONFIG"; + value = '' + plugin-files = ${pkgs.nix-plugins}/lib/nix/plugins + extra-builtins-file = ${self.outPath}/nix/extra-builtins.nix + ''; + } + ]; }; # `nix fmt` diff --git a/modules/config/home-manager.nix b/modules/config/home-manager.nix index bce4560..376d829 100644 --- a/modules/config/home-manager.nix +++ b/modules/config/home-manager.nix @@ -1,8 +1,16 @@ -{ +{config, ...}: { home-manager = { useGlobalPkgs = true; useUserPackages = true; verbose = true; + sharedModules = [ + { + home.stateVersion = config.system.stateVersion; + } + ]; + extraSpecialArgs = { + nixosConfig = config; + }; }; # Required even when using home-manager's zsh module since the /etc/profile load order diff --git a/users/root/default.nix b/users/root/default.nix index 60819d9..a64cfaf 100644 --- a/users/root/default.nix +++ b/users/root/default.nix @@ -16,7 +16,6 @@ ]; home = { - inherit (config.system) stateVersion; inherit (config.users.users.root) uid; username = config.users.users.root.name;