about summary refs log tree commit diff
path: root/nixos/modules/virtualisation
diff options
context:
space:
mode:
authorTristan Helmich <tristan.helmich@gmail.com>2015-12-18 14:07:53 +0100
committerTristan Helmich <tristan.helmich@gmail.com>2016-01-15 14:26:20 +0100
commitbce59a1a8bb0430533178df080937ce24efe926a (patch)
treeb33c7e17ebc8a9a8b70e3ebecce49c08a291cf7c /nixos/modules/virtualisation
parentc29df5f8a7122fbc9411765156ab42c12baadbbb (diff)
downloadnixlib-bce59a1a8bb0430533178df080937ce24efe926a.tar
nixlib-bce59a1a8bb0430533178df080937ce24efe926a.tar.gz
nixlib-bce59a1a8bb0430533178df080937ce24efe926a.tar.bz2
nixlib-bce59a1a8bb0430533178df080937ce24efe926a.tar.lz
nixlib-bce59a1a8bb0430533178df080937ce24efe926a.tar.xz
nixlib-bce59a1a8bb0430533178df080937ce24efe926a.tar.zst
nixlib-bce59a1a8bb0430533178df080937ce24efe926a.zip
libvirtd service: Move mutable configs to /var
Modifies libvirt package to search for configs in /var/lib and changes
libvirtd service to copy the default configs to the new location.

This enables the user to change e.g. the networking configuration with
virsh or virt-manager and keep those settings.
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r--nixos/modules/virtualisation/libvirtd.nix14
1 files changed, 5 insertions, 9 deletions
diff --git a/nixos/modules/virtualisation/libvirtd.nix b/nixos/modules/virtualisation/libvirtd.nix
index 3668d17ac89b..67fbb8263b05 100644
--- a/nixos/modules/virtualisation/libvirtd.nix
+++ b/nixos/modules/virtualisation/libvirtd.nix
@@ -122,18 +122,14 @@ in
             chmod 755 /var/lib/libvirt
             chmod 755 /var/lib/libvirt/dnsmasq
 
-            # Libvirt unfortunately writes mutable state (such as
-            # runtime changes to VM, network or filter configurations)
-            # to /etc.  So we can't use environment.etc to make the
-            # default network and filter definitions available, since
-            # libvirt will then modify the originals in the Nix store.
-            # So here we copy them instead.  Ugly.
-            for i in $(cd ${pkgs.libvirt}/etc && echo \
+            # Copy default libvirt network config .xml files to /var/lib
+            # Files modified by the user will not be overwritten
+            for i in $(cd ${pkgs.libvirt}/var/lib && echo \
                 libvirt/qemu/networks/*.xml libvirt/qemu/networks/autostart/*.xml \
                 libvirt/nwfilter/*.xml );
             do
-                mkdir -p /etc/$(dirname $i) -m 755
-                cp -fpd ${pkgs.libvirt}/etc/$i /etc/$i
+                mkdir -p /var/lib/$(dirname $i) -m 755
+                cp -npd ${pkgs.libvirt}/var/lib/$i /var/lib/$i
             done
 
             # libvirtd puts the full path of the emulator binary in the machine