tl;dr How to I combine
nix-store --add-fixed and
nix-store --add-root to prevent garbage collection of manually added files?
I’ve installed Mathematica on my Nix installation which requires the manual insertion of the installer into the Nix store. To this end I am using
$ nix-store --add-fixed sha256 Mathematica_11.3.0_LINUX.sh
First of all this doesn’t work on my 2012 laptop because it runs out of memory and I use the technique outlined in the (old) NixOS wiki.
Find the right store path
$ nix-hash --type sha256 --flat --base32 Mathematica_11.3.0_LINUX.sh 03nimsayxj18740nq1jxkjyif2rphkdhpbz3gf749j7aq44f5kqg $ nix-store --print-fixed-path sha256 03nimsayxj18740nq1jxkjyif2rphkdhpbz3gf749j7aq44f5kqg Mathematica_11.3.0_LINUX.sh /nix/store/h9pljd50ha6b4bbrwp3riabh3g4i5bkp-Mathematica_11.3.0_LINUX.sh
Move (or copy) the file there as root
# mount -o remount,rw /nix/store # mv Mathematica_11.3.0_LINUX.sh /nix/store/h9pljd50ha6b4bbrwp3riabh3g4i5bkp-Mathematica_11.3.0_LINUX.sh # mount -o remount,ro /nix/store
Register the file (interactively, i.e. requires user input)
# nix-store --register-validity --reregister /nix/store/h9pljd50ha6b4bbrwp3riabh3g4i5bkp-Mathematica_11.3.0_LINUX.sh <RET> <RET> 0 <RET> <C-d>
This method is surely not very elegant but seems to work fine. However, because the laptop is so old, it only has a small SSD and therefore I regularly garbage collect the Nix store. Unfortunately, this will eventually delete the Mathematica installer but I need this again when there is an update for curl or whatever and the Mathematica derivation has to be rebuilt. Hence I’m keeping around a second copy of the installer outside of the Nix store, just so that I can go through the process described above again, when it is needed.
I’ve went through the manpage of
nix-store and found the
--add-root option to add a gcroot for a realization but I don’t know how to combine this with the above process. Can you please help me?
Just another side question: How do I change the syntax highlighting to not use Nix language highlighting, but either none or console session?