Improve nixos-enter / chroot support with broken nix-daemon #1206

Open
opened 2026-05-04 16:21:54 +00:00 by teutat3s · 0 comments

Describe the bug

Imagine a nixos-enter rescue situation with a single / partition.
Booted from a NixOS 25.11 installation ISO, you mount your broken NixOS disk to /mnt and chroot using nixos-enter. You fix your broken config, then try to rebuild. Inside the chroot, you are using lix. The installation ISO uses nix. When trying to nix build <flake-config> inside the chroot you are presented with the error:

error: cannot connect to socket at '/nix/var/nix/daemon-socket/socket': Connection refused

As a workaround, using /nix/store/<hash>-nix-2.31.2/bin/nix inside the chroot works. @raito mentioned on Matrix that

NIX_REMOTE=local nix

should also work.

Steps To Reproduce

  1. Mount NixOS 25.11 installation ISO
  2. Boot from ISO
  3. Mount NixOS disk configured to use lix to /mnt
  4. (Optional) mount boot disk to /mnt/boot, also any other partitions that might be necessary
  5. nixos-enter
  6. Try to use nix build inside the chroot
  7. Observe above mentioned error

Expected behavior

lix should be able to nix build inside a chrooted NixOS.

nix --version output

  • inside chroot: lix version 2.94.1
  • NixOS installation ISO: nix version 2.31.2
## Describe the bug Imagine a `nixos-enter` rescue situation with a single `/` partition. Booted from a NixOS 25.11 installation ISO, you mount your broken NixOS disk to `/mnt` and `chroot` using `nixos-enter`. You fix your broken config, then try to rebuild. Inside the chroot, you are using `lix`. The installation ISO uses `nix`. When trying to `nix build <flake-config>` inside the chroot you are presented with the error: ``` error: cannot connect to socket at '/nix/var/nix/daemon-socket/socket': Connection refused ``` As a workaround, using `/nix/store/<hash>-nix-2.31.2/bin/nix` inside the chroot works. @raito mentioned on Matrix that ``` NIX_REMOTE=local nix ``` should also work. ## Steps To Reproduce 1. Mount NixOS 25.11 installation ISO 2. Boot from ISO 3. Mount NixOS disk configured to use `lix` to `/mnt` 4. (Optional) mount boot disk to `/mnt/boot`, also any other partitions that might be necessary 5. `nixos-enter` 6. Try to use `nix build` inside the chroot 7. Observe above mentioned error ## Expected behavior `lix` should be able to `nix build` inside a chrooted NixOS. ## `nix --version` output - inside chroot: lix version `2.94.1` - NixOS installation ISO: nix version `2.31.2`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#1206
No description provided.