1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

feat: switch to numtide devshell; unify user stateVersion and system stateVersion

This commit is contained in:
oddlama 2023-09-04 16:15:25 +02:00
parent b5563fa841
commit 919381aa87
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
4 changed files with 102 additions and 16 deletions

43
flake.lock generated
View file

@ -152,6 +152,27 @@
"type": "github" "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": { "disko": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -262,7 +283,7 @@
}, },
"flake-utils": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems_2"
}, },
"locked": { "locked": {
"lastModified": 1685518550, "lastModified": 1685518550,
@ -280,7 +301,7 @@
}, },
"flake-utils_2": { "flake-utils_2": {
"inputs": { "inputs": {
"systems": "systems_2" "systems": "systems_3"
}, },
"locked": { "locked": {
"lastModified": 1687709756, "lastModified": 1687709756,
@ -298,7 +319,7 @@
}, },
"flake-utils_3": { "flake-utils_3": {
"inputs": { "inputs": {
"systems": "systems_3" "systems": "systems_4"
}, },
"locked": { "locked": {
"lastModified": 1692799911, "lastModified": 1692799911,
@ -606,6 +627,7 @@
"agenix": "agenix", "agenix": "agenix",
"agenix-rekey": "agenix-rekey", "agenix-rekey": "agenix-rekey",
"colmena": "colmena", "colmena": "colmena",
"devshell": "devshell",
"disko": "disko", "disko": "disko",
"elewrap": "elewrap", "elewrap": "elewrap",
"flake-utils": "flake-utils_3", "flake-utils": "flake-utils_3",
@ -709,6 +731,21 @@
"type": "github" "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": { "templates": {
"locked": { "locked": {
"lastModified": 1691421369, "lastModified": 1691421369,

View file

@ -8,6 +8,11 @@
inputs.flake-utils.follows = "flake-utils"; inputs.flake-utils.follows = "flake-utils";
}; };
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = { disko = {
url = "github:nix-community/disko"; url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -74,6 +79,7 @@
self, self,
agenix-rekey, agenix-rekey,
colmena, colmena,
devshell,
elewrap, elewrap,
flake-utils, flake-utils,
microvm, microvm,
@ -136,6 +142,7 @@
++ [ ++ [
microvm.overlay microvm.overlay
elewrap.overlays.default elewrap.overlays.default
devshell.overlays.default
]; ];
}; };
@ -174,21 +181,56 @@
}; };
# `nix develop` # `nix develop`
devShells.default = pkgs.mkShell { devShells.default = pkgs.devshell.mkShell {
name = "nix-config"; name = "nix-config";
packages = with pkgs; [ packages = with pkgs; [
# Nix 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.
alejandra
cachix
deadnix
nix-tree
statix
update-nix-fetchgit
]; ];
shellHook = '' commands = with pkgs; [
${self.checks.${system}.pre-commit-hooks.shellHook} {
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` # `nix fmt`

View file

@ -1,8 +1,16 @@
{ {config, ...}: {
home-manager = { home-manager = {
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true; useUserPackages = true;
verbose = 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 # Required even when using home-manager's zsh module since the /etc/profile load order

View file

@ -16,7 +16,6 @@
]; ];
home = { home = {
inherit (config.system) stateVersion;
inherit (config.users.users.root) uid; inherit (config.users.users.root) uid;
username = config.users.users.root.name; username = config.users.users.root.name;