From 7b77d12a8bc7beb3c6dbf8da2fed20e1fd2da4b5 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 28 Jun 2024 09:53:18 -0500 Subject: [PATCH] Make pushing optional --- nix/cache.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nix/cache.nix b/nix/cache.nix index 2305640..daadc80 100644 --- a/nix/cache.nix +++ b/nix/cache.nix @@ -20,7 +20,10 @@ in writeShellApplication { packer ]; text = '' - mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET" + push="''${1:-yes}" + if [ "$push" == "yes" ]; then + mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET" + fi mkdir -p cache '' + (concatStringsSep "\n" ( map (d: '' @@ -29,7 +32,9 @@ in writeShellApplication { # shellcheck disable=SC2143 if [ -z "$(mc ls storage/isos/cache/ | grep "$sha")" ]; then curl -L --retry 3 --retry-all-errors -o "cache/$sha.iso" "$url" - mc put "cache/$sha.iso" "storage/isos/cache/$sha.iso" + if [ "$push" == "yes" ]; then + mc put "cache/$sha.iso" "storage/isos/cache/$sha.iso" + fi else echo "Skipping ${d.distro} - cache/$sha.iso" fi