I’m trying to package Nix and it turns out that make all
actually tries to write linker output to /usr/local/
(the configured --prefix=
), i.e.,
CXX src/libmain/shared.o
CXX src/libmain/stack.o
LD src/libmain/libnixmain.so
CXX src/libcmd/command.o
CXX src/libcmd/installables.o
CXX src/libcmd/legacy.o
CXX src/libcmd/markdown.o
LD src/libcmd/libnixcmd.so
LD src/nix/nix
GEN scripts/nix-http-export.cgi
GEN scripts/nix-profile.sh
GEN scripts/nix-reduce-build
GEN doc/manual/nix-env.1
GEN doc/manual/nix-build.1
GEN doc/manual/nix-shell.1
GEN doc/manual/nix-store.1
GEN doc/manual/nix-instantiate.1
GEN doc/manual/nix-collect-garbage.1
GEN doc/manual/nix-prefetch-url.1
GEN doc/manual/nix-channel.1
GEN doc/manual/nix-hash.1
GEN doc/manual/nix-copy-closure.1
LD /usr/local/lib/libnixutil.so
ld: error: cannot open output file /usr/local/lib/libnixutil.so: Permission denied
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
This seems wrong, make all
should never write outside the build directory.
As far as I understand the makefiles, this is done (in the instance shown above) to inject an rpath
value into the final nix
executable. I would like to understand why that is necessary. Or if it is not necessary, what is the rationale?
Perhaps this step can be made optional.
Or perhaps building everything statically will avoid this problem completely. I might try that anyway.