diff --git a/hosts/default.nix b/hosts/default.nix index 8665a39..aa7a0db 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -8,11 +8,12 @@ options.fleet = { hosts = lib.mkOption { description = "Host configuration"; - type = lib.types.attrsOf (lib.types.submodule { + type = lib.types.attrsOf (lib.types.submodule ({name, ...}: { options = { name = lib.mkOption { description = "Host name"; type = lib.types.strMatching "^$|^[[:alnum:]]([[:alnum:]_-]{0,61}[[:alnum:]])?$"; + default = name; }; system = lib.mkOption { description = "NixOS architecture (a.k.a. system)"; @@ -75,7 +76,7 @@ default = "ccr"; }; }; - }); + })); default = {}; }; _mkNixosConfiguration = lib.mkOption { @@ -90,6 +91,12 @@ ({lib, ...}: { networking.hostName = lib.mkForce hostname; nixpkgs.overlays = config.overlays; + networking.hosts = + lib.mapAttrs' (hostname: ip: { + name = ip; + value = ["${hostname}.fleet"]; + }) + (import "${self}/lib").ips; }) "${self.outPath}/hosts/${hostname}" ] diff --git a/lib/default.nix b/lib/default.nix index 4d32a5f..8f38faf 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -9,4 +9,8 @@ mothership = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFlepPWHE9GvQIBcAQBQPd80oiePSPxGDnMdqpdEqx6I"; }; }; + ips = { + mothership = "10.100.0.1"; + thinkpad = "10.100.0.2"; + }; }