]> git.proxmox.com Git - pve-container.git/commitdiff
Setup: add NixOS support
authorHarikrishnan R via pve-devel <pve-devel@lists.proxmox.com>
Tue, 15 Feb 2022 17:28:46 +0000 (22:58 +0530)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 17 Feb 2022 07:05:12 +0000 (08:05 +0100)
Distro detection is done heuristically through the presence of a
`/nix/store` folder.

NixOS typically uses a script-based network configuration system that
isn't easy to configure from the outside, while the configuration
snippets would be simple to generate, bringing them in effect isn't.

LXC templates generated for proxmox are instead expected to use
systemd-networkd.

Signed-off-by: Harikrishnan R <rharikrishnan95@gmail.com>
 [ Thomas: update/reword commit ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/LXC/Config.pm
src/PVE/LXC/Setup.pm
src/PVE/LXC/Setup/Makefile
src/PVE/LXC/Setup/NixOS.pm [new file with mode: 0644]

index 7c503ca056018405e23d0739038f21461605b343..0ed7bd245dd9db32745eb2d6460ffba030807ab9 100644 (file)
@@ -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 => {
index 5cc56af7dc7cecb3cf87253b72732e8edd916bd1..b72a18e0d5ae066040898c44d46c0c681bd3eaa3 100644 (file)
@@ -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/store") {
+       return "nixos";
     } elsif (-f "$rootdir/etc/os-release") {
        die "unable to detect OS distribution\n";
     } else {
index 04ee2e4f394a70573f561dbb41f4918b580298a5..df1cf972774ba0c2ca217e1357d44badfcb4be93 100644 (file)
@@ -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 (file)
index 0000000..905ca8c
--- /dev/null
@@ -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;