2023-09-02 16:26:45 +00:00
|
|
|
{ nixpkgs, self, 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 =
|
2023-09-03 11:24:36 +00:00
|
|
|
if builtins.pathExists "${directory}/machines"
|
2023-09-03 12:04:18 +00:00
|
|
|
then builtins.readDir directory + /machines
|
2023-08-29 13:00:03 +00:00
|
|
|
else { };
|
|
|
|
|
|
|
|
machineSettings = machineName:
|
2023-09-03 11:24:36 +00:00
|
|
|
if builtins.pathExists "${directory}/machines/${machineName}/settings.json"
|
2023-09-03 12:04:18 +00:00
|
|
|
then builtins.fromJSON (builtins.readFile directory + /machines/${machineName}/settings.json)
|
2023-08-29 13:00:03 +00:00
|
|
|
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-09-02 16:26:45 +00:00
|
|
|
self.nixosModules.clanCore
|
2023-08-29 13:00:03 +00:00
|
|
|
(machineSettings name)
|
|
|
|
(machines.${name} or { })
|
2023-09-03 11:09:35 +00:00
|
|
|
{
|
|
|
|
clanCore.machineName = name;
|
2023-09-03 11:53:20 +00:00
|
|
|
clanCore.clanDir = directory;
|
2023-09-03 11:09:35 +00:00
|
|
|
# TODO: remove this once we have a hardware-config mechanism
|
|
|
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
|
|
}
|
2023-08-29 20:29:32 +00:00
|
|
|
];
|
2023-09-03 11:09:35 +00:00
|
|
|
inherit specialArgs;
|
2023-08-29 13:00:03 +00:00
|
|
|
})
|
2023-08-29 20:03:57 +00:00
|
|
|
(machinesDirs // machines);
|
2023-08-29 13:00:03 +00:00
|
|
|
in
|
|
|
|
nixosConfigurations
|