nixpkgs icon indicating copy to clipboard operation
nixpkgs copied to clipboard

Documentation: Debian package states that sandbox must equal false for it to work on Debian but issue does not exist

Open AkechiShiro opened this issue 1 year ago • 4 comments

Problem

This is on Debian 11 Bullseye (after having installed Nix)

image

https://github.com/NixOS/nixpkgs/pull/47794#issuecomment-429575989 (404)

Proposal

Link the proper issue that explains why or build documentation that explains what are the current blockers for this feature.

Checklist

AkechiShiro avatar Aug 20 '23 16:08 AkechiShiro

Trying with sandbox=true, does fail I guess if bash is not present :

debian11:~$ nix-channel --update
unpacking channels...
while setting up the build environment: executing '/bin/bash': No such file or directory
builder for '/nix/store/c35hpqm9y66k75drlin48z16j6ljslyd-nixpkgs-23.11pre516257.3476a1047858.drv' failed with exit code 1
error: build of '/nix/store/c35hpqm9y66k75drlin48z16j6ljslyd-nixpkgs-23.11pre516257.3476a1047858.drv' failed
error: program '/usr/bin/nix-env' failed with exit code 100

AkechiShiro avatar Aug 20 '23 16:08 AkechiShiro

With sandbox=false, it does indeed work, now as to why this is I'm clueless.

AkechiShiro avatar Aug 20 '23 16:08 AkechiShiro

FYI, original link https://web.archive.org/web/20220112084213/https://github.com/NixOS/nixpkgs/pull/47794

valodzka avatar May 13 '24 11:05 valodzka

I don't understand how it is related to this : dhcp: fix build with sandbox=false #47794 dhcp still does not build with sandbox=true under Debian with Nix ?

There was someone that talked about a source of impurity maybe at hand here making the need to disable the sandbox so this issue should be documented and may need to be fixed at some point, no ? Or I'm misunderstanding something here ?

AkechiShiro avatar May 14 '24 04:05 AkechiShiro

I am not sure if this has been discussed elsewhere. I found a comment in Debian's /etc/nix/nix.conf, searched for an explanation, and only found this issue and a link on the web archive.

From my experiments, it works in most cases but breaks in some. For example, this derivation works on Debian without sandbox and on NixOS with sandbox, but fails on Debian with sandbox:

  initDb = pkgs.stdenv.mkDerivation {
    buildInputs = [pkgs.postgresql_16];
    name = "init-db";
    phases = ["buildPhase"];
    buildPhase = ''
      initdb $out
    '';
  };

valodzka avatar May 14 '24 08:05 valodzka

Has anyone been able to pinpoint the reason why would the sandbox break on Debian? There must be some form of pollution/or network request something that is breaking due to the sandboxing on Debian that we don't have on NixOS.

But pinpointing exactly what isn't easy.

AkechiShiro avatar May 14 '24 08:05 AkechiShiro

After some research, I found that sandboxing works differently on Debian than on NixOS because NixOS includes /bin/sh in the sandbox, while Debian does not. Adding a static BusyBox to nix.conf (extra-sandbox-paths = /bin/sh=/bin/busybox) resolved all the issues I encountered. Now, all packages I checked work on Debian with sandboxing.

valodzka avatar May 16 '24 10:05 valodzka

Thanks for researching the root cause and finding a way to fix it, maybe we should document this in the documentation ?

May I ask where did you find more information on the sandboxing ? Did you read the source code of some specific file in this repo ?

AkechiShiro avatar May 17 '24 10:05 AkechiShiro

May I ask where did you find more information on the sandboxing ?

I simply ran nix show-config --extra-experimental-features nix-command | grep sandbox on Debian and on NixOS and saw the difference.

valodzka avatar May 17 '24 11:05 valodzka

maybe we should document this in the documentation ?

This is briefly mentioned in the nix documentation, but it’s practically impossible to find unless you know exactly what you're looking for.

Depending on how Nix was built, the default value for this option may be empty or provide /bin/sh as a bind-mount of bash.

valodzka avatar May 18 '24 12:05 valodzka

[…] Now, all packages I checked work on Debian with sandboxing.

Thank you for your research; was going crazy when researching build-issues reported by Debian-based colleagues trying to run unit-tests executed against an ephemeral postgres…

All I could respond was "works on my machine", which is precisely the phrase we wanted to eliminate by adopting nix…

obreitwi avatar Jul 04 '24 14:07 obreitwi