diff --git a/lib/default.nix b/lib/default.nix index ca7c9ee..52171ce 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,5 +1,7 @@ -{lib}: { - imports=[./net.nix]; +{lib}:let + net = import ./net.nix {inherit lib;}; +in +{ dirToStrings = dir: (map (v: builtins.readFile "${dir}/${v}") (builtins.filter (v: @@ -11,4 +13,10 @@ ) else [] ))); + + + calcSystemdDhcpPoolOffset = {base, start, end}: { + offset = net.lib.net.ip.diff start base; + size = net.lib.net.ip.diff end start; + }; } diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix deleted file mode 100644 index 4da28bd..0000000 --- a/modules/nixos/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - config, - pkgs, - lib, - inputs, - ... -}: { - imports=[./systemd-dhcpServ.nix]; -} diff --git a/modules/nixos/systemd-dhcpServ.nix b/modules/nixos/systemd-dhcpServ.nix deleted file mode 100644 index 9e85bce..0000000 --- a/modules/nixos/systemd-dhcpServ.nix +++ /dev/null @@ -1,108 +0,0 @@ -{ - config, - pkgs, - lib, - inputs, - ... -}: { - options = { - host.systemdDhcpSrv = { - enable = lib.mkEnableOption "systemd DHCP server"; - - interface = lib.mkOption { - type = lib.types.str; - description = "interface to run dhcp server on"; - }; - - uplinkInterface = lib.mkOption { - type = lib.types.str; - description = "if dns, router, or ntp are set but no adresses are set, pass on the settings of this interface."; - default = ":auto"; - }; - - pool = lib.mkOption { - description = "the pool of ips the dhcp server will hand out."; - type = lib.types.submodule { - options = { - start = lib.mkOption { - type = lib.types.str; - description = "starting IP of the range the dhcp server will assign"; - }; - end = lib.mkOption { - type = lib.types.str; - description = "ending IP of the range the dhcp server will assign"; - }; - }; - }; - }; - - time = lib.mkOption { - type = lib.types.submodule { - options = { - default = lib.mkOption { - description = "the default dhcp lease time, in seconds, defaults to 1h"; - type = lib.types.nullOr lib.types.int; - default = null; - }; - max = lib.mkOption { - description = "the max dhcp lease time, in seconds. defaults to 12h"; - type = lib.types.nullOr lib.types.int; - default = null; - }; - }; - }; - }; - - dns = lib.mkoption { - type = lib.types.submodule { - options = { - enable = lib.mkOption { - type = lib.types.bool; - default = true; - description = "whether to include dns server info in the dhcp lease"; - }; - servers = lib.mkOption { - type = lib.types.listOf lib.types.str; - description = "IPs of dns servers to hand out"; - default = []; - }; - }; - }; - }; - - router = lib.mkoption { - type = lib.types.submodule { - options = { - enable = lib.mkOption { - type = lib.types.bool; - default = true; - description = "whether to include router (gateway) info in the dhcp lease"; - }; - servers = lib.mkOption { - type = lib.types.listOf lib.types.str; - description = "IPs of dns servers to hand out"; - default = []; - }; - }; - }; - }; - - ntp = lib.mkoption { - type = lib.types.submodule { - options = { - enable = lib.mkOption { - type = lib.types.bool; - default = true; - description = "whether to include ntp server info in the dhcp lease"; - }; - servers = lib.mkOption { - type = lib.types.listOf lib.types.str; - description = "IPs of ntp servers to hand out"; - default = []; - }; - }; - }; - }; - }; - }; -}