mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 23:29:08 +01:00
36 lines
834 B
Nix
36 lines
834 B
Nix
{
|
|
inputs,
|
|
self,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
mkHost =
|
|
hostDir:
|
|
inputs.nixpkgs.lib.nixosSystem {
|
|
specialArgs = { inherit inputs self; };
|
|
modules =
|
|
(lib.singleton { networking.hostName = lib.baseNameOf hostDir; })
|
|
++ (
|
|
hostDir
|
|
|> builtins.readDir
|
|
|> lib.attrNames
|
|
|> lib.filter (lib.hasSuffix ".nix")
|
|
|> lib.map (file: "${hostDir}/${file}")
|
|
);
|
|
};
|
|
|
|
mkHosts =
|
|
baseDir:
|
|
baseDir
|
|
|> builtins.readDir
|
|
|> lib.filterAttrs (_: type: type == "directory")
|
|
|> lib.mapAttrs (hostName: _: mkHost "${baseDir}/${hostName}");
|
|
in
|
|
{
|
|
flake = {
|
|
nixosConfigurations = mkHosts "${self}/hosts";
|
|
externalConfigurations = mkHosts "${self}/external-hosts";
|
|
allHosts = self.nixosConfigurations // self.externalConfigurations;
|
|
};
|
|
}
|