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