11 options.proxmoxLXC = {
15 description = "Whether to enable the Proxmox VE LXC module.";
17 privileged = mkOption {
21 Whether to enable privileged mounts
24 manageNetwork = mkOption {
28 Whether to manage network interfaces through nix options
29 When false, systemd-networkd is enabled to accept network
30 configuration from proxmox.
33 manageHostName = mkOption {
37 Whether to manage hostname through nix options
38 When false, the hostname is picked up from /etc/hostname
46 cfg = config.proxmoxLXC;
49 system.build.tarball = pkgs.callPackage ../../lib/make-system-tarball.nix {
52 object = config.system.build.toplevel;
59 source = config.system.build.toplevel + "/init";
60 target = "/sbin/init";
64 extraCommands = "mkdir -p root etc/systemd/network";
67 boot.postBootCommands = ''
68 # After booting, register the contents of the Nix store in the Nix
70 if [ -f /nix-path-registration ]; then
71 ${config.nix.package.out}/bin/nix-store --load-db < /nix-path-registration &&
72 rm /nix-path-registration
75 # nixos-rebuild also requires a "system" profile
76 ${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
81 loader.initScript.enable = true;
84 console.enable = true;
86 networking = mkIf (!cfg.manageNetwork) {
88 useHostResolvConf = false;
90 # pick up hostname from /etc/hostname generated by proxmox
91 hostName = mkIf (!cfg.manageHostName) (mkForce "");
94 # unprivileged LXCs can't set net.ipv4.ping_group_range
95 security.wrappers.ping = mkIf (!cfg.privileged) {
98 capabilities = "cap_net_raw+p";
99 source = "${pkgs.iputils.out}/bin/ping";
103 enable = mkDefault true;
104 startWhenNeeded = mkDefault true;
108 mounts = mkIf (!cfg.privileged) [
111 where = "/sys/kernel/debug";
115 # By default only starts getty on tty0 but first on LXC is tty1
116 services."autovt@".unitConfig.ConditionPathExists = [
121 # These are disabled by `console.enable` but console via tty is the default in Proxmox
122 services."getty@tty1".enable = lib.mkForce true;
123 services."autovt@".enable = lib.mkForce true;