From 5cf89fbc2f533326f29cd4f46ee590e4d03dd86c Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 20 Mar 2021 13:37:08 +0000 Subject: [PATCH] switch-prebuilt: check for existence before nix copy --- ops/nixos/lib/switch-prebuilt.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ops/nixos/lib/switch-prebuilt.nix b/ops/nixos/lib/switch-prebuilt.nix index 4adbb16a27..7820cb557d 100644 --- a/ops/nixos/lib/switch-prebuilt.nix +++ b/ops/nixos/lib/switch-prebuilt.nix @@ -10,8 +10,11 @@ pkgs.writeShellScriptBin "switch-prebuilt" '' export AWS_SECRET_ACCESS_KEY="${depot.ops.secrets.nixCache.AWS_SECRET_ACCESS_KEY}" system="''${1}" - # We should be a trusted-user. - nix copy -v --from 's3://lukegb-nix-cache?endpoint=storage.googleapis.com' --no-check-sigs "$system" + if [[ ! -e "$system" ]]; then + # We should be a trusted-user. + nix copy -v --from 's3://lukegb-nix-cache?endpoint=storage.googleapis.com' --no-check-sigs "$system" + fi + diff "$system/etc/hostname" "/etc/hostname" # The next phase requires sudo, but it's harmless to run the preceding commands twice.