nix-community / nixos-anywhere

install nixos everywhere via ssh [maintainer=@numtide]
https://nix-community.github.io/nixos-anywhere/
MIT License
1.66k stars 116 forks source link

nixos-anywhere doesn't respect `--option sandbox relaxed` or `--option sandbox false` flags #397

Closed hatredholder closed 2 weeks ago

hatredholder commented 1 month ago

Issue

In my NixOS configuration I have a derivation which uses __noChroot = true to disable the sandbox and have internet access. In order to build the configuration I must set --option sandbox relaxed flag before running nix build, which works fine on my local machine.

When I run nixos-anywhere with the specified sandbox option, however, I get the following error:

$ nix run github:nix-community/nixos-anywhere -- --flake .#nixos --option sandbox relaxed root@ip

...

error:
       … while calling the 'head' builtin

         at /nix/store/x76i82ichcxssszb5i0ppzlmffms9iyk-source/lib/attrsets.nix:1575:11:

         1574|         || pred here (elemAt values 1) (head values) then
         1575|           head values
             |           ^
         1576|         else

       … while evaluating the attribute 'value'

         at /nix/store/x76i82ichcxssszb5i0ppzlmffms9iyk-source/lib/modules.nix:821:9:

          820|     in warnDeprecation opt //
          821|       { value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          822|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: derivation '/nix/store/apnjia83x4kr3730f41ssyh0b8njc2rx-ytdata.json.drv' has '__noChroot' set, but that's not allowed when 'sandbox' is 'true'

I've also tried running it with --option sandbox false, no success that way either.

System information

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.52, NixOS, 24.11 (Vicuna), 24.11.20240919.c04d565`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - nixpkgs: `/nix/store/hiasfhl8f5yy88hcfbr3s8s4bm63wsjw-source`
hatredholder commented 2 weeks ago

Updated Nix and the issue disappeared:

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.57, NixOS, 24.11 (Vicuna), 24.11.20241025.18536bf`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.24.9`
 - nixpkgs: `/nix/store/wb6agba4kfsxpbnb5hzlq58vkjzvbsk6-source`