2022-02-15 18:14:26 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
options.proxmoxLXC = {
|
|
|
|
privileged = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-29 17:33:50 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-02-15 18:14:26 +00:00
|
|
|
Whether to enable privileged mounts
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
manageNetwork = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-29 17:33:50 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-02-15 18:14:26 +00:00
|
|
|
Whether to manage network interfaces through nix options
|
|
|
|
When false, systemd-networkd is enabled to accept network
|
|
|
|
configuration from proxmox.
|
|
|
|
'';
|
|
|
|
};
|
2022-03-18 10:48:00 +00:00
|
|
|
manageHostName = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-29 17:33:50 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-03-18 10:48:00 +00:00
|
|
|
Whether to manage hostname through nix options
|
|
|
|
When false, the hostname is picked up from /etc/hostname
|
|
|
|
populated by proxmox.
|
|
|
|
'';
|
|
|
|
};
|
2022-02-15 18:14:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
2022-03-18 10:48:00 +00:00
|
|
|
# pick up hostname from /etc/hostname generated by proxmox
|
|
|
|
hostName = mkIf (!cfg.manageHostName) (mkForce "");
|
2022-02-15 18:14:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
services.openssh = {
|
|
|
|
enable = mkDefault true;
|
|
|
|
startWhenNeeded = mkDefault true;
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.mounts = mkIf (!cfg.privileged)
|
|
|
|
[{ where = "/sys/kernel/debug"; enable = false; }];
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|