Proxmox LXC systemd-networkd container image

Hello all,

I am working on setting up a NixOS LXC container in Proxmox 8.1. I downloaded both Hydra - Build 247009785 of job nixos:release-23.11:nixos.containerTarball.x86_64-linux and Hydra - Build 247009460 of job nixos:release-23.11:nixos.lxdContainerImage.x86_64-linux to try out.

I kept getting an error:

unable to open file '/etc/systemd/network/eth0.network.tmp.2776' - No such file or directory
unable to create CT 15003 - error in setup task PVE::LXC::Setup::post_create_hook

So I took a look at the PVE source code, and it appears to try to set up networking using systemd-networkd: [PATCH v2 container 1/1] Setup: add NixOS support. When commenting out the line $self->setup_systemd_networkd($conf); in /usr/share/perl5/PVE/LXC/Setup/NixOS.pm the container successfully initiates.

I found out how to do this, because most guides online say to pass --os-type unmanaged which has no networking setup. The downside to this is that I cannot pass this option in the Web GUI, because there is no option to enable to pass this argument.

The rest of the options that are typically recommended for Proxmox containers are able to be passed during (nesting) or after (console) the creation of the container in the Web GUI, but this systemd-networkd error will actually stop the creation of the container, preventing me from intervening manually later.

The workarounds AFAIK are to create the container using pct on the CLI, (which I have been able to do) or to create a container that uses systemd-networkd (which I have not tried yet). However, I would hope that there is a smoother way to use the provided builds to create a container on the Proxmox GUI as it is described on Proxmox Virtual Environment - NixOS Wiki. (Albeit it does suggest to create the image yourself. Like I said, I have not tried this yet, but I don’t have the nix command installed on my desktop to attempt to create a proxmox-lxc image on my own desktop, )

So I’m wondering the following:

  1. Is there a container build (hosted, maybe on hydra?) that has systemd-networkd enabled (does proxmox-lxc do this?) so this setup passes?
  2. Should this Proxmox script be changed so that the Proxmox setup does not try to set up the network via systemd-networkd?

Thanks for your time!

I tested using an older version of the image from 2023-04-23:

root@matrix:~# pct create 130 local:vztmpl/nixos-system-x86_64-linux.tar.xz --hostname test-new --net0 name=eth0,bridge=vmbr0,gw=192.168.1.1,ip=192.168.1.111/24,type=veth --features nesting=1
Formatting '/mnt/pve/nfs/images/130/vm-130-disk-0.raw', fmt=raw size=4294967296 preallocation=off
Creating filesystem with 1048576 4k blocks and 262144 inodes
Filesystem UUID: b249a6b0-b951-40a6-9970-3b0f1f9b40f5
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736
extracting archive '/var/lib/vz/template/cache/nixos-system-x86_64-linux.tar.xz'
Total bytes read: 617082880 (589MiB, 58MiB/s)
Detected container architecture: amd64
root@matrix:~# pct start 130
root@matrix:~# pct enter 130
sh-5.2# /bin/sh -l

[root@test-new:~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0@if21: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether bc:24:11:7b:a6:f0 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.1.111/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::be24:11ff:fe7b:a6f0/64 scope link
       valid_lft forever preferred_lft forever

With the latest image from Hydra, I am running into the same issue as you:

root@matrix:~# pct create 130 local:vztmpl/nixos-system-x86_64-linux-1.tar.xz --hostname test-new --net0 name=eth0,bridge=vmbr0,gw=192.168.1.1,ip=192.168.1.111/24,type=veth --features nesting=1
Formatting '/mnt/pve/nfs/images/130/vm-130-disk-0.raw', fmt=raw size=4294967296 preallocation=off
Creating filesystem with 1048576 4k blocks and 262144 inodes
Filesystem UUID: f66b2541-9f3f-4116-b892-f4247474d7dd
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736
extracting archive '/var/lib/vz/template/cache/nixos-system-x86_64-linux-1.tar.xz'
Total bytes read: 697835520 (666MiB, 55MiB/s)
Detected container architecture: amd64
unable to open file '/etc/systemd/network/eth0.network.tmp.938012' - No such file or directory
unable to create CT 130 - error in setup task PVE::LXC::Setup::post_create_hook

Looking inside the archives, it looks like the directory /etc/systemd doesn’t exist in the new image. Something must have changed in nixpkgs. I’ll look into it.

EDIT:

Looks like you are using the wrong container image. The correct one is
https://hydra.nixos.org/job/nixos/release-23.11/nixos.proxmoxLXC.x86_64-linux

1 Like

That worked! Thanks for pointing me to that image.

Thanks, the image works, but I’m having this problem with the console:

Did you ever get the console to work so many years ago?

No, despite setting it up like above.