Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 693482 - sys-apps/nix-2.2.2 - nix-channel --update: error: build of '/nix/store/q7jp1fvirvfggj9ciybdzfbg46fy4rqb-nixpkgs-19.09pre191265.c4adeddb5f8.drv' failed
Summary: sys-apps/nix-2.2.2 - nix-channel --update: error: build of '/nix/store/q7jp1f...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sergei Trofimovich (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-04 12:14 UTC by Kirill Zaborsky
Modified: 2019-10-11 22:18 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kirill Zaborsky 2019-09-04 12:14:23 UTC
nix-2.2.2 fails to update channels:
```
qdesktop ~ # nix-channel --update
unpacking channels...
while setting up the build environment: executing '/bin/bash': No such file or directory
builder for '/nix/store/q7jp1fvirvfggj9ciybdzfbg46fy4rqb-nixpkgs-19.09pre191265.c4adeddb5f8.drv' failed with exit code 1
error: build of '/nix/store/q7jp1fvirvfggj9ciybdzfbg46fy4rqb-nixpkgs-19.09pre191265.c4adeddb5f8.drv' failed
error: program '/usr/bin/nix-env' failed with exit code 100
```
There is a discussion about this bug in https://github.com/NixOS/nix/issues/2673
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2019-09-04 20:48:34 UTC
I had impression I fixed it by passing busybox:
    --with-sandbox-shell=/bin/busybox

Can you post your output of:
$ nix show-config | fgrep sandbox
Comment 2 Michael Schmid 2019-09-05 06:00:43 UTC
(In reply to Sergei Trofimovich from comment #1)
> I had impression I fixed it by passing busybox:
>     --with-sandbox-shell=/bin/busybox
I had the same error and this workaround works for me while running "nix-channel --update".
Comment 3 Kirill Zaborsky 2019-09-05 07:05:30 UTC
qdesktop ~ # nix show-config | fgrep sandbox
extra-sandbox-paths = 
sandbox = true
sandbox-build-dir = /build
sandbox-dev-shm-size = 50%
sandbox-paths = /bin/sh=/bin/busybox

and using the flag you specified makes it work (but I guess it's just a workaround):

qdesktop ~ # nix-channel --update --with-sandbox-shell=/bin/busybox
unpacking channels...
created 2 symlinks in user environment
Comment 4 Sergei Trofimovich (RETIRED) gentoo-dev 2019-09-05 18:37:31 UTC
(In reply to Kirill Zaborsky from comment #3)
> qdesktop ~ # nix show-config | fgrep sandbox
> extra-sandbox-paths = 
> sandbox = true
> sandbox-build-dir = /build
> sandbox-dev-shm-size = 50%
> sandbox-paths = /bin/sh=/bin/busybox
> 
> and using the flag you specified makes it work (but I guess it's just a
> workaround):
> 
> qdesktop ~ # nix-channel --update --with-sandbox-shell=/bin/busybox
> unpacking channels...
> created 2 symlinks in user environment

Oh, I had no idea you can pass that flag as a commandline argument as well. I meant ./configure's flag. That is good to know :)

Any chance you were running old nix-daemon? Or it was freshly started after nix being updated?
Comment 5 Kirill Zaborsky 2019-09-05 18:42:42 UTC
I don't quite remember when I upgraded nix. And also I've restarted nixdaemon multiple times which doesn't give me anything.
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2019-09-07 08:12:02 UTC
Reproduced locally on freshly created user. nix-build tries to use system /bin/bash if nix store does not provide one but does not pull in it's runtime libraries into container. Looking.
Comment 7 Kirill Zaborsky 2019-10-05 13:42:04 UTC
It looks like nix-channel --update --with-sandbox-shell=/bin/busybox doesn't work anymore:


qdesktop /home/qrilka # nix-channel --update --with-sandbox-shell=/bin/busybox
unpacking channels...
qdesktop /home/qrilka #

And nix-info shows that root is at nixpkgs-19.09pre182717.b58ada326aa which is from June and I couldn't get updates
Comment 8 Kirill Zaborsky 2019-10-09 21:48:02 UTC
Updating nix to 2.3 didn't change the situation
Comment 9 Kirill Zaborsky 2019-10-10 07:38:36 UTC
As a workaround I have disabled sandbox for doing nix-channel --update
Comment 10 Larry the Git Cow gentoo-dev 2019-10-10 22:08:54 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d230dd2ca9479868134a2278c8759f03a80e01e7

commit d230dd2ca9479868134a2278c8759f03a80e01e7
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-10-10 22:08:33 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-10-10 22:08:48 +0000

    sys-apps/nix: fix nix bootstrap, bug #693482
    
    Fix `nix-channel --update` does not work on freshly-installed nix.
    
    `nix-channel --update` does a few main things:
    1. fetch new tarball with nix expressions
    2. unpack that tarball as part of the build system using
       a shell script derived by unpack-channel.nix.
    3. install the result into /nix/store
    
    [2.] fails because tarball unpacking runs in a sandboxed environment
    in a container with /nix/store and /bin/sh mounted.
    
    unpack-channel.nix needs bash, tar and xz binaries in PATH.
    These are normally provided by bash, tar and xz packages from /nix/store.
    
    Unfortunately bash, tar and xz packages are not yet fetched as we
    only have nix installed without nixpkgs tree.
    
    1. we patch unpack-channel.nix to only require 'sh'
    2. we use /bin/sh as a static busybox and point nix at it:
       ./configure --with-sandbox-shell=/bin/busybox
    
    Reported-by: Kirill Zaborsky
    Closes: https://bugs.gentoo.org/693482
    Bug: https://github.com/NixOS/nix/issues/2673
    Package-Manager: Portage-2.3.76, Repoman-2.3.17
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 sys-apps/nix/files/nix-2.3-bootstrap.patch |  58 ++++++++++++
 sys-apps/nix/nix-2.3-r1.ebuild             | 138 +++++++++++++++++++++++++++++
 2 files changed, 196 insertions(+)
Comment 11 Sergei Trofimovich (RETIRED) gentoo-dev 2019-10-10 22:10:00 UTC
Pushed the workaround into sys-apps/nix-2.3-r1. `nix-channel --update` should work with a sandbox enabled now.
Comment 12 Kirill Zaborsky 2019-10-11 21:42:08 UTC
Works fine, thank you!
Comment 13 Sergei Trofimovich (RETIRED) gentoo-dev 2019-10-11 22:18:22 UTC
Thank for the report and test! It's always easy to miss when nix is already up and running.