refactor nix config a bit

This commit is contained in:
Vivian 2022-12-26 15:13:04 +01:00
parent 4b90002e45
commit 424d48bdb1
9 changed files with 182 additions and 238 deletions

View file

@ -1,13 +1,16 @@
{ config, pkgs, hosts, ... }:
let
inherit (builtins) filter hasAttr;
inherit (pkgs.lib.attrsets) mapAttrsToList;
hostToDhcp = { hostname, mac, ip, ... }: {
ethernetAddress = mac;
hostName = hostname;
ipAddress = ip;
};
localDomain = config.networking.domain;
hosts' = filter (h: hasAttr "ip" h && hasAttr "mac" h) hosts.${localDomain};
# TODO: Alternatively filter on flat_hosts where realm == localDomain
local_hosts = mapAttrsToList (name: value: value // { hostname = name; }) hosts.${localDomain};
hosts' = filter (h: hasAttr "ip" h && hasAttr "mac" h) local_hosts;
in {
imports = [ ];