1# LXC Configuration
2
3{ config, lib, pkgs, ... }:
4
5with lib;
6
7let
8 cfg = config.virtualisation.lxc.lxcfs;
9in {
10 meta.maintainers = [ maintainers.mic92 ];
11
12 ###### interface
13 options.virtualisation.lxc.lxcfs = {
14 enable =
15 mkOption {
16 type = types.bool;
17 default = false;
18 description = lib.mdDoc ''
19 This enables LXCFS, a FUSE filesystem for LXC.
20 To use lxcfs in include the following configuration in your
21 container configuration:
22 ```
23 virtualisation.lxc.defaultConfig = "lxc.include = ''${pkgs.lxcfs}/share/lxc/config/common.conf.d/00-lxcfs.conf";
24 ```
25 '';
26 };
27 };
28
29 ###### implementation
30 config = mkIf cfg.enable {
31 systemd.services.lxcfs = {
32 description = "FUSE filesystem for LXC";
33 wantedBy = [ "multi-user.target" ];
34 before = [ "lxc.service" ];
35 restartIfChanged = false;
36 serviceConfig = {
37 ExecStartPre="${pkgs.coreutils}/bin/mkdir -p /var/lib/lxcfs";
38 ExecStart="${pkgs.lxcfs}/bin/lxcfs /var/lib/lxcfs";
39 ExecStopPost="-${pkgs.fuse}/bin/fusermount -u /var/lib/lxcfs";
40 KillMode="process";
41 Restart="on-failure";
42 };
43 };
44 };
45}