about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorPatryk Wychowaniec <wychowaniec.patryk@gmail.com>2020-06-05 14:40:02 +0200
committerPatryk Wychowaniec <wychowaniec.patryk@gmail.com>2020-06-05 16:37:31 +0200
commit6c6924b2eb54658ededd4e20275c4a5b2ebab24c (patch)
treee9c41a7385e7fac1b365eaa9787d4e9bddd5ea28 /nixos
parent4dee97c43e72daee80e1c6b61e402c7cad6ac689 (diff)
downloadnixlib-6c6924b2eb54658ededd4e20275c4a5b2ebab24c.tar
nixlib-6c6924b2eb54658ededd4e20275c4a5b2ebab24c.tar.gz
nixlib-6c6924b2eb54658ededd4e20275c4a5b2ebab24c.tar.bz2
nixlib-6c6924b2eb54658ededd4e20275c4a5b2ebab24c.tar.lz
nixlib-6c6924b2eb54658ededd4e20275c4a5b2ebab24c.tar.xz
nixlib-6c6924b2eb54658ededd4e20275c4a5b2ebab24c.tar.zst
nixlib-6c6924b2eb54658ededd4e20275c4a5b2ebab24c.zip
lxd: When `lxcfs` is enabled, start `lxd` with explicit `LXD_LXC_TEMPLATE_CONFIG`
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/virtualisation/lxd.nix12
1 files changed, 12 insertions, 0 deletions
diff --git a/nixos/modules/virtualisation/lxd.nix b/nixos/modules/virtualisation/lxd.nix
index f526324e0a02..3958fc2c1d7c 100644
--- a/nixos/modules/virtualisation/lxd.nix
+++ b/nixos/modules/virtualisation/lxd.nix
@@ -24,6 +24,12 @@ in
           containers. Users in the "lxd" group can interact with
           the daemon (e.g. to start or stop containers) using the
           <command>lxc</command> command line tool, among others.
+
+          Most of the time, you'll also want to start lxcfs, so
+          that containers can "see" the limits:
+          <code>
+            virtualisation.lxc.lxcfs.enable = true;
+          </code>
         '';
       };
 
@@ -114,6 +120,12 @@ in
         LimitNOFILE = "1048576";
         LimitNPROC = "infinity";
         TasksMax = "infinity";
+
+        # By default, `lxd` loads configuration files from hard-coded
+        # `/usr/share/lxc/config` - since this is a no-go for us, we have to
+        # explicitly tell it where the actual configuration files are
+        Environment = mkIf (config.virtualisation.lxc.lxcfs.enable)
+          "LXD_LXC_TEMPLATE_CONFIG=${pkgs.lxcfs}/share/lxc/config";
       };
     };