about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2022-02-25 14:49:48 +0000
committerGitHub <noreply@github.com>2022-02-25 14:49:48 +0000
commita9252603d544324504c7e8c4c83bf6d551756e3f (patch)
treee79facc8d0cc4c407fd59bfc81ca9cf4cdc18071 /nixos
parent0c1592eb53e14a7934c781484d44bdc356c2243b (diff)
parent19f7856b391b77d72c56fa8a2400fd6caf42e9e9 (diff)
downloadnixlib-a9252603d544324504c7e8c4c83bf6d551756e3f.tar
nixlib-a9252603d544324504c7e8c4c83bf6d551756e3f.tar.gz
nixlib-a9252603d544324504c7e8c4c83bf6d551756e3f.tar.bz2
nixlib-a9252603d544324504c7e8c4c83bf6d551756e3f.tar.lz
nixlib-a9252603d544324504c7e8c4c83bf6d551756e3f.tar.xz
nixlib-a9252603d544324504c7e8c4c83bf6d551756e3f.tar.zst
nixlib-a9252603d544324504c7e8c4c83bf6d551756e3f.zip
Merge pull request #160195 from illustris/proxmox-lxc
nixos/proxmox-lxc: init
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/virtualisation/proxmox-lxc.nix64
1 files changed, 64 insertions, 0 deletions
diff --git a/nixos/modules/virtualisation/proxmox-lxc.nix b/nixos/modules/virtualisation/proxmox-lxc.nix
new file mode 100644
index 000000000000..3913b474afbe
--- /dev/null
+++ b/nixos/modules/virtualisation/proxmox-lxc.nix
@@ -0,0 +1,64 @@
+{ config, pkgs, lib, ... }:
+
+with lib;
+
+{
+  options.proxmoxLXC = {
+    privileged = mkOption {
+      type = types.bool;
+      default = false;
+      description = ''
+        Whether to enable privileged mounts
+      '';
+    };
+    manageNetwork = mkOption {
+      type = types.bool;
+      default = false;
+      description = ''
+        Whether to manage network interfaces through nix options
+        When false, systemd-networkd is enabled to accept network
+        configuration from proxmox.
+      '';
+    };
+  };
+
+  config =
+    let
+      cfg = config.proxmoxLXC;
+    in
+    {
+      system.build.tarball = pkgs.callPackage ../../lib/make-system-tarball.nix {
+        storeContents = [{
+          object = config.system.build.toplevel;
+          symlink = "none";
+        }];
+
+        contents = [{
+          source = config.system.build.toplevel + "/init";
+          target = "/sbin/init";
+        }];
+
+        extraCommands = "mkdir -p root etc/systemd/network";
+      };
+
+      boot = {
+        isContainer = true;
+        loader.initScript.enable = true;
+      };
+
+      networking = mkIf (!cfg.manageNetwork) {
+        useDHCP = false;
+        useHostResolvConf = false;
+        useNetworkd = true;
+      };
+
+      services.openssh = {
+        enable = mkDefault true;
+        startWhenNeeded = mkDefault true;
+      };
+
+      systemd.mounts = mkIf (!cfg.privileged)
+        [{ where = "/sys/kernel/debug"; enable = false; }];
+
+    };
+}