mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 23:29:08 +01:00
Add external host support
This commit is contained in:
parent
f93908d157
commit
28e704ceff
11 changed files with 31 additions and 21 deletions
|
|
@ -6,21 +6,31 @@
|
|||
}:
|
||||
let
|
||||
mkHost =
|
||||
hostName:
|
||||
hostDir:
|
||||
inputs.nixpkgs.lib.nixosSystem {
|
||||
specialArgs = { inherit inputs self; };
|
||||
modules =
|
||||
(lib.singleton { networking = { inherit hostName; }; })
|
||||
(lib.singleton { networking.hostName = lib.baseNameOf hostDir; })
|
||||
++ (
|
||||
"${self}/hosts/${hostName}"
|
||||
hostDir
|
||||
|> builtins.readDir
|
||||
|> lib.attrNames
|
||||
|> lib.filter (file: file |> lib.hasSuffix ".nix")
|
||||
|> lib.map (file: "${self}/hosts/${hostName}/${file}")
|
||||
|> 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 =
|
||||
"${self}/hosts" |> self.lib.listDirectoryNames |> self.lib.genAttrs mkHost;
|
||||
flake = {
|
||||
nixosConfigurations = mkHosts "${self}/hosts";
|
||||
externalConfigurations = mkHosts "${self}/external-hosts";
|
||||
allHosts = self.nixosConfigurations // self.externalConfigurations;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue