I am trying to relocate /nix to /opt/nix on macOS Catalina.
I have looked at other options like mounting a new volume or creating a firmlink, but I have decided that moving the nix store works best for me despite losing the binary cache.
I read through 3 different things for changing the store path:
- The --store option which is not documented much
- The NIX_STORE_DIR environmental variable which again is not documented much
- Build Nix using -with-store-dir=/opt/nix/store
Since 3 is most documented, I went with that. I used the below commands and got the following error.
I am not sure how to proceed. Maybe if I can’t build on Darwin, can I build on Linux and target Darwin?
./configure --with-store-dir=/opt/nix/store --disable-seccomp-sandboxing --disable-gc --localstatedir=/opt/nix/var
...
make
....
1 warning generated.
LD src/libstore/libnixstore.dylib
LD src/libexpr/libnixexpr.dylib
CXX src/libmain/common-args.o
CXX src/libmain/shared.o
CXX src/libmain/stack.o
LD src/libmain/libnixmain.dylib
LD src/nix/nix
Undefined symbols for architecture x86_64:
"_GC_free", referenced from:
nix::CmdRepl::run(nix::ref<nix::Store>) in repl.o
"_GC_malloc", referenced from:
nix::CmdRepl::run(nix::ref<nix::Store>) in repl.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [src/nix/nix] Error 1
And if helpful, here is the make dry run of where I’m at:
eeee@eeee nix-2.3.75 % make -n
echo " LD " src/nix/nix; g++ -std=c++17 -o src/nix/nix -all_load -L/usr/local/lib src/build-remote/build-remote.o src/nix-build/nix-build.o src/nix-channel/nix-channel.o src/nix-collect-garbage/nix-collect-garbage.o src/nix-copy-closure/nix-copy-closure.o src/nix-daemon/nix-daemon.o src/nix-env/nix-env.o src/nix-env/user-env.o src/nix-instantiate/nix-instantiate.o src/nix-prefetch-url/nix-prefetch-url.o src/nix-store/dotgraph.o src/nix-store/graphml.o src/nix-store/nix-store.o src/nix/add-to-store.o src/nix/build.o src/nix/cat.o src/nix/command.o src/nix/copy.o src/nix/doctor.o src/nix/dump-path.o src/nix/edit.o src/nix/eval.o src/nix/hash.o src/nix/installables.o src/nix/legacy.o src/nix/log.o src/nix/ls.o src/nix/main.o src/nix/optimise-store.o src/nix/path-info.o src/nix/ping-store.o src/nix/progress-bar.o src/nix/repl.o src/nix/run.o src/nix/search.o src/nix/show-config.o src/nix/show-derivation.o src/nix/sigs.o src/nix/upgrade-nix.o src/nix/verify.o src/nix/why-depends.o -pthread -L/usr/local/lib -leditline -L/usr/local/lib -lboost_context -lboost_thread -lboost_system -Lsrc/libexpr -lnixexpr -Lsrc/libmain -lnixmain -Lsrc/libstore -lnixstore -Lsrc/libutil -lnixutil
mkdir -p "src/resolve-system-dependencies/"
echo " CXX " src/resolve-system-dependencies/resolve-system-dependencies.o; g++ -std=c++17 -o src/resolve-system-dependencies/resolve-system-dependencies.o -c src/resolve-system-dependencies/resolve-system-dependencies.cc -g -Wall -include config.h -fPIC -g -I . -I src -I src/libutil -I src/libstore -I src/libmain -I src/libexpr -I src/nix -I/usr/local/Cellar/brotli/1.0.7/include -I/usr/local/include -I/usr/local/include -I/usr/local/Cellar/openssl@1.1/1.1.1g/include -I/usr/local/include -O3 -MMD -MF src/resolve-system-dependencies/.resolve-system-dependencies.o.dep -MP
echo " LD " src/resolve-system-dependencies/resolve-system-dependencies; g++ -std=c++17 -o src/resolve-system-dependencies/resolve-system-dependencies -all_load -L/usr/local/lib src/resolve-system-dependencies/resolve-system-dependencies.o -Lsrc/libstore -lnixstore -Lsrc/libmain -lnixmain -Lsrc/libutil -lnixutil
echo " GEN " scripts/nix-http-export.cgi; rm -f scripts/nix-http-export.cgi && ./config.status --quiet --file=scripts/nix-http-export.cgi
echo " GEN " scripts/nix-profile.sh; rm -f scripts/nix-profile.sh && ./config.status --quiet --file=scripts/nix-profile.sh
echo " GEN " scripts/nix-reduce-build; rm -f scripts/nix-reduce-build && ./config.status --quiet --file=scripts/nix-reduce-build
eeee@eeee nix-2.3.75 %