$ schroot -c nixos
E: 15binfmt: update-binfmts: unable to open /var/run/schroot/mount/nixos-0cc7367a-84b4-4a8d-9ba3-1d36b05
391c4/bin/sh: No such file or directory
E: 20nssdatabases: /etc/schroot/setup.d/20nssdatabases: 32: cannot create /var/run/schroot/mount/nixos-0
cc7367a-84b4-4a8d-9ba3-1d36b05391c4/etc/services: Directory nonexistent
E: 15binfmt: update-binfmts: unable to open /var/run/schroot/mount/nixos-0cc7367a-84b4-4a8d-9ba3-1d36b05
391c4/bin/sh: No such file or directory
E: nixos-0cc7367a-84b4-4a8d-9ba3-1d36b05391c4: Chroot setup failed: stage=setup-start
What is going wrong here and how can I fix it? There are no problems schrooting into other Debian and Ubuntu installations in the same way.
This is a guess, Iâve never used schroot in anger, but since NixOS doesnât use an fhs directory structure /bin/sh only exists for compatibility reasons. Itâs a symlink to some path in the nix store on this distro. Chances are it doesnât exist until after the first boot, and schroot clearly needs it.
Yes, you also cannot execute /bin/bash with chroot, bash does not exist in that location, NixOS is not an fhs-compliant distro. Try chroot <root> /nix/store/<some hash>-bash-<version>/bin/bash.
The root cause is the same, NixOS is just quite different from traditional distros, and therefore some of the assumptions of the tools you use may not hold. In this case, the assumption that /bin/bash and /bin/sh exist. NixOS isnât the only distro where this might fail, alpine for example would break this too, at least in the bash case.
To fix this, youâll need to know a bit more about what schroot needs. What exactly is your use case for this, why are you chrooting at all? Maybe we can point you in the right direction from there.
I have a NixOS installation on a separate partition and use mainly Debian (still, maybe?). I want to build and test my programs in different environments (other Debian and Ubuntu versions and NixOS) without booting into those operating systems. I want to update packages in the NixOS partition.
Alternatively using Nix from Debian user-space does not work here. All Nix commands nix-env, nix-shell etc. terminate all my sessions after doing some work. Looks like a very ugly bug, but it prevents me from using Nix in user space, but this is a different issue.
Maybe we (we, who? O.O) can look at the original code of schroot and send some patches from nixos-enter!
Unfortunately I believe the easiest patch is if itsanixos then print ("hey, you are trying to chroot on NixOS! Use nixos-enter instead.")
nixpkgs$ bash nixos/modules/installer/tools/nixos-enter.sh --help
unshare: failed to execute nixos/modules/installer/tools/nixos-enter.sh: Datei oder Verzeichnis nicht gefunden
The German error message means: âFile or directory not foundâ.
It seems I need a command called âunshareâ. Never heard of it.