Jakub Sokołowski de7ce0493b
nix: optimize garbage collection
In order to prevent `nix-store --gc` from removing too much I've:

- Added the `keep-outputs = true` setting to `nix/nix.conf`
- Fixed `nix/scripts/gcroots.sh` to make symlinks in `/nix/var/nix/gcroots`
- Made `nix/scripts/build.sh` and `nix/scripts/shell.sh` use it

This way when running `make nix-gc` most recently used shells and built
derivations won't be removed along with their dependencies.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2020-06-22 16:34:27 +02:00

34 lines
802 B
Bash
Executable File

#!/usr/bin/env bash
# This script makes sure we have Nix tools available
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
# Location of profile script for Nix that adjusts PATH
export NIX_PROFILE_SH="${HOME}/.nix-profile/etc/profile.d/nix.sh"
function source_nix() {
# Just stop if Nix is already available
if [[ -x $(command -v nix) ]]; then
return
elif [[ -f "${NIX_PROFILE_SH}" ]]; then
# Load Nix profile if it exists
source "${NIX_PROFILE_SH}"
return
else
# Setup Nix if not available
${GIT_ROOT}/nix/scripts/setup.sh
fi
# Load Nix profile
source "${NIX_PROFILE_SH}"
# Verify Nix is available
if [[ ! -x $(command -v nix) ]]; then
echo "Nix not available, sourcing profile failed!" > /dev/stderr
exit 1
fi
}
source_nix