Skip to content

Build fails on DESTDIR= build environments: No rule to make target '/usr/bin/nix' #5781

@trofi

Description

@trofi

Linux distributions usually install packages into sandboxed environments before moving packages into live system:

$ ./configure --prefix=/usr
$ make install DESTDIR=/sandbox
$ mv /sandbox/* /

nix fails at make install stage:

make: *** No rule to make target '/usr/bin/nix', needed by 'doc/manual/nix.json'.  Stop.
make: *** Waiting for unfinished jobs....

On NixOS it's easiest to reproduce by using inaccessible prefix:

$ nix develop -f ~/nixpkgs/master nixUnstable
$ ./bootstrap.sh
$ ./configure --prefix=/usr
$ make install DESTDIR=$PWD/__sandbox__
...
make: *** No rule to make target '/usr/bin/nix', needed by 'doc/manual/nix.json'.  Stop.

I sprinlked s@$(bindir)/nix@$(DESTDIR)$(bindir)/nix@g around with:

--- a/doc/manual/local.mk
+++ b/doc/manual/local.mk
@@ -20,7 +20,7 @@ dummy-env = env -i \
        NIX_STATE_DIR=/dummy \
        NIX_CONFIG='cores = 0'

-nix-eval = $(dummy-env) $(bindir)/nix eval --experimental-features nix-command -I nix/corepkgs=corepkgs --store dummy:// --impure --raw
+nix-eval = $(dummy-env) $(DESTDIR)$(bindir)/nix eval --experimental-features nix-command -I nix/corepkgs=corepkgs --store dummy:// --impure --raw

 $(d)/%.1: $(d)/src/command-ref/%.md
        @printf "Title: %s\n\n" "$$(basename $@ .1)" > $^.tmp
@@ -44,7 +44,7 @@ $(d)/src/SUMMARY.md: $(d)/src/SUMMARY.md.in $(d)/src/command-ref/new-cli
        $(trace-gen) cat doc/manual/src/SUMMARY.md.in | while IFS= read line; do if [[ $$line = @manpages@ ]]; then cat doc/manual/src/command-ref/new-cli/SUMMARY.md; else echo "$$line"; fi; done > [email protected]
        @mv [email protected] $@

But it's not enough as nix relies on it's own local libraries:

$ dev>LANG=C make install DESTDIR=$PWD/__sandbox__
  INST   /home/slyfox/dev/git/nix/__sandbox__/usr/libexec/nix/build-remote
  GEN    doc/manual/nix.json
/home/slyfox/dev/git/nix/__sandbox__/usr/bin/nix: error while loading shared libraries: libnixexpr.so: cannot open shared object file: No such file or directory
make: *** [doc/manual/local.mk:57: doc/manual/nix.json] Error 127

What would be the best way to fix it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions