lib > builtins
This commit is contained in:
parent
47ccd698a9
commit
22f93f23ed
6 changed files with 39 additions and 38 deletions
19
flake.nix
19
flake.nix
|
@ -11,6 +11,7 @@
|
|||
|
||||
outputs = { self, nixpkgs-25-05, nixpkgs-unstable, deploy-rs, agenix }: let
|
||||
system = "x86_64-linux";
|
||||
lib = nixpkgs-25-05.lib;
|
||||
|
||||
# Mapping version identifiers to nixpkgs
|
||||
nixpkgsMap = {
|
||||
|
@ -40,16 +41,16 @@
|
|||
nodes = import ./nodes.nix;
|
||||
mapping = import ./mapping.nix;
|
||||
|
||||
findRolesForHost = hostName: builtins.filter
|
||||
(roleName: builtins.elem hostName mapping.${roleName}.hosts)
|
||||
(builtins.attrNames mapping);
|
||||
findRolesForHost = hostName: lib.filter
|
||||
(roleName: lib.elem hostName mapping.${roleName}.hosts)
|
||||
(lib.attrNames mapping);
|
||||
|
||||
getModulesForHost = hostName: let
|
||||
roles = findRolesForHost hostName;
|
||||
modulesList = builtins.map
|
||||
modulesList = map
|
||||
(role: mapping.${role}._inherit or [])
|
||||
roles;
|
||||
in builtins.concatLists modulesList;
|
||||
in lib.lists.concatLists modulesList;
|
||||
|
||||
defaultModules = [
|
||||
agenix.nixosModules.default
|
||||
|
@ -58,7 +59,7 @@
|
|||
];
|
||||
|
||||
in {
|
||||
nixosConfigurations = builtins.mapAttrs (name: config:
|
||||
nixosConfigurations = lib.mapAttrs (name: config:
|
||||
nixpkgsMap.${config.ver}.lib.nixosSystem {
|
||||
system = config.system;
|
||||
modules = getModulesForHost "${name}" ++ defaultModules ++ [{ hostName = "${name}"; }];
|
||||
|
@ -70,8 +71,8 @@
|
|||
autoRollback = true;
|
||||
magicRollback = true;
|
||||
remoteBuild = true;
|
||||
nodes = builtins.mapAttrs (name: config: {
|
||||
hostname = builtins.head (builtins.split "/" config.ip4);
|
||||
nodes = lib.mapAttrs (name: config: {
|
||||
hostname = lib.lists.head (lib.strings.splitString "/" config.ip4);
|
||||
profilesOrder = [ "system" ];
|
||||
profiles = {
|
||||
system = {
|
||||
|
@ -82,6 +83,6 @@
|
|||
};
|
||||
|
||||
# This is highly advised, and will prevent many possible mistakes, just run "deploy -s" to bypass it
|
||||
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
|
||||
checks = lib.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue