at 24.11-pre 1.2 kB view raw
1# LXC Configuration 2 3{ config, lib, pkgs, ... }: 4 5let 6 cfg = config.virtualisation.lxc.lxcfs; 7in { 8 meta = { 9 maintainers = lib.teams.lxc.members; 10 }; 11 12 ###### interface 13 options.virtualisation.lxc.lxcfs = { 14 enable = 15 lib.mkOption { 16 type = lib.types.bool; 17 default = false; 18 description = '' 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 = lib.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}