From 74c10c044667951c1b9d197511b052a544466201 Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 27 Mar 2021 02:07:14 +0100 Subject: [PATCH] config: add dhcpOpts, import from salt-pillar --- nix/lib/config/legacy.nix | 7 +++++++ nix/lib/config/options.nix | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/nix/lib/config/legacy.nix b/nix/lib/config/legacy.nix index 479c7dc..82be186 100644 --- a/nix/lib/config/legacy.nix +++ b/nix/lib/config/legacy.nix @@ -25,6 +25,13 @@ in (builtins.mapAttrs (_: vlan: { vlan = vlan; }) pillar.vlans) (builtins.mapAttrs (_: subnet4: { inherit subnet4; }) pillar.subnets-inet) (builtins.mapAttrs (_: hosts4: { inherit hosts4; }) pillar.hosts-inet) + (builtins.mapAttrs (_: dhcpData: { + dhcp = { + inherit (dhcpData) start end time max-time; + router = dhcpData.host-opts.routers; + domainName = dhcpData.string-opts.domain-name; + }; + }) pillar.dhcp) { core.ospf.secret = pillar.ospf.secret; } ] ++ ( map (ctx: diff --git a/nix/lib/config/options.nix b/nix/lib/config/options.nix index 3cafba7..476698e 100644 --- a/nix/lib/config/options.nix +++ b/nix/lib/config/options.nix @@ -2,6 +2,32 @@ with lib; let + dhcpOpts = { + start = mkOption { + description = "First IP address in pool"; + type = types.str; + }; + end = mkOption { + description = "Last IP address in pool"; + type = types.str; + }; + time = mkOption { + description = "Renew time in seconds"; + type = types.int; + }; + max-time = mkOption { + description = "Max renew time in seconds"; + type = types.int; + }; + router = mkOption { + description = "Gateway"; + type = types.str; + }; + domainName = mkOption { + description = "Domain name option"; + type = types.str; + }; + }; netOpts = { name, ... }: { options = { vlan = mkOption { @@ -45,6 +71,10 @@ let default = null; }; }; + dhcp = mkOption { + type = with types; nullOr (submodule { options = dhcpOpts; }); + default = null; + }; }; }; interfaceOpts = { name, ... }: {