2021-09-24 11:31:56 -07:00
|
|
|
{ lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
{
|
|
|
|
base-host-config = host-path: let
|
|
|
|
hostname-from-file = filename: builtins.replaceStrings [".nix"] [""] filename;
|
|
|
|
|
|
|
|
is-nix-file = filename: type: (builtins.match ".+\.nix$" filename) != null;
|
|
|
|
is-regular-file = filename: type: type == "regular" || type == "link";
|
|
|
|
|
|
|
|
host-files = attrNames (filterAttrs is-nix-file (filterAttrs is-regular-file (builtins.readDir host-path)));
|
|
|
|
hosts = map hostname-from-file host-files;
|
|
|
|
|
2021-09-29 17:55:13 -07:00
|
|
|
load-host-file = hostname: import (host-path + "/${hostname}.nix");
|
2021-09-24 11:31:56 -07:00
|
|
|
in genAttrs hosts (hostname: load-host-file hostname);
|
|
|
|
}
|