1# LXC Configuration
2
3{ config, lib, pkgs, ... }:
4
5with lib;
6
7let
8
9 cfg = config.virtualisation.lxc;
10
11in
12
13{
14 ###### interface
15
16 options.virtualisation.lxc = {
17 enable =
18 mkOption {
19 type = types.bool;
20 default = false;
21 description =
22 ''
23 This enables Linux Containers (LXC), which provides tools
24 for creating and managing system or application containers
25 on Linux.
26 '';
27 };
28
29 systemConfig =
30 mkOption {
31 type = types.lines;
32 default = "";
33 description =
34 ''
35 This is the system-wide LXC config. See
36 <citerefentry><refentrytitle>lxc.system.conf</refentrytitle>
37 <manvolnum>5</manvolnum></citerefentry>.
38 '';
39 };
40
41 defaultConfig =
42 mkOption {
43 type = types.lines;
44 default = "";
45 description =
46 ''
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>.
50 '';
51 };
52
53 usernetConfig =
54 mkOption {
55 type = types.lines;
56 default = "";
57 description =
58 ''
59 This is the config file for managing unprivileged user network
60 administration access in LXC. See <citerefentry>
61 <refentrytitle>lxc-user-net</refentrytitle><manvolnum>5</manvolnum>
62 </citerefentry>.
63 '';
64 };
65
66 };
67
68 ###### implementation
69
70 config = mkIf cfg.enable {
71
72 environment.systemPackages = [ pkgs.lxc ];
73
74 environment.etc."lxc/lxc.conf".text = cfg.systemConfig;
75 environment.etc."lxc/lxc-usernet".text = cfg.usernetConfig;
76 environment.etc."lxc/default.conf".text = cfg.defaultConfig;
77
78 };
79
80}