3838 shell : bash
3939 run : |
4040 set -euxo pipefail
41+ NIX_BINARY_VERSION=2.32.0
42+ echo "NIX_BINARY_VERSION=$NIX_BINARY_VERSION" >> $GITHUB_ENV
43+ cat nix/canton-sources.json
4144 git ls-files nix/ | grep -v '[.]md$' | LC_ALL=C sort | xargs sha256sum -b > /tmp/nix-cache-key
4245 uname -m >> /tmp/nix-cache-key # Add architecture to the cache key
4346 echo "gh_cache_version: ${{ inputs.cache_version }}" >> /tmp/nix-cache-key # Add cache version to the cache key
47+ echo "home: $HOME" >> /tmp/nix-cache-key # important when restoring simlinks from cache, apparently
48+ echo "nix binary version: $NIX_BINARY_VERSION" >> /tmp/nix-cache-key # different nix versions might behave differently and corrupt the caches
4449 if [ "${{ inputs.oss_only }}" == true ]; then
4550 echo "Using OSS only dependencies"
4651 echo "oss_only: ${{ inputs.oss_only }}" >> /tmp/nix-cache-key
8691 # we use rsync here because it's simply faster to install
8792 rsync -avi /cache/nix/$cache_key/.nix-* $HOME/
8893 rsync -avi "/cache/nix/$cache_key/nix" $HOME/.config/
89- rsync -avi "/cache/nix/$cache_key/nix_store/var/" /nix/var
90- sudo mount --bind /cache/nix/$cache_key/nix_store/store /nix/store
94+ # TODO (#2663): fix & uncomment these two lines
95+ # rsync -avi "/cache/nix/$cache_key/nix_store/var/" /nix/var
96+ # sudo mount --bind /cache/nix/$cache_key/nix_store/store /nix/store
9197 else
9298 sudo mkdir -p "/cache/nix/$cache_key"
9399 sudo chown $(whoami):$(whoami) "/cache/nix/$cache_key"
@@ -126,7 +132,7 @@ runs:
126132 max-jobs = 16
127133 EOF
128134 fi
129- sh <(curl -fsSL --retry 8 https://releases.nixos.org/nix/nix-2.13.3 /install) --no-daemon
135+ sh <(curl -fsSL --retry 8 " https://releases.nixos.org/nix/nix-$NIX_BINARY_VERSION /install" ) --no-daemon
130136 sudo mkdir -p /etc/nix
131137 sudo chmod a+rw /etc/nix
132138 if [[ "${{ inputs.oss_only }}" == true ]]; then
@@ -147,8 +153,6 @@ runs:
147153 target="default"
148154 fi
149155 nix develop path:nix#${target} -v --profile "$HOME/.nix-shell" --command echo "Done loading packages"
150- echo "Garbage collecting to reduce cache size"
151- nix-store --gc
152156 fi
153157
154158 - name : Invoke nix before saving cache
@@ -176,6 +180,9 @@ runs:
176180 export USER=$(whoami)
177181 . ~/.nix-profile/etc/profile.d/nix.sh
178182
183+ echo "Garbage collecting to reduce cache size"
184+ nix-store --gc
185+
179186 nix copy --all --to 'file:///cache/nix/binary_cache?trusted=1' -v
180187
181188 CLONE_COMMAND="rclone --no-update-dir-modtime --no-update-modtime --size-only --multi-thread-streams=32 --transfers=32 --ignore-existing --links --create-empty-src-dirs --fast-list --metadata --order-by name,mixed --retries 10 copy"
@@ -187,7 +194,8 @@ runs:
187194
188195 #requires to preserve read only during clone
189196 sudo ${CLONE_COMMAND} /nix/store/ /cache/nix/$cache_key/nix_store/store
190- sudo ${CLONE_COMMAND} /nix/var/ "/cache/nix/$cache_key/nix_store/var"
197+ # TODO (#2663): fix & uncomment this line
198+ # sudo ${CLONE_COMMAND} /nix/var/ "/cache/nix/$cache_key/nix_store/var"
191199
192200 echo "done" > "/cache/nix/$cache_key/cached"
193201 fi
0 commit comments