12 ../image/file-options.nix
15 options.proxmoxLXC = {
19 description = "Whether to enable the Proxmox VE LXC module.";
21 privileged = mkOption {
25 Whether to enable privileged mounts
28 manageNetwork = mkOption {
32 Whether to manage network interfaces through nix options
33 When false, systemd-networkd is enabled to accept network
34 configuration from proxmox.
37 manageHostName = mkOption {
41 Whether to manage hostname through nix options
42 When false, the hostname is picked up from /etc/hostname
50 cfg = config.proxmoxLXC;
57 image.extension = "tar.xz";
58 image.filePath = "tarball/${config.image.fileName}";
59 system.build.image = config.system.build.tarball;
60 system.build.tarball = pkgs.callPackage ../../lib/make-system-tarball.nix {
61 fileName = config.image.baseName;
64 object = config.system.build.toplevel;
71 source = config.system.build.toplevel + "/init";
72 target = "/sbin/init";
76 extraCommands = "mkdir -p root etc/systemd/network";
79 boot.postBootCommands = ''
80 # After booting, register the contents of the Nix store in the Nix
82 if [ -f /nix-path-registration ]; then
83 ${config.nix.package.out}/bin/nix-store --load-db < /nix-path-registration &&
84 rm /nix-path-registration
87 # nixos-rebuild also requires a "system" profile
88 ${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
93 loader.initScript.enable = true;
96 console.enable = true;
98 networking = mkIf (!cfg.manageNetwork) {
100 useHostResolvConf = false;
102 # pick up hostname from /etc/hostname generated by proxmox
103 hostName = mkIf (!cfg.manageHostName) (mkForce "");
106 # unprivileged LXCs can't set net.ipv4.ping_group_range
107 security.wrappers.ping = mkIf (!cfg.privileged) {
110 capabilities = "cap_net_raw+p";
111 source = "${pkgs.iputils.out}/bin/ping";
115 enable = mkDefault true;
116 startWhenNeeded = mkDefault true;
120 mounts = mkIf (!cfg.privileged) [
123 where = "/sys/kernel/debug";
127 # By default only starts getty on tty0 but first on LXC is tty1
128 services."autovt@".unitConfig.ConditionPathExists = [
133 # These are disabled by `console.enable` but console via tty is the default in Proxmox
134 services."getty@tty1".enable = lib.mkForce true;
135 services."autovt@".enable = lib.mkForce true;