mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 17:49:07 +01:00
34 lines
752 B
Nix
34 lines
752 B
Nix
{
|
|
inputs,
|
|
self,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
mkHost =
|
|
hostDir:
|
|
inputs.nixpkgs.lib.nixosSystem {
|
|
specialArgs = {
|
|
inherit inputs self;
|
|
inherit (self) allHosts;
|
|
};
|
|
modules =
|
|
(lib.singleton {
|
|
networking.hostName = hostDir |> lib.baseNameOf |> lib.unsafeDiscardStringContext;
|
|
})
|
|
++ self.lib.listNixFilesRecursively hostDir;
|
|
};
|
|
|
|
mkHosts =
|
|
baseDir:
|
|
baseDir
|
|
|> self.lib.listDirectoryNames
|
|
|> self.lib.genAttrs (hostName: mkHost "${baseDir}/${hostName}");
|
|
in
|
|
{
|
|
flake = {
|
|
nixosConfigurations = mkHosts "${self}/hosts";
|
|
externalConfigurations = mkHosts "${self}/external-hosts";
|
|
allHosts = self.nixosConfigurations // self.externalConfigurations;
|
|
};
|
|
}
|