27 lines
856 B
Bash
Executable File
27 lines
856 B
Bash
Executable File
#!/usr/bin/env nix
|
|
#! nix shell nixpkgs#bash nixpkgs#jq nixpkgs#gnused nixpkgs#nixVersions.latest nixpkgs#attic-client --command bash
|
|
|
|
#set -x
|
|
#set -v
|
|
set -e
|
|
|
|
# retrieve all paths under 2G
|
|
# nix_paths=$(nix path-info --json --all --closure-size \
|
|
# | jq 'map_values(.closureSize | select(. < 2e9)) | to_entries | sort_by(.value)' \
|
|
# | jq 'map(.key) | join("\n")' | sed -E -e 's/\\n/\n/g;s/^"//g;s/"$//g')
|
|
|
|
# retrieve all paths
|
|
nix_paths=$(nix path-info --json --all --closure-size |
|
|
jq 'map_values(.closureSize | select(true)) | to_entries | sort_by(.value)' |
|
|
jq 'map(.key) | join("\n")' | sed -E -e 's/\\n/\n/g;s/^"//g;s/"$//g')
|
|
|
|
readarray -t nix_path_array < <(echo "$nix_paths")
|
|
|
|
batchsize=1000
|
|
|
|
for ((i = 0; i < ${#nix_path_array[@]}; i += batchsize)); do
|
|
part=("${nix_path_array[@]:i:batchsize}")
|
|
|
|
attic push nix-cache "${part[@]}"
|
|
done
|