elitak / nixos-infect

[GPLv3+] install nixos over the existing OS in a DigitalOcean droplet (and others with minor modifications)
GNU General Public License v3.0
1.38k stars 224 forks source link

NixOS 24.11 switch-to-configuration broke nixos-infect #225

Open erdnaxe opened 1 day ago

erdnaxe commented 1 day ago

When running nixos-infect on a brand new Contabo VPS running Ubuntu 22.04, I get the following crash:

[...]
deleting unused links...
note: currently hard linking saves -0.00 MiB
174 store paths deleted, 377.98 MiB freed
+ [[ -L /etc/resolv.conf ]]
+ mv -v /etc/resolv.conf /etc/resolv.conf.lnk
renamed '/etc/resolv.conf' -> '/etc/resolv.conf.lnk'
+ cat /etc/resolv.conf.lnk
+ '[' -n '' ']'
+ touch /etc/NIXOS
+ echo etc/nixos
+ echo etc/resolv.conf
+ echo root/.nix-defexpr/channels
+ cd /
+ ls etc/ssh/ssh_host_dsa_key etc/ssh/ssh_host_dsa_key.pub etc/ssh/ssh_host_ecdsa_key etc/ssh/ssh_host_ecdsa_key.pub etc/ssh/ssh_host_ed25519_key etc/ssh/ssh_host_ed25519_key.pub etc/ssh/ssh_host_rsa_key etc/ssh/ssh_host_rsa_key.pub
+ rm -rf /boot.bak
+ isEFI
+ '[' -d /sys/firmware/efi ']'
+ mv -v /boot /boot.bak
mv: cannot move '/boot' to '/boot.bak': Device or resource busy
+ cp -a /boot /boot.bak
+ rm -rf /boot/config-5.15.0-25-generic /boot/config-5.4.0-105-generic /boot/grub /boot/initrd.img /boot/initrd.img-5.15.0-25-generic /boot/initrd.img-5.4.0-105-generic /boot/initrd.img.old /boot/lost+found /boot/System.map-5.15.0-25-generic /boot/System.map-5.4.0-105-generic /boot/vmlinuz /boot/vmlinuz-5.15.0-25-generic /boot/vmlinuz-5.4.0-105-generic /boot/vmlinuz.old
+ umount /boot
+ isEFI
+ '[' -d /sys/firmware/efi ']'
+ /nix/var/nix/profiles/system/bin/switch-to-configuration boot
Error: /run/current-system/sw/bin is missing

Caused by:
    No such file or directory (os error 2)

It seems that NixOS new switch-to-configuration Rust tool expects /run/current-system/sw/bin to exist.

erdnaxe commented 1 day ago

A dirty fix to circumvent this issue is to run ln -s /nix/var/nix/profiles/system /run/current-system then /nix/var/nix/profiles/system/bin/switch-to-configuration boot.