1
0
Fork 0

Improve custom cache upload script

This commit is contained in:
Daniel Kempkens 2022-08-09 20:33:39 +02:00
parent db683560ac
commit abcf83a3ad

View file

@ -14,7 +14,8 @@ in
sudo mkdir ${cache.rootDir}/.aws 2> /dev/null
sudo cp "$HOME/.aws/credentials" ${cache.rootDir}/.aws/
uncachedHashes=$(echo 'SELECT DISTINCT hashPart FROM NARs WHERE present = 0;' | sudo sqlite3 "${cache.database}")
minTimestamp=$(expr $(date +%s) - 3600)
uncachedHashes=$(echo "SELECT DISTINCT hashPart FROM NARs WHERE present = 0 AND timestamp >= $minTimestamp;" | sudo sqlite3 "${cache.database}")
signingKey="$HOME/.config/nifoc-nix/${cache.signingKey}"
for uncachedHash in $uncachedHashes; do
@ -35,10 +36,10 @@ in
if [ "$1" = "--list" ]; then
echo "$storePath"
else
nix store sign --key-file $signingKey $storePath
sudo -H nix store sign --key-file $signingKey $storePath
echo "Uploading $storePath ..."
nix copy --to '${cache.s3Url}' $storePath
sudo -H nix copy --to '${cache.s3Url}' $storePath
fi
done
'';