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";
};
};