Happened
When trying to install a NixOS flake setup in a QEMU/KVM virtual machine, I get
mktemp: failed to create file via template ‘/run/user/0/tmp.XXXXXXXXXX’: No such file or directory
Traceback (most recent call last):
File "/nix/store/yb390224d24pp41qya0s9w20jkfcrwp8-systemd-boot", line 305, in <module>
main()
File "/nix/store/yb390224d24pp41qya0s9w20jkfcrwp8-systemd-boot", line 293, in main
subprocess.check_call("/nix/store/iqa5zghnjhxasfl1w3xigk6mbi0qlfbd-copy-extra-files")
File "/nix/store/dn4fwp0yx6nsa85cr20cwvdmg64xwmcy-python3-3.9.9/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '/nix/store/iqa5zghnjhxasfl1w3xigk6mbi0qlfbd-copy-extra-files' returned non-zero exit status 1.
Even though I’m able too boot in this installation afterwards, this terminates the installation in seemingly a bad state and I can’t login in the root user since I wasn’t asked to change its password.
Reproduce
-
Get NixOS 21.11 minimal ISO image at https://nixos.org/download.html
-
Use iso image to create new QEMU/KVM virtual machine on virt-manager, and configure to use UEFI instead of BIOS
-
Boot virtual machine
-
Partition
sudo parted /dev/vda mklabel gpt sudo parted /dev/vda mkpart ESP fat32 0% 200MiB sudo parted /dev/vda mkpart CRY 200MiB 100% sudo parted /dev/vda set 1 esp on
-
Encrypt vda2 and open it
sudo cryptsetup --verbose --type luks2 --hash sha512 --cipher aes-xts-plain64 --key-size 512 luksFormat /dev/vda2 sudo cryptsetup luksOpen --type luks2 /dev/vda2 cry
-
Create LVM
sudo pvcreate /dev/mapper/cry sudo vgcreate vg /dev/mapper/cry sudo lvcreate -L 30G vg -n root
-
Format partitions
sudo mkfs.vfat -F 32 -n esp /dev/vda1 sudo mkfs.xfs -L root /dev/vg/root
-
Mount
sudo mount /dev/vg/root /mnt sudo mkdir /mnt/efi /etc/nixos sudo mount /dev/vda1 /mnt/efi
-
Clone and install
nix-shell -p git nixFlakes sudo git clone https://github.com/yuuyins/cnix.git /mnt/etc/nixos
-
Change UUIDs in
/mnt/etc/nixos/cnix/host/hardware-configuration.nix
to match accordinglyblkid
output -
Install
sudo nixos-install --impure --root /mnt --flake /mnt/etc/nixos#cnix
Log
nixos-install --impure --root /mnt --flake /mnt/etc/nixos#cnix
warning: creating lock file '/mnt/etc/nixos/flake.lock'
warning: Git tree '/mnt/etc/nixos' is dirty
building the flake in git+file:///mnt/etc/nixos...
warning: Git tree '/mnt/etc/nixos' is dirty
copying channel...
installing the boot loader...
warning: user ‘cnix’ has unknown group ‘cnix’
setting up /etc...
Warning: something's wrong at /nix/store/cz6na7w751iv7z78fb9ms8hhvnsd0l8z-setup-etc.pl line 120.
/etc/tmpfiles.d/journal-nocow.conf:26: Failed to resolve specifier: uninitialized /etc detected, skipping
All rules containing unresolvable specifiers will be skipped.
Initializing machine ID from VM UUID.
Created "/efi/EFI".
Created "/efi/EFI/systemd".
Created "/efi/EFI/BOOT".
Created "/efi/loader".
Created "/efi/loader/entries".
Created "/efi/EFI/Linux".
Copied "/nix/store/cfhpzlarbhfw3scj91dcz5ai04ayfzik-systemd-249.7/lib/systemd/boot/efi/systemd-bootx64.efi" to "/efi/EFI/systemd/systemd-bootx64.efi".
Copied "/nix/store/cfhpzlarbhfw3scj91dcz5ai04ayfzik-systemd-249.7/lib/systemd/boot/efi/systemd-bootx64.efi" to "/efi/EFI/BOOT/BOOTX64.EFI".
Created "/efi/d2fee85a986d49c29a422c3dd1435341".
Random seed file /efi/loader/random-seed successfully written (512 bytes).
Not installing system token, since we are running in a virtualized environment.
Created EFI boot entry "Linux Boot Manager".
mktemp: failed to create file via template ‘/run/user/0/tmp.XXXXXXXXXX’: No such file or directory
Traceback (most recent call last):
File "/nix/store/yb390224d24pp41qya0s9w20jkfcrwp8-systemd-boot", line 305, in <module>
main()
File "/nix/store/yb390224d24pp41qya0s9w20jkfcrwp8-systemd-boot", line 293, in main
subprocess.check_call("/nix/store/iqa5zghnjhxasfl1w3xigk6mbi0qlfbd-copy-extra-files")
File "/nix/store/dn4fwp0yx6nsa85cr20cwvdmg64xwmcy-python3-3.9.9/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '/nix/store/iqa5zghnjhxasfl1w3xigk6mbi0qlfbd-copy-extra-files' returned non-zero exit status 1.