diff --git a/modules/networking/default.nix b/modules/networking/default.nix index d7ee3e2..1408b16 100644 --- a/modules/networking/default.nix +++ b/modules/networking/default.nix @@ -5,7 +5,7 @@ ./rename-interfaces ./routing ./wireguard - ./dhcp + # DHCP should directly use NixOS module --- kea ./isp-split-tunnel ]; diff --git a/modules/networking/dhcp/default.nix b/modules/networking/dhcp/default.nix deleted file mode 100644 index 55268c0..0000000 --- a/modules/networking/dhcp/default.nix +++ /dev/null @@ -1,50 +0,0 @@ -{ config, lib, ... }: - - -with lib; - -let - cfg = config.turbo.networking.dhcp; - subnetOptions = types.submodule (import ./subnet-options.nix { - inherit lib; - }); - - utils = import ./utils.nix { - inherit lib; - }; - - configText = utils.buildConfig cfg; -in -{ - options = { - turbo.networking.dhcp = { - enable = mkOption { - default = false; - type = with types; bool; - }; - - subnets = mkOption { - default = [ ]; - type = with types; listOf subnetOptions; - }; - - enableIpxe = mkOption { - default = false; - type = types.bool; - }; - - interfaces = mkOption { - default = [ ]; - type = with types; listOf str; - }; - }; - }; - - config = mkIf cfg.enable { - services.dhcpd4 = { - enable = true; - interfaces = cfg.interfaces; - extraConfig = configText; - }; - }; -} diff --git a/modules/networking/dhcp/host-options.nix b/modules/networking/dhcp/host-options.nix deleted file mode 100644 index e078011..0000000 --- a/modules/networking/dhcp/host-options.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ lib, ... }: - -with lib; -{ - options = { - name = mkOption { - type = types.str; - }; - - mac = mkOption { - type = types.str; - }; - - address = mkOption { - default = null; - type = with types; nullOr str; - }; - - router = mkOption { - default = null; - type = with types; nullOr str; - }; - - dns = mkOption { - default = null; - type = with types; nullOr str; - }; - - extraOptions = mkOption { - default = null; - type = with types; nullOr str; - }; - }; -} diff --git a/modules/networking/dhcp/subnet-options.nix b/modules/networking/dhcp/subnet-options.nix deleted file mode 100644 index 9433279..0000000 --- a/modules/networking/dhcp/subnet-options.nix +++ /dev/null @@ -1,63 +0,0 @@ -{ lib, ... }: - -with lib; -let - hostOptions = types.submodule (import ./host-options.nix { - inherit lib; - }); -in -{ - options = { - ip = mkOption { - type = types.str; - }; - - netmask = mkOption { - type = types.str; - default = "255.255.255.0"; - }; - - rangeBegin = mkOption { - type = types.str; - }; - - rangeEnd = mkOption { - type = types.str; - }; - - dns = mkOption { - default = null; - type = with types; nullOr str; - }; - - router = mkOption { - default = null; - type = with types; nullOr str; - }; - - ipxeFile = mkOption { - default = null; - type = with types; nullOr str; - }; - - tftpServer = mkOption { - default = null; - type = with types; nullOr str; - }; - - interface = mkOption { - default = null; - type = with types; nullOr str; - }; - - hosts = mkOption { - default = [ ]; - type = types.listOf hostOptions; - }; - - extraConfig = mkOption { - default = ""; - type = types.str; - }; - }; -} diff --git a/modules/networking/dhcp/utils.nix b/modules/networking/dhcp/utils.nix deleted file mode 100644 index 5488912..0000000 --- a/modules/networking/dhcp/utils.nix +++ /dev/null @@ -1,131 +0,0 @@ -{ lib }: - -with lib; - -let - ipxeOptionsString = '' - # Unifi Config Space - option space ubnt; - option ubnt.unifi-address code 1 = ip-address; - - class "ubnt" { - match if substring (option vendor-class-identifier, 0, 4) = "ubnt"; - option vendor-class-identifier "ubnt"; - vendor-option-space ubnt; - } - # iPXE config space - option space ipxe; - option ipxe-encap-opts code 175 = encapsulate ipxe; - option ipxe.priority code 1 = signed integer 8; - option ipxe.keep-san code 8 = unsigned integer 8; - option ipxe.skip-san-boot code 9 = unsigned integer 8; - option ipxe.syslogs code 85 = string; - option ipxe.cert code 91 = string; - option ipxe.privkey code 92 = string; - option ipxe.crosscert code 93 = string; - option ipxe.no-pxedhcp code 176 = unsigned integer 8; - option ipxe.bus-id code 177 = string; - option ipxe.san-filename code 188 = string; - option ipxe.bios-drive code 189 = unsigned integer 8; - option ipxe.username code 190 = string; - option ipxe.password code 191 = string; - option ipxe.reverse-username code 192 = string; - option ipxe.reverse-password code 193 = string; - option ipxe.version code 235 = string; - option iscsi-initiator-iqn code 203 = string; - # Feature indicators - option ipxe.pxeext code 16 = unsigned integer 8; - option ipxe.iscsi code 17 = unsigned integer 8; - option ipxe.aoe code 18 = unsigned integer 8; - option ipxe.http code 19 = unsigned integer 8; - option ipxe.https code 20 = unsigned integer 8; - option ipxe.tftp code 21 = unsigned integer 8; - option ipxe.ftp code 22 = unsigned integer 8; - option ipxe.dns code 23 = unsigned integer 8; - option ipxe.bzimage code 24 = unsigned integer 8; - option ipxe.multiboot code 25 = unsigned integer 8; - option ipxe.slam code 26 = unsigned integer 8; - option ipxe.srp code 27 = unsigned integer 8; - option ipxe.nbi code 32 = unsigned integer 8; - option ipxe.pxe code 33 = unsigned integer 8; - option ipxe.elf code 34 = unsigned integer 8; - option ipxe.comboot code 35 = unsigned integer 8; - option ipxe.efi code 36 = unsigned integer 8; - option ipxe.fcoe code 37 = unsigned integer 8; - option ipxe.vlan code 38 = unsigned integer 8; - option ipxe.menu code 39 = unsigned integer 8; - option ipxe.sdi code 40 = unsigned integer 8; - option ipxe.nfs code 41 = unsigned integer 8; - option client-arch code 93 = unsigned integer 16; - option ipxe.no-pxedhcp 1; - ''; - - buildHost = opt: '' - host ${opt.name} { - hardware ethernet ${opt.mac}; - ${optionalString (opt.address != null) '' - fixed-address ${opt.address}; - ''} - - ${optionalString (opt.router != null) '' - option routers ${opt.router}; - ''} - - ${optionalString (opt.dns != null) '' - option domain-name-servers ${opt.dns}; - ''} - - ${optionalString (opt.extraOptions != null) '' - ${opt.extraOptions} - ''} - } - ''; - - buildSubnet = opt: '' - subnet ${opt.ip} netmask ${opt.netmask} { - range ${opt.rangeBegin} ${opt.rangeEnd}; - option subnet-mask ${opt.netmask}; - ${optionalString (opt.router != null) '' - option routers ${opt.router}; - ''} - ${optionalString (opt.dns != null) '' - option domain-name-servers ${opt.dns}; - ''} - ${optionalString (opt.interface != null) '' - interface ${opt.interface}; - ''} - - ${opt.extraConfig} - - ${optionalString (opt.ipxeFile != null) '' - if exists user-class and option user-class = "iPXE" { - filename "${opt.ipxeFile}"; - } - ''} - - ${optionalString (opt.tftpServer != null) '' - else if option client-arch != 00:00 { - next-server ${opt.tftpServer}; - filename "ipxe.efi"; - } - - else { - next-server ${opt.tftpServer}; - filename "undionly.kpxe"; - } - - ''} - - ${builtins.concatStringsSep "\n" (map buildHost opt.hosts)} - } - ''; - -in -rec { - buildConfig = opt: '' - ddns-update-style none; - ${optionalString opt.enableIpxe ipxeOptionsString} - - ${builtins.concatStringsSep "\n" (map buildSubnet opt.subnets)} - ''; -} diff --git a/modules/virtualization/libvirt/default.nix b/modules/virtualization/libvirt/default.nix index 9173ae2..178ca1d 100644 --- a/modules/virtualization/libvirt/default.nix +++ b/modules/virtualization/libvirt/default.nix @@ -276,10 +276,27 @@ let buildMemoryBacking = md: '' + ${shouldWrite md.hugepages '' + + ${md.hugepages} + + ''} + ${shouldWrite md.nosharepages '' + + ''} + ${shouldWrite md.locked '' + + ''} ${shouldWrite md.sourceType '' ''} + ${shouldWrite md.allocation '' + + ''} ''; diff --git a/modules/virtualization/libvirt/memoryBacking.nix b/modules/virtualization/libvirt/memoryBacking.nix index 3bf2f82..fbfef04 100644 --- a/modules/virtualization/libvirt/memoryBacking.nix +++ b/modules/virtualization/libvirt/memoryBacking.nix @@ -1,6 +1,18 @@ { lib, ... }: with lib; let + allocationModule = { + options = { + mode = mkOption { + type = types.nullOr (types.enum ["immediate" "ondemand"]); + default = null; + }; + threads = mkOption { + type = types.nullOr types.int; + default = null; + }; + }; + }; in { options = { @@ -13,5 +25,31 @@ in type = types.enum [ "shared" "private" ]; default = "shared"; }; + + hugepages = mkOption { + type = types.nullOr types.str; + default = null; + description = "add xml def or empty string to enable"; + }; + + nosharepages = mkOption { + type = types.bool; + default = false; + }; + + locked = mkOption { + type = types.bool; + default = false; + }; + + allocation = mkOption { + type = types.nullOr (types.submodule allocationModule); + default = null; + }; + + discard = mkOption { + type = types.bool; + default = false; + }; }; }