utilisation des profils pour modifier les flags :)

nixos-19.09
Yves Dubromelle 8 years ago
parent 745d2cd171
commit c43adc80cb

@ -14,17 +14,33 @@ let
graphical = true; graphical = true;
docker = true; docker = true;
}; };
isServer = { #isServer = {
}; #};
}; };
in in
rec { with lib; rec{
# Apply the profiles (pre-defined + custom) to the whole directory
applyProfilesToDirectory = customProfiles: directory: applyProfilesToDirectory = customProfiles: directory:
lib.mapAttrs (applyProfilesToMachine customProfiles) directory; lib.mapAttrs (applyProfilesToMachine customProfiles) directory;
# Apply the profiles (pre-defined + custom) to a machine
applyProfilesToMachine = customProfiles: machineName: machineOptions: applyProfilesToMachine = customProfiles: machineName: machineOptions:
machineOptions; { configuration-flags = lib.recursiveUpdate (generateFlagsSet customProfiles machineOptions.profiles) machineOptions.configuration-flags;
#lib.recursiveUpdate {} machineOptions; ipAddress = machineOptions.ipAddress;
tinc = machineOptions.tinc;
profiles = machineOptions.profiles;
};
# Generate a set of configuration flags based on profiles
generateFlagsSet = customProfiles: machineProfiles:
let
allProfiles = recursiveUpdate profiles customProfiles;
conditionalFlags = name: value:
if machineProfiles.${name}
then value
else {};
in
foldr (a: b: a // b) {} (mapAttrsToList conditionalFlags allProfiles);
} }

Loading…
Cancel
Save