nix-dotfiles/utils/attic-push.bash
ahuston-0 c7411635f7
Some checks failed
Check Nix flake / Perform Nix flake checks (ubuntu-latest) (pull_request) Failing after 5m57s
Check flake.lock / Check health of `flake.lock` (pull_request) Successful in 8s
Check Nix formatting / Perform Nix format checks (pull_request) Successful in 2m23s
add optional attic push
Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
2025-01-26 12:00:51 -05:00

23 lines
586 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 100M
nix_paths=$(nix path-info --json --all --closure-size \
| jq 'map_values(.closureSize | select(. < 1e8)) | to_entries | sort_by(.value)' \
| jq 'map(.key) | join("\n")' | sed 's/\\n/\n/g')
readarray -t nix_path_array < <(echo "$nix_paths")
batchsize=10
for((i=0; i < ${#nix_path_array[@]}; i+=batchsize))
do
part=( "${nix_path_array[@]:i:batchsize}" )
attic push "${part[@]}"
done