1
1
mirror of https://github.com/nmattia/niv.git synced 2024-11-07 22:36:53 +03:00

GC and use store as cache

This commit is contained in:
Nicolas Mattia 2019-02-05 14:19:17 +01:00
parent 487b6bbfc9
commit 0b555e497c
2 changed files with 17 additions and 8 deletions

View File

@ -12,8 +12,17 @@ jobs:
sudo chown circleci /nix
bash <(curl https://nixos.org/nix/install)
echo '. /home/circleci/.nix-profile/etc/profile.d/nix.sh' >> $BASH_ENV
sudo mkdir -p /etc/nix && echo "sandbox = true" | sudo tee -a /etc/nix/nix.conf
sudo mkdir -p /etc/nix &&
# Enable sandbox
echo "sandbox = true" | sudo tee -a /etc/nix/nix.conf
# Keep derivations and their outputs for better caching
echo "keep-outputs = true" | sudo tee -a /etc/nix/nix.conf
echo "keep-derivations = true" | sudo tee -a /etc/nix/nix.conf
- checkout
- restore_cache:
# Match on the latest cache for this branch
keys:
@ -41,11 +50,14 @@ jobs:
- run:
name: Create cache
command: |
nix-store --gc
cache_path=~/.nix-build-cache-export.gz
store_list=~/.store-list
echo "Listing paths"
nix-instantiate \
| xargs nix-store -qR --include-outputs \
find /nix/store \
-maxdepth 1 -mindepth 1 \
-not -name '\.links' -print \
| sort \
> $store_list
echo "Generating cache file"
cat $store_list \

View File

@ -10,10 +10,7 @@ export NIX_PATH="nixpkgs=./nix"
echo "Building"
nix build --no-link
echo "Testing shell"
nix-shell --run "echo -n"
# Build and create a root
nix build
echo "all good"