init: static-hosts module #1385
@ -14,6 +14,7 @@
|
||||
root-password = ./root-password;
|
||||
sshd = ./sshd;
|
||||
sunshine = ./sunshine;
|
||||
static-hosts = ./static-hosts;
|
||||
syncthing = ./syncthing;
|
||||
thelounge = ./thelounge;
|
||||
user-password = ./root-password;
|
||||
|
2
clanModules/static-hosts/README.md
Normal file
2
clanModules/static-hosts/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
Statically configure the host names of machines based on their respective zerotier-ip.
|
||||
---
|
24
clanModules/static-hosts/default.nix
Normal file
24
clanModules/static-hosts/default.nix
Normal file
@ -0,0 +1,24 @@
|
||||
{ lib, config, ... }:
|
||||
{
|
||||
options.clan.static-hosts = {
|
||||
excludeHosts = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ config.clanCore.machineName ];
|
||||
description = "Hosts that should be excluded";
|
||||
};
|
||||
};
|
||||
|
||||
config.networking.hosts =
|
||||
let
|
||||
clanDir = config.clanCore.clanDir;
|
||||
machineDir = clanDir + "/machines/";
|
||||
zerotierIpMachinePath = machines: machineDir + machines + "/facts/zerotier-ip";
|
||||
machines = builtins.readDir machineDir;
|
||||
filteredMachines = lib.filterAttrs (
|
||||
name: _: !(lib.elem name config.clan.static-hosts.excludeHosts)
|
||||
) machines;
|
||||
in
|
||||
(lib.mapAttrs' (
|
||||
machine: _: lib.nameValuePair (builtins.readFile (zerotierIpMachinePath machine)) [ machine ]
|
||||
) filteredMachines);
|
||||
}
|
@ -62,6 +62,7 @@ nav:
|
||||
- reference/clanModules/sshd.md
|
||||
- reference/clanModules/sunshine.md
|
||||
- reference/clanModules/syncthing.md
|
||||
- reference/clanModules/static-hosts.md
|
||||
- reference/clanModules/thelounge.md
|
||||
- reference/clanModules/user-password.md
|
||||
- reference/clanModules/xfce.md
|
||||
|
Loading…
Reference in New Issue
Block a user