New modules for container managment

This commit is contained in:
pazpi 2024-08-16 18:22:21 +02:00
parent 0a48b3d817
commit 93e9d585cb
No known key found for this signature in database
GPG key ID: 0942571C4B9966BE
7 changed files with 121 additions and 2 deletions

View file

@ -3,7 +3,9 @@
./docker.nix
./libvirtd.nix
./lxc.nix
./lxc-guest.nix
./podman.nix
./oci-containers
./proxmox.nix
# ./oci-containers
];
}

View file

@ -10,7 +10,7 @@ in
config = lib.mkIf cfg.enable {
virtualisation = {
docker = {
storageDriver = "btrfs";
storageDriver = "overlay2";
rootless = {
enable = true;
setSocketVariable = true;

View file

@ -0,0 +1,27 @@
{ config, lib, ... }:
let
cfg = config.lxcGuest;
in
{
options.lxcGuest = {
enable = lib.mkEnableOption "NixOs inside LXC container";
};
config = lib.mkIf cfg.enable {
# start tty0 on serial console
systemd.services."getty@tty1" = {
enable = lib.mkForce true;
wantedBy = [ "getty.target" ]; # to start at boot
serviceConfig.Restart = "always"; # restart when session is closed
};
# Supress systemd units that don't work because of LXC.
# https://blog.xirion.net/posts/nixos-proxmox-lxc/#configurationnix-tweak
systemd.suppressedSystemUnits = [
"dev-mqueue.mount"
"sys-kernel-debug.mount"
"sys-fs-fuse-connections.mount"
];
};
}

View file

@ -0,0 +1,48 @@
{ config, lib, pkgs, ... }:
let
cfg = config.proxmox;
in
{
options.proxmox = {
enable = lib.mkEnableOption "If this host is running inside Proxmox";
privileged = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable privileged mounts
'';
};
manageNetwork = lib.mkOption {
type = lib.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.
'';
};
manageHostName = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to manage hostname through nix options
When false, the hostname is picked up from /etc/hostname
populated by proxmox.
'';
};
};
config = lib.mkIf cfg.enable {
proxmoxLXC = {
enable = true;
privileged = cfg.privileged;
manageNetwork = cfg.manageNetwork;
manageHostName = cfg.manageHostName;
};
};
}