diff --git a/lib/hosts.nix b/lib/hosts.nix new file mode 100644 index 0000000..b0e26d3 --- /dev/null +++ b/lib/hosts.nix @@ -0,0 +1,26 @@ +{ pkgs ? import ../pkgs {} }: + +with pkgs.lib; + +rec { + hostsDir = ../hosts; + + hostNames = attrNames ( + filterAttrs ( + name: type: type == "directory" + ) ( + builtins.readDir hostsDir + ) + ); + + hosts = listToAttrs ( + map ( + hostName: nameValuePair hostName ( + import (pkgs.path + "/nixos") { + configuration = import (hostsDir + "/${hostName}/configuration.nix"); + system = "x86_64-linux"; + } + ) + ) hostNames + ); +}