3 { config, lib, pkgs, ... }:
9 cfg = config.virtualisation.lxc;
16 options.virtualisation.lxc = {
23 This enables Linux Containers (LXC), which provides tools
24 for creating and managing system or application containers
35 This is the system-wide LXC config. See
36 <citerefentry><refentrytitle>lxc.system.conf</refentrytitle>
37 <manvolnum>5</manvolnum></citerefentry>.
47 Default config (default.conf) for new containers, i.e. for
48 network config. See <citerefentry><refentrytitle>lxc.container.conf
49 </refentrytitle><manvolnum>5</manvolnum></citerefentry>.
59 This is the config file for managing unprivileged user network
60 administration access in LXC. See <citerefentry>
61 <refentrytitle>lxc-usernet</refentrytitle><manvolnum>5</manvolnum>
69 config = mkIf cfg.enable {
70 environment.systemPackages = [ pkgs.lxc ];
71 environment.etc."lxc/lxc.conf".text = cfg.systemConfig;
72 environment.etc."lxc/lxc-usernet".text = cfg.usernetConfig;
73 environment.etc."lxc/default.conf".text = cfg.defaultConfig;
74 systemd.tmpfiles.rules = [ "d /var/lib/lxc/rootfs 0755 root root -" ];
76 security.apparmor.packages = [ pkgs.lxc ];
77 security.apparmor.policies = {
78 "bin/lxc-start".profile = ''
79 #include ${pkgs.lxc}/etc/apparmor.d/usr.bin.lxc-start
81 "lxc-containers".profile = ''
82 #include ${pkgs.lxc}/etc/apparmor.d/lxc-containers