at 17.09-beta 1.3 kB view raw
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 = '' 19 This enables LXCFS, a FUSE filesystem for LXC. 20 To use lxcfs in include the following configuration in your 21 container configuration: 22 <code> 23 virtualisation.lxc.defaultConfig = "lxc.include = ''${pkgs.lxcfs}/share/lxc/config/common.conf.d/00-lxcfs.conf"; 24 </code> 25 ''; 26 }; 27 }; 28 29 ###### implementation 30 config = mkIf cfg.enable { 31 services.cgmanager.enable = true; 32 33 systemd.services.lxcfs = { 34 description = "FUSE filesystem for LXC"; 35 wantedBy = [ "multi-user.target" ]; 36 requires = [ "cgmanager.service" ]; 37 after = [ "cgmanager.service" ]; 38 before = [ "lxc.service" ]; 39 restartIfChanged = false; 40 serviceConfig = { 41 ExecStartPre="${pkgs.coreutils}/bin/mkdir -p /var/lib/lxcfs"; 42 ExecStart="${pkgs.lxcfs}/bin/lxcfs /var/lib/lxcfs"; 43 ExecStopPost="-${pkgs.fuse}/bin/fusermount -u /var/lib/lxcfs"; 44 KillMode="process"; 45 Restart="on-failure"; 46 }; 47 }; 48 }; 49}