Nixos-install and nixos-enter: chroot: failed to run command ‘/nix/var/nix/profiles/system/activate’: No such file or directory

I’m trying to install an aarch64-linux system (rpi 4), mounted at /mnt/tmp2, from an x86_64 NixOS host. I have configured boot.binfmt.emulatedSystems = ["aarch64-linux"]; and can successfully build and run nixpkgs#legacyPackages.aarch64-linux.hello.

Whenever I try to nixos-install or subsequently nixos-enter this system, I get an error about /nix/var/nix/profiles/system/activate not existing:

# nixos-install --root /mnt/tmp2 --flake /mnt/tmp2/home/n8henrie/git/nixos#homeslice --show-trace -vvv
building the flake in git+file:///mnt/tmp2/home/n8henrie/git/nixos...
evaluating derivation 'git+file:///mnt/tmp2/home/n8henrie/git/nixos#nixosConfigurations."homeslice".config.system.build.toplevel'...
evaluating file '/mnt/tmp2/nix/store/27cfxv8m4n5nn2f2l31s9hg36mkx6xi9-source/flake.nix'
querying info about missing paths...
starting pool of 24 threads
substitution of '/nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e': created
substitution of '/nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e': woken up
querying info about missing paths...
starting pool of 24 threads
entered goal loop
substitution of '/nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e': init
acquiring write lock on '/mnt/tmp2/nix/var/nix/temproots/598998'
substitution of '/nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e': done
substitution of '/nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e': goal destroyed
switching to new user environment
installing the boot loader...
chroot: failed to run command ‘/nix/var/nix/profiles/system/activate’: No such file or directory
chroot: failed to run command ‘/nix/var/nix/profiles/system/sw/bin/bash’: No such file or directory

Not sure if there is something wrong with the symlinks?

# ls -l /mnt/tmp2/nix/var/nix/profiles/system/activate
ls: cannot access '/mnt/tmp2/nix/var/nix/profiles/system/activate': No such file or directory
# ls -l /mnt/tmp2/nix/var/nix/profiles/system/activate
ls: cannot access '/mnt/tmp2/nix/var/nix/profiles/system/activate': No such file or directory
#
# # the `system` link seems broken?
# stat /mnt/tmp2$(readlink -f /mnt/tmp2/nix/var/nix/profiles/system)/activate
  File: /mnt/tmp2/nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e/activate
  Size: 28654           Blocks: 18         IO Block: 28672  regular file
Device: 0,70    Inode: 904760      Links: 2
Access: (0555/-r-xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2023-08-22 15:24:50.932883329 -0600
Modify: 1969-12-31 17:00:01.000000000 -0700
Change: 2023-08-22 15:24:50.806876264 -0600
 Birth: 2023-08-22 15:24:50.798875815 -0600

Installing without the bootloader still produced those errors but looked a little more promising:

# nixos-install --root /mnt/tmp2 --flake /mnt/tmp2/home/n8henrie/git/nixos#homeslice --no-bootloader
warning: Git tree '/mnt/tmp2/home/n8henrie/git/nixos' is dirty
building the flake in git+file:///mnt/tmp2/home/n8henrie/git/nixos...
warning: Git tree '/mnt/tmp2/home/n8henrie/git/nixos' is dirty
chroot: failed to run command ‘/nix/var/nix/profiles/system/activate’: No such file or directory
chroot: failed to run command ‘/nix/var/nix/profiles/system/sw/bin/bash’: No such file or directory
installation finished!

I thought perhaps I could nixos-enter since the installation seemed to have gotten pretty far:

# nixos-enter --root /mnt/tmp2
chroot: failed to run command ‘/nix/var/nix/profiles/system/activate’: No such file or directory
chroot: failed to run command ‘/nix/var/nix/profiles/system/sw/bin/bash’: No such file or directory

Then I thought maybe I could manually follow the symlinks and specify the full path to system:

# nixos-enter --root /mnt/tmp2 --system /mnt/tmp2//nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e
chroot: failed to run command '/mnt/tmp2//nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e/activate': No such file or directory
chroot: failed to run command ‘/nix/var/nix/profiles/system/sw/bin/bash’: No such file or directory
# 
# ls -l /mnt/tmp2//nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e/activate
-r-xr-xr-x 2 root root 28654 Dec 31  1969 /mnt/tmp2//nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e/activate
#
# # or maybe without the `/mnt/tmp2` prefix?
# nixos-enter --root /mnt/tmp2 --system /nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e
chroot: failed to run command '/nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e/activate': No such file or directory
chroot: failed to run command ‘/nix/var/nix/profiles/system/sw/bin/bash’: No such file or directory
# ls -ld /mnt/tmp2/nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e
dr-xr-xr-x 4 root root 23 Dec 31  1969 /mnt/tmp2/nix/store/aa0cyxj9719kd044x7wn1k5pqmaf6hls-nixos-system-homeslice-23.05.20230820.52e3c9e

I am going nuts here.

The device passes a smartctl test and zfs scrub is normal.

It’s mounted at /mnt/tmp2 because I read an old / resolved issue where people were required to manually create /mnt/tmp (my original mountpoint), so I thought perhaps it was problematic to use that mountpoint.

I’ve tried using --max-jobs 0 with an Arch Linux substituter that regularly does my aarch64-linux builds, no luck.

I tried a rm -rf /mnt/tmp2/nix/* to force it to rebuild everything, resulted in the same error.

Tried from a nix shell nixpkgs/master#nixos-install-tools (since I’m pinned to release-23.05), same error.

Any ideas? This one has me stumped.

The host:

$ nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.3.13, NixOS, 23.05 (Stoat), 23.05.20230822.26260b1`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.5`
 - channels(root): `""`
 - nixpkgs: `/nix/store/mnrrmipim9qabwy89c1pbx28nrcxrf6y-source`

Prior to running with --max-jobs 0, I was getting a lot of failed with exit code 255 errors:

# nixos-install --root /mnt/tmp2 --flake /mnt/tmp2/home/n8henrie/git/nixos#homeslice --show-trace -vvv
building the flake in git+file:///mnt/tmp2/home/n8henrie/git/nixos...
evaluating derivation 'git+file:///mnt/tmp2/home/n8henrie/git/nixos#nixosConfigurations."homeslice".config.system.build.toplevel'...
evaluating file '/mnt/tmp2/nix/store/92y3h2y4zlnav0j080591mbqm7vy4lcc-source/flake.nix'
these 2 derivations will be built:
  /nix/store/45wcak7jhq02271sb204vx06m10qg2kv-etc.drv
  /nix/store/cjlh4zwgyyycfh23hgz2j94c6a6ccikp-nixos-system-homeslice-23.05.20230820.52e3c9e.drv
setting up chroot environment in '/mnt/tmp2/nix/store/45wcak7jhq02271sb204vx06m10qg2kv-etc.drv.chroot'
executing builder '/nix/store/nyw3r7n9rr79jvqhdjcvccfqy7rw0lws-bash-5.2-p15/bin/bash'
using builder args '-e /nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh'
building '/nix/store/45wcak7jhq02271sb204vx06m10qg2kv-etc.drv'...
error: builder for '/nix/store/45wcak7jhq02271sb204vx06m10qg2kv-etc.drv' failed with exit code 255
error: 1 dependencies of derivation '/nix/store/cjlh4zwgyyycfh23hgz2j94c6a6ccikp-nixos-system-homeslice-23.05.20230820.52e3c9e.drv' failed to build

These went away when I ran with --max-jobs 0, so perhaps my binfmt setup isn’t working, even though the aarch64-linux hello builds and runs?

Thought maybe this would work, but same error:

# nix build .#nixosConfigurations.homeslice.config.system.build.toplevel
warning: Git tree '/mnt/tmp2/home/n8henrie/git/nixos' is dirty
# echo $?
0
# nixos-install --root /mnt/tmp2 --system ./result
installing the boot loader...
chroot: failed to run command ‘/nix/var/nix/profiles/system/activate’: No such file or directory
chroot: failed to run command ‘/nix/var/nix/profiles/system/sw/bin/bash’: No such file or directory

With set -x added to nixos-enter:

$ sudo ./nixos-enter --root /mnt/tmp2
+ '[' -z '' ']'
+ export NIXOS_ENTER_REEXEC=1
+ NIXOS_ENTER_REEXEC=1
++ id -u
+ '[' 0 '!=' 0 ']'
+ exec unshare --fork --mount --uts --mount-proc --pid -- ./nixos-enter --root /mnt/tmp2
+ '[' -z 1 ']'
+ mount --make-rprivate /
+ mountPoint=/mnt
+ system=/nix/var/nix/profiles/system
+ command=("$system/sw/bin/bash" "--login")
+ silent=0
+ '[' 2 -gt 0 ']'
+ i=--root
+ shift 1
+ case "$i" in
+ mountPoint=/mnt/tmp2
+ shift 1
+ '[' 0 -gt 0 ']'
+ [[ ! -e /mnt/tmp2/etc/NIXOS ]]
+ mkdir -p /mnt/tmp2/dev /mnt/tmp2/sys
+ chmod 0755 /mnt/tmp2/dev /mnt/tmp2/sys
+ mount --rbind /dev /mnt/tmp2/dev
+ mount --rbind /sys /mnt/tmp2/sys
+ chroot_add_resolv_conf /mnt/tmp2
+ local chrootDir=/mnt/tmp2 resolvConf=/mnt/tmp2/etc/resolv.conf
+ [[ -e /etc/resolv.conf ]]
+ [[ -L /mnt/tmp2/etc/resolv.conf ]]
+ [[ ! -f /mnt/tmp2/etc/resolv.conf ]]
+ mount --bind /etc/resolv.conf /mnt/tmp2/etc/resolv.conf
+ '[' 0 -eq 1 ']'
+ LOCALE_ARCHIVE=/nix/var/nix/profiles/system/sw/lib/locale/locale-archive
+ IN_NIXOS_ENTER=1
+ chroot /mnt/tmp2 /nix/var/nix/profiles/system/activate
chroot: failed to run command ‘/nix/var/nix/profiles/system/activate’: No such file or directory
+ true
+ chroot /mnt/tmp2 /nix/var/nix/profiles/system/sw/bin/systemd-tmpfiles --create --remove -E
+ true
+ unset TMPDIR
+ exec chroot /mnt/tmp2 /nix/var/nix/profiles/system/sw/bin/bash --login
chroot: failed to run command ‘/nix/var/nix/profiles/system/sw/bin/bash’: No such file or directory

I wonder if this is related to duplicate zpool names – both are nixos systems in which I use the openzfs guide’s default pool names of rpool and bpool, so I’ve had to temporarily import the Pi’s pool under a different name, something like: sudo zpool import -t rpool rpool2. Perhaps this is confusing things?

That seems like a potential cause, though I don’t know enough about ZFS to judge that. If that seems plausible, you could try wiping and re-formatting the storage with ext4 and installing on that.

Not sure how you’d get that idea, the stat call looks good.

That looks very much correct. It seems the system was fully built. Can you cat the contents of that script?

Can you run chroot /mnt/tmp2 /nix/var/nix/profiles/system/sw/bin/bash --login manually? What about just executing /mnt/tmp2/nix/var/nix/profiles/system/sw/bin/bash?

Thanks for your time and response.

Just inexperience. That was my initial thought when ls -l reported broken symlinks, but I think I was just failing to take the /mnt/tmp2 prefix into account (so obviously the symlinks don’t resolve from the host system).

Yes, they seem correct

No to both, /nix/var/nix/profiles/system/sw/bin/bash complains about not existing, see the last bit of output above:

I’m just experimenting with it myself.

I tried leaving the pool names as rpool and bpool in my hardware.nix (where my fileSystems are defined) as well as with the temporary pool names rpool2 and bpool2, same error either way. But still seems possible.

Could you please post the exact error message you get when executing /mnt/tmp2/nix/var/nix/profiles/system/sw/bin/bash? Just to clear up confusion. This should not be able to return the same error message as chroot.

When you’re calling chroot directly, you need to add sudo in the beginning as well.

Chroot can also print some very confusing error messages when in fact a shared library is missing, that might be what’s happening here.

Maybe more precisely, you could try running

sudo chroot /mnt/tmp2 ldd /nix/var/nix/profiles/system/sw/bin/bash

Moved mountpoint back to /mnt/tmp, temp pool name is still rpool2 / bpool2.

# /mnt/tmp/nix/var/nix/profiles/system/sw/bin/bash
bash: /mnt/tmp/nix/var/nix/profiles/system/sw/bin/bash: No such file or directory
$ sudo chroot /mnt/tmp ldd /nix/var/nix/profiles/system/sw/bin/bash
chroot: failed to run command ‘ldd’: No such file or directory

Even when running as root? (I’m trying to ensure that my prompt properly reflects root vs non-root in my codeblocks.)

Manually resolving the symlinks, it seems to execute fine:

$ file /mnt/tmp$(readlink -f /mnt/tmp$(readlink -f /mnt/tmp$(readlink -f /mnt/tmp/nix/var/nix/profiles/system)/sw)/bin/bash)
/mnt/tmp/nix/store/9ks1k9wxxhxbfsrf2i1kcc6blgxy0nf2-bash-interactive-5.2-p15/bin/bash: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/ld-linux-aarch64.so.1, BuildID[sha1]=2749e1ee694a80dfe9e81e7c60f5722b2c6bece1, for GNU/Linux 3.10.0, not stripped
$ /mnt/tmp$(readlink -f /mnt/tmp$(readlink -f /mnt/tmp$(readlink -f /mnt/tmp/nix/var/nix/profiles/system)/sw)/bin/bash) -c 'echo foo'
foo

But doesn’t seem to work manually with chroot:

$ sudo chroot /mnt/tmp $(readlink -f /mnt/tmp$(readlink -f /mnt/tmp$(readlink -f /mnt/tmp/nix/var/nix/profiles/system)/sw)/bin/bash)
chroot: failed to run command ‘/nix/store/9ks1k9wxxhxbfsrf2i1kcc6blgxy0nf2-bash-interactive-5.2-p15/bin/bash’: No such file or directory
$ ls -l /mnt/tmp/nix/store/9ks1k9wxxhxbfsrf2i1kcc6blgxy0nf2-bash-interactive-5.2-p15/bin/bash
-r-xr-xr-x 2 root root 1192968 Dec 31  1969 /mnt/tmp/nix/store/9ks1k9wxxhxbfsrf2i1kcc6blgxy0nf2-bash-interactive-5.2-p15/bin/bash
$ sudo nixos-enter --root /mnt/tmp --command $(readlink -f /mnt/tmp$(readlink -f /mnt/tmp$(readlink -f /mnt/tmp/nix/var/nix/profiles/system)/sw)/bin/bash)
chroot: failed to run command ‘/nix/var/nix/profiles/system/activate’: No such file or directory
chroot: failed to run command ‘/nix/var/nix/profiles/system/sw/bin/bash’: No such file or directory

I was able to manually run the ldd command, unsure if this is helpful:

# file /mnt/tmp$(realpath /mnt/tmp/nix/var/nix/profiles/system/sw/bin/bash)
/mnt/tmp/nix/store/9ks1k9wxxhxbfsrf2i1kcc6blgxy0nf2-bash-interactive-5.2-p15/bin/bash: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/ld-linux-aarch64.so.1, BuildID[sha1]=2749e1ee694a80dfe9e81e7c60f5722b2c6bece1, for GNU/Linux 3.10.0, not stripped
#
# nix shell nixpkgs#legacyPackages.aarch64-linux.glibc -c ldd /mnt/tmp$(realpath /mnt/tmp/nix/var/nix/profiles/system/sw/bin/bash)
        libreadline.so.8 => /nix/store/scapnd82svnambl958r7bs8qjzm7hza0-readline-8.2p1/lib/libreadline.so.8 (0x0000005502850000)
        libhistory.so.8 => /nix/store/scapnd82svnambl958r7bs8qjzm7hza0-readline-8.2p1/lib/libhistory.so.8 (0x00000055028c0000)
        libncursesw.so.6 => /nix/store/fi7c3yk3wc36hbd9g68mxr7fx3brgvwh-ncurses-6.4/lib/libncursesw.so.6 (0x00000055028f0000)
        libdl.so.2 => /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/libdl.so.2 (0x0000005502980000)
        libc.so.6 => /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/libc.so.6 (0x00000055029b0000)
        /nix/store/0ckxcm0bnsh64a4vi40d5wjs96i014nl-glibc-2.37-8/lib/ld-linux-aarch64.so.1 (0x0000005500000000)

I’m also seeing a bunch of weird build errors with nixos-install but the system (and the specific dependencies) build without issue with nix build. I haven’t seen this before, so I have to think it’s related.

nix store verify --all is clean.

# nixos-install --root /mnt/tmp --option builders ''
...
error: builder for '/nix/store/d5s9nbdbif5ysa8m5j116cr95sj5nl5i-builder.pl.drv' failed with exit code 255
error: builder for '/nix/store/gachck9zzw3771sb5hvi86mw9wacb95q-ensure-all-wrappers-paths-exist.drv' failed with exit code 255
error: builder for '/nix/store/rn8whcdim9bib1v9dw5m9n6m7w28i8f4-etc-60-nixos.conf.drv' failed with exit code 255
error: builder for '/nix/store/aszrrrb714zkg7n48az4j1d11nrk66hl-etc-bashrc.drv' failed with exit code 255
error: builder for '/nix/store/2wcv6881dvnngxnvs015lfygq10ykdbv-etc-environment.drv' failed with exit code 255
error: builder for '/nix/store/api6s2nxzxhx3pnbnfxw0rxn6qwyg7xf-etc-fstab.drv' failed with exit code 255
error: builder for '/nix/store/b057245c6dk5906vj05xbj4v42ypvgg0-etc-hostname.drv' failed with exit code 255
error: builder for '/nix/store/r842z7nl38j18bcylp8jg7rvp6s2sfbr-etc-os-release.drv' failed with exit code 255
error: builder for '/nix/store/g6hvw2ck70jgfdjlxn884w4b7yrrvfbb-etc-registry.json.drv' failed with exit code 255
error: builder for '/nix/store/wmfw52xqbmnz1x97i30xh3in62wmzhvf-etc-shells.drv' failed with exit code 255
error: builder for '/nix/store/klyxyl20x0ss5sn85ggglsz90xx7gh3l-etc-ssh_config.drv' failed with exit code 255
error: builder for '/nix/store/dnd68ipygafwqi0981bmjx4bzdmmdg53-issue.drv' failed with exit code 255
error: builder for '/nix/store/8fqi9a77ymkws3dphg29rvgfnpfs9wfq-nix.conf.drv' failed with exit code 255
error: 1 dependencies of derivation '/nix/store/nj7kdxdzgixvml2f2f6q6b6r416zs6gw-nixos-system-nixos-23.05pre-git.drv' failed to build

I don’t see any way to nix log this?

# nix log /nix/store/d5s9nbdbif5ysa8m5j116cr95sj5nl5i-builder.pl.drv
# 
# nix log /nix/store/d5s9nbdbif5ysa8m5j116cr95sj5nl5i-builder.pl
error: build log of '/nix/store/d5s9nbdbif5ysa8m5j116cr95sj5nl5i-builder.pl' is not available
#
# # seems to build fine directly:
# nix build /nix/store/d5s9nbdbif5ysa8m5j116cr95sj5nl5i-builder.pl.drv
# echo $?
0
# ls -l ./result
lrwxrwxrwx 1 root root 54 Aug 23 17:03 ./result -> /nix/store/wvc0lk45ndj7d76hfrbv35ifzk19y7v7-builder.pl

EDIT: As noted, the same system builds fine with nix build /path/to/#nixosConfigurations.homeslice.config.system.build.toplevel. Can’t figure out why I’m getting those errors with nixos-install, but it must be related, right?

Looks like it may be an issue with the binfmt / emulation after all. If I change nixpkgs.hostPlatform from aarch64-linux to x86_64-linux and remove a few RPi-specific kernel modules, with no other changes, both nixos-install and nixos-enter succeed uneventfully. Revert those changes and the errors return.

Oddly, nixos-install (and then nixos-enter work) on my archlinux machine:

$ cat /etc/os-release
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo
$ nix run nixpkgs#nix-info -- -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.46-1-lts, Arch Linux, noversion, rolling`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.17.0`
 - channels(root): `""`
 - channels(n8henrie): `"nixpkgs-22.11"`
 - nixpkgs: `/home/n8henrie/.nix-defexpr/channels/nixpkgs`

I still get an error when trying to install the bootloader, but certainly seems to be getting a long further than NixOS was. For example, from within nixos-enter:

# nixos-rebuild --install-bootloader switch --flake .#homeslice                                                                                                                                      
building the system configuration...
evaluating derivation 'git+file:///home/n8henrie/git/nixos#nixosConfigurations."homeslice".config.system.build.toplevee
updating GRUB 2 menu...
installing the GRUB 2 boot loader into /boot/efi...
Installing for arm64-efi platform.
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
/nix/store/cxvc722xy5cilkq2qpdws5n3z2a1vcgs-install-grub.pl: installation of GRUB EFI into /boot/efi failed: Inappropriate ioctl for device
warning: error(s) occurred while switching to the new configuration

(also not sure what the toplevee typo is about?)

Any idea why x86_64 ArchLinux (+ nix + aarch64 via binfmt) would do a much better job nixos-install-ing a configuration than x86_64 NixOS + aarch64 via binfmt ? At least on ArchLinux I can nixos-enter the resulting configuration!

I worked around things. Unfortunately my grub configuration required the host system to be UEFI booted (I think), and the only EFI machines I have available are x86-64 (or aarch64-darwin). From what I can tell, for whatever reason the binfmt emulation wasn’t working right, resulting in those errors.

As for my workaround:

  1. changed my grub config to use efiInstallAsRemovable = true; (and canTouchEfiVariables = false; as a corollary). This seems to allow nixos-installing from a non-EFI host.
  2. burned an installer ISO of the sd-image to USB
  3. booted the RPi from USB, giving me an aarch64-linux system
  4. nix-shell -p git, because flakes
  5. nixos-install from the installer ISO
  6. this gave me a bootable system (-ish, a few issues worked out in a rescue shell)
  7. revert the changes from #1
  8. nixos-rebuild --install-bootloader switch --flake .#homeslice
2 Likes

Damn, that’s a lot of detective work. Sorry I couldn’t be of much help, but I’m glad to see you found a somewhat workable solution.

1 Like