diff --git a/home/programs/custom-nix-cache.nix b/home/programs/custom-nix-cache.nix index a01292c..12c38ab 100644 --- a/home/programs/custom-nix-cache.nix +++ b/home/programs/custom-nix-cache.nix @@ -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 '';