improve the handling of the different nixpkgs version in flake.nix
This commit is contained in:
parent
0060b2e6b1
commit
24e8170453
1 changed files with 22 additions and 20 deletions
42
flake.nix
42
flake.nix
|
@ -12,28 +12,30 @@
|
|||
outputs = { self, nixpkgs-25-05, nixpkgs-unstable, deploy-rs, agenix }: let
|
||||
system = "x86_64-linux";
|
||||
|
||||
# Mapping version identifiers to nixpkgs
|
||||
nixpkgsMap = {
|
||||
"25.05" = nixpkgs-25-05;
|
||||
"unstable" = nixpkgs-unstable;
|
||||
};
|
||||
|
||||
importPkgs = version: overlays: import nixpkgsMap.${version} {
|
||||
inherit system;
|
||||
overlays = if overlays == null then [] else overlays;
|
||||
};
|
||||
|
||||
# Unmodified nixpkgs
|
||||
pkgs-25-05 = import nixpkgs-25-05 { inherit system; };
|
||||
pkgs-unstable = import nixpkgs-unstable { inherit system; };
|
||||
getNixpkgs = version: importPkgs version [];
|
||||
|
||||
# nixpkgs with deploy-rs overlay but force the nixpkgs package
|
||||
deployPkgs-25-05 = import nixpkgs-25-05 {
|
||||
inherit system;
|
||||
overlays = [
|
||||
deploy-rs.overlays.default
|
||||
(self: super: { deploy-rs = { inherit (pkgs-25-05) deploy-rs; lib = super.deploy-rs.lib; }; })
|
||||
];
|
||||
};
|
||||
deployPkgs-unstable = import nixpkgs-unstable {
|
||||
inherit system;
|
||||
overlays = [
|
||||
deploy-rs.overlays.default
|
||||
(self: super: { deploy-rs = { inherit (pkgs-unstable) deploy-rs; lib = super.deploy-rs.lib; }; })
|
||||
];
|
||||
};
|
||||
|
||||
getDeployPkgs = ver: if ver == "25.05" then deployPkgs-25-05 else deployPkgs-unstable;
|
||||
getNixpkgs = ver: if ver == "25.05" then nixpkgs-25-05 else nixpkgs-unstable;
|
||||
getDeployPkgs = version: importPkgs version [
|
||||
deploy-rs.overlays.default
|
||||
(self: super: {
|
||||
deploy-rs = {
|
||||
inherit (getNixpkgs version) deploy-rs;
|
||||
lib = super.deploy-rs.lib;
|
||||
};
|
||||
})
|
||||
];
|
||||
|
||||
nodes = import ./nodes.nix;
|
||||
mapping = import ./mapping.nix;
|
||||
|
@ -57,7 +59,7 @@
|
|||
|
||||
in {
|
||||
nixosConfigurations = builtins.mapAttrs (name: config:
|
||||
(getNixpkgs config.ver).lib.nixosSystem {
|
||||
nixpkgsMap.${config.ver}.lib.nixosSystem {
|
||||
system = config.system;
|
||||
modules = getModulesForHost "${name}" ++ defaultModules ++ [{ hostName = "${name}"; }];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue