Commit 412543dd authored by John Chadwick's avatar John Chadwick
Browse files

nixos/libvirtd: add support for nss modules

parent 07fb3036
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -183,6 +183,31 @@ let
      };
    };
  };

  nssModule = types.submodule {
    options = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = lib.mdDoc ''
          This option enables the older libvirt NSS module. This method uses
          DHCP server records, therefore is dependent on the hostname provided
          by the guest.
          Please see https://libvirt.org/nss.html for more information.
        '';
      };

      enableGuest = mkOption {
        type = types.bool;
        default = false;
        description = lib.mdDoc ''
          This option enables the newer libvirt_guest NSS module. This module
          uses the libvirt guest name instead of the hostname of the guest.
          Please see https://libvirt.org/nss.html for more information.
        '';
      };
    };
  };
in
{

@@ -308,6 +333,14 @@ in
        Hooks related options.
      '';
    };

    nss = mkOption {
      type = nssModule;
      default = { };
      description = lib.mdDoc ''
        libvirt NSS module options.
      '';
    };
  };


@@ -498,5 +531,11 @@ in
        });
      '';
    };

    system.nssModules = optional (cfg.nss.enable or cfg.nss.enableGuest) cfg.package;
    system.nssDatabases.hosts = builtins.concatLists [
      (optional cfg.nss.enable "libvirt")
      (optional cfg.nss.enableGuest "libvirt_guest")
    ];
  };
}
+1 −1
Original line number Diff line number Diff line
@@ -14,10 +14,10 @@ import ./make-test-python.nix ({ pkgs, ... }: {
          libvirtd.hooks.qemu.is_working = "${pkgs.writeShellScript "testHook.sh" ''
            touch /tmp/qemu_hook_is_working
          ''}";
          libvirtd.nss.enable = true;
        };
        boot.supportedFilesystems = [ "zfs" ];
        networking.hostId = "deadbeef"; # needed for zfs
        networking.nameservers = [ "192.168.122.1" ];
        security.polkit.enable = true;
        environment.systemPackages = with pkgs; [ virt-manager ];
      };