NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.51k stars 1.5k forks source link

Build fails in single-user mode, but works with a daemon #2762

Open tilpner opened 5 years ago

tilpner commented 5 years ago

This issue is a result of @yurkobb's errors during nix-env -u.

# weird.nix
with import <nixpkgs> {};

stdenv.mkDerivation {
  name = "weird";
  src = fetchurl {
    url = https://newsboat.org/releases/2.15/newsboat-2.15.tar.xz;
    sha256 = "1dqdcp34jmphqf3d8ik0xdhg0s66nd5rky0y8y591nidq29wws6s";
  };

  phases = [ "unpackPhase" "installPhase" ];

  installPhase = "echo done > $out";
}

This derivation builds fine with a daemon, but not on a single-user installation or as root on a multi-user installation:

~/dev/foo/nix > nix-build --no-out-link weird.nix
these derivations will be built:
  /nix/store/vs258nla6s2pw9zgnpg0l7dcjc28gpvg-weird.drv
building '/nix/store/vs258nla6s2pw9zgnpg0l7dcjc28gpvg-weird.drv'...
unpacking sources
unpacking source archive /nix/store/ndqhrldc89207rqi8mda8nz6lj4vdpq9-newsboat-2.15.tar.xz
source root is newsboat-2.15
setting SOURCE_DATE_EPOCH to timestamp 1553359864 of file newsboat-2.15/txt2h
installing
/nix/store/iy24hzgrx181c6drqy2qmldmgihhsp53-weird

~/dev/foo/nix > nix-store --delete /nix/store/iy24hzgrx181c6drqy2qmldmgihhsp53-weird
finding garbage collector roots...
removing stale link from '/nix/var/nix/gcroots/auto/9vmxbpm6s4hmhy3pcm37j5kix8s64473' to '/tmp/nix-build-25614-0/result'
deleting '/nix/store/iy24hzgrx181c6drqy2qmldmgihhsp53-weird'
deleting '/nix/store/trash'
deleting unused links...
note: currently hard linking saves 3718.13 MiB
1 store paths deleted, 0.00 MiB freed

~/dev/foo/nix > sudo nix-build --no-out-link weird.nix
these derivations will be built:
  /nix/store/vs258nla6s2pw9zgnpg0l7dcjc28gpvg-weird.drv
building '/nix/store/vs258nla6s2pw9zgnpg0l7dcjc28gpvg-weird.drv'...
unpacking sources
unpacking source archive /nix/store/ndqhrldc89207rqi8mda8nz6lj4vdpq9-newsboat-2.15.tar.xz
do not know how to unpack source archive /nix/store/ndqhrldc89207rqi8mda8nz6lj4vdpq9-newsboat-2.15.tar.xz
builder for '/nix/store/vs258nla6s2pw9zgnpg0l7dcjc28gpvg-weird.drv' failed with exit code 1
error: build of '/nix/store/vs258nla6s2pw9zgnpg0l7dcjc28gpvg-weird.drv' failed

Note how it intends to build the same derivation both times, but succeeds only once. The error is identical for the single-user installation (done as non-root).

More -v doesn't seem to help either:

...
closing leaked FD 14
closing leaked FD 15
closing leaked FD 16
closing leaked FD 17
building '/nix/store/qhs6qdc4ylrf05vv9q873hyyq1q3pr5m-weird.drv'...
unpacking sources
unpacking source archive /nix/store/ndqhrldc89207rqi8mda8nz6lj4vdpq9-newsboat-2.15.tar.xz
do not know how to unpack source archive /nix/store/ndqhrldc89207rqi8mda8nz6lj4vdpq9-newsboat-2.15.tar.xz
building of '/nix/store/qhs6qdc4ylrf05vv9q873hyyq1q3pr5m-weird.drv': got EOF
building of '/nix/store/qhs6qdc4ylrf05vv9q873hyyq1q3pr5m-weird.drv': woken up
building of '/nix/store/qhs6qdc4ylrf05vv9q873hyyq1q3pr5m-weird.drv': build done
killing process 17154
builder process for '/nix/store/qhs6qdc4ylrf05vv9q873hyyq1q3pr5m-weird.drv' finished
killing all processes running under uid '30001'
builder for '/nix/store/qhs6qdc4ylrf05vv9q873hyyq1q3pr5m-weird.drv' failed with exit code 1
lock released on '/nix/store/jxrwgm3k1qjldn56b4vdkz0cxd17n2i0-weird.lock'
building of '/nix/store/qhs6qdc4ylrf05vv9q873hyyq1q3pr5m-weird.drv': done
building of '/nix/store/qhs6qdc4ylrf05vv9q873hyyq1q3pr5m-weird.drv': goal destroyed
error: build of '/nix/store/qhs6qdc4ylrf05vv9q873hyyq1q3pr5m-weird.drv' failed
download thread shutting down

All interactive shells had tar and xz available, but that seems irrelevant because Nix seems to pick the path from <nix/config.nix>.

This was tested on nixpkgs master with Nix 2.2 on NixOS 19.03 and Ubuntu 18.04.

FRidh commented 5 years ago

Weakly related. There used to be an attribute path that often failed on Hydra with

do not know how to unpack source archive

It was also an .xz file. It did not fail always though.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

stale[bot] commented 2 years ago

I closed this issue due to inactivity. → More info