nixos/libvirt: Syntactic-only refactoring

(cherry picked from commit a0c0f63811)
This commit is contained in:
Rickard Nilsson 2016-06-27 13:10:05 +02:00
parent bb52e1449d
commit adc5760bb2

View File

@ -1,5 +1,3 @@
# Systemd services for libvirtd.
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib; with lib;
@ -16,19 +14,16 @@ let
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
in in {
{
###### interface ###### interface
options = { options = {
virtualisation.libvirtd.enable = virtualisation.libvirtd.enable = mkOption {
mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = description = ''
''
This option enables libvirtd, a daemon that manages This option enables libvirtd, a daemon that manages
virtual machines. Users in the "libvirtd" group can interact with virtual machines. Users in the "libvirtd" group can interact with
the daemon (e.g. to start or stop VMs) using the the daemon (e.g. to start or stop VMs) using the
@ -36,44 +31,36 @@ in
''; '';
}; };
virtualisation.libvirtd.enableKVM = virtualisation.libvirtd.enableKVM = mkOption {
mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
description = description = ''
''
This option enables support for QEMU/KVM in libvirtd. This option enables support for QEMU/KVM in libvirtd.
''; '';
}; };
virtualisation.libvirtd.extraConfig = virtualisation.libvirtd.extraConfig = mkOption {
mkOption {
type = types.lines; type = types.lines;
default = ""; default = "";
description = description = ''
''
Extra contents appended to the libvirtd configuration file, Extra contents appended to the libvirtd configuration file,
libvirtd.conf. libvirtd.conf.
''; '';
}; };
virtualisation.libvirtd.extraOptions = virtualisation.libvirtd.extraOptions = mkOption {
mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [ ];
example = [ "--verbose" ]; example = [ "--verbose" ];
description = description = ''
''
Extra command line arguments passed to libvirtd on startup. Extra command line arguments passed to libvirtd on startup.
''; '';
}; };
virtualisation.libvirtd.onShutdown = virtualisation.libvirtd.onShutdown = mkOption {
mkOption {
type = types.enum ["shutdown" "suspend" ]; type = types.enum ["shutdown" "suspend" ];
default = "suspend"; default = "suspend";
description = description = ''
''
When shutting down / restarting the host what method should When shutting down / restarting the host what method should
be used to gracefully halt the guests. Setting to "shutdown" be used to gracefully halt the guests. Setting to "shutdown"
will cause an ACPI shutdown of each guest. "suspend" will will cause an ACPI shutdown of each guest. "suspend" will
@ -81,7 +68,6 @@ in
''; '';
}; };
}; };
@ -95,8 +81,10 @@ in
boot.kernelModules = [ "tun" ]; boot.kernelModules = [ "tun" ];
systemd.services.libvirtd = users.extraGroups.libvirtd.gid = config.ids.gids.libvirtd;
{ description = "Libvirt Virtual Machine Management Daemon";
systemd.services.libvirtd = {
description = "Libvirt Virtual Machine Management Daemon";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "systemd-udev-settle.service" ] after = [ "systemd-udev-settle.service" ]
@ -111,8 +99,7 @@ in
++ optional cfg.enableKVM pkgs.qemu_kvm ++ optional cfg.enableKVM pkgs.qemu_kvm
++ optional vswitch.enable vswitch.package; ++ optional vswitch.enable vswitch.package;
preStart = preStart = ''
''
mkdir -p /var/log/libvirt/qemu -m 755 mkdir -p /var/log/libvirt/qemu -m 755
rm -f /var/run/libvirtd.pid rm -f /var/run/libvirtd.pid
@ -176,8 +163,5 @@ in
description = "Virtual machine lock manager"; description = "Virtual machine lock manager";
serviceConfig.ExecStart = "@${pkgs.libvirt}/sbin/virtlockd virtlockd"; serviceConfig.ExecStart = "@${pkgs.libvirt}/sbin/virtlockd virtlockd";
}; };
users.extraGroups.libvirtd.gid = config.ids.gids.libvirtd;
}; };
} }