--- Begin Message ---
Distro detection is done through the presence of a /nix folder.
NixOS typically uses a script-based network configuration system
that isn't easy to configure from the outside. LXC templates
generated for proxmox are instead expected to use systemd-networkd.
---
src/PVE/LXC/Config.pm | 2 +-
src/PVE/LXC/Setup.pm | 4 ++++
src/PVE/LXC/Setup/Makefile | 1 +
src/PVE/LXC/Setup/NixOS.pm | 44 ++++++++++++++++++++++++++++++++++++++
4 files changed, 50 insertions(+), 1 deletion(-)
create mode 100644 src/PVE/LXC/Setup/NixOS.pm
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index 7c503ca..0ed7bd2 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -469,7 +469,7 @@ my $confdesc = {
ostype => {
optional => 1,
type => 'string',
- enum => [qw(debian devuan ubuntu centos fedora opensuse archlinux
alpine gentoo unmanaged)],
+ enum => [qw(debian devuan ubuntu centos fedora opensuse archlinux
alpine gentoo nixos unmanaged)],
description => "OS type. This is used to setup configuration inside the
container, and corresponds to lxc setup scripts in
/usr/share/lxc/config/<ostype>.common.conf. Value 'unmanaged' can be used to
skip and OS specific setup.",
},
console => {
diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
index 5cc56af..709f1ea 100644
--- a/src/PVE/LXC/Setup.pm
+++ b/src/PVE/LXC/Setup.pm
@@ -17,6 +17,7 @@ use PVE::LXC::Setup::Fedora;
use PVE::LXC::Setup::Gentoo;
use PVE::LXC::Setup::SUSE;
use PVE::LXC::Setup::Ubuntu;
+use PVE::LXC::Setup::NixOS;
use PVE::LXC::Setup::Unmanaged;
my $plugins = {
@@ -29,6 +30,7 @@ my $plugins = {
gentoo => 'PVE::LXC::Setup::Gentoo',
opensuse => 'PVE::LXC::Setup::SUSE',
ubuntu => 'PVE::LXC::Setup::Ubuntu',
+ nixos => 'PVE::LXC::Setup::NixOS',
unmanaged => 'PVE::LXC::Setup::Unmanaged',
};
@@ -75,6 +77,8 @@ my $autodetect_type = sub {
return "alpine";
} elsif (-f "$rootdir/etc/gentoo-release") {
return "gentoo";
+ } elsif (-d "$rootdir/nix") {
+ return "nixos";
} elsif (-f "$rootdir/etc/os-release") {
die "unable to detect OS distribution\n";
} else {
diff --git a/src/PVE/LXC/Setup/Makefile b/src/PVE/LXC/Setup/Makefile
index 04ee2e4..df1cf97 100644
--- a/src/PVE/LXC/Setup/Makefile
+++ b/src/PVE/LXC/Setup/Makefile
@@ -10,6 +10,7 @@ SOURCES=\
Gentoo.pm \
SUSE.pm \
Ubuntu.pm \
+ NixOS.pm \
Unmanaged.pm \
.PHONY: install
diff --git a/src/PVE/LXC/Setup/NixOS.pm b/src/PVE/LXC/Setup/NixOS.pm
new file mode 100644
index 0000000..905ca8c
--- /dev/null
+++ b/src/PVE/LXC/Setup/NixOS.pm
@@ -0,0 +1,44 @@
+package PVE::LXC::Setup::NixOS;
+
+use strict;
+use warnings;
+
+use File::Path 'make_path';
+
+use PVE::LXC::Setup::Base;
+
+use base qw(PVE::LXC::Setup::Base);
+
+sub new {
+ my ($class, $conf, $rootdir) = @_;
+
+ my $self = { conf => $conf, rootdir => $rootdir, version => 0 };
+
+ $conf->{ostype} = "nixos";
+
+ return bless $self, $class;
+}
+
+sub template_fixup {
+ my ($self, $conf) = @_;
+}
+
+sub setup_network {
+ my ($self, $conf) = @_;
+
+ $self->setup_systemd_networkd($conf);
+}
+
+sub set_hostname {
+ my ($self, $conf) = @_;
+}
+
+sub set_timezone {
+ my ($self, $conf) = @_;
+}
+
+sub setup_init {
+ my ($self, $conf) = @_;
+}
+
+1;
--
2.35.1
--- End Message ---
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel