2023-08-30 14:41:10 +00:00
|
|
|
{ nixpkgs, clan, lib }:
|
2023-08-29 13:00:03 +00:00
|
|
|
{ directory # The directory containing the machines subdirectory
|
|
|
|
, specialArgs ? { } # Extra arguments to pass to nixosSystem i.e. useful to make self available
|
|
|
|
, machines ? { } # allows to include machine-specific modules i.e. machines.${name} = { ... }
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
machinesDirs =
|
|
|
|
if builtins.pathExists (directory + /machines)
|
|
|
|
then builtins.readDir (directory + /machines)
|
|
|
|
else { };
|
|
|
|
|
|
|
|
machineSettings = machineName:
|
|
|
|
if builtins.pathExists (directory + /machines/${machineName}/settings.json)
|
|
|
|
then builtins.fromJSON (builtins.readFile (directory + /machines/${machineName}/settings.json))
|
|
|
|
else { };
|
|
|
|
|
|
|
|
nixosConfigurations = lib.mapAttrs
|
2023-08-29 20:03:57 +00:00
|
|
|
(name: _:
|
2023-08-29 13:00:03 +00:00
|
|
|
nixpkgs.lib.nixosSystem {
|
|
|
|
modules = [
|
2023-08-30 14:41:10 +00:00
|
|
|
clan.nixosModules.clanCore
|
2023-08-29 13:00:03 +00:00
|
|
|
(machineSettings name)
|
|
|
|
(machines.${name} or { })
|
2023-08-29 20:29:32 +00:00
|
|
|
];
|
2023-08-29 13:00:03 +00:00
|
|
|
specialArgs = specialArgs;
|
|
|
|
})
|
2023-08-29 20:03:57 +00:00
|
|
|
(machinesDirs // machines);
|
2023-08-29 13:00:03 +00:00
|
|
|
in
|
|
|
|
nixosConfigurations
|