From 6c6924b2eb54658ededd4e20275c4a5b2ebab24c Mon Sep 17 00:00:00 2001 From: Patryk Wychowaniec Date: Fri, 5 Jun 2020 14:40:02 +0200 Subject: [PATCH] lxd: When `lxcfs` is enabled, start `lxd` with explicit `LXD_LXC_TEMPLATE_CONFIG` --- nixos/modules/virtualisation/lxd.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nixos/modules/virtualisation/lxd.nix b/nixos/modules/virtualisation/lxd.nix index f526324e0a0..3958fc2c1d7 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 lxc command line tool, among others. + + Most of the time, you'll also want to start lxcfs, so + that containers can "see" the limits: + + virtualisation.lxc.lxcfs.enable = true; + ''; }; @@ -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"; }; };