From 334bb6100bdd1a5664275eae5d5c0a7062e5e1cf Mon Sep 17 00:00:00 2001 From: zimbatm Date: Mon, 2 Nov 2020 12:35:39 +0100 Subject: [PATCH] idempotent installation Don't run the installer if Nix has already been installed on the host. We assume that the installed Nix is already in the desired state. This allows to share a given pipeline between hosted and self-hosted runners. Usually the self-hosted runners are long-lived and already have Nix installed. --- lib/install-nix.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/install-nix.sh b/lib/install-nix.sh index 9b2e240..d4a3b9a 100755 --- a/lib/install-nix.sh +++ b/lib/install-nix.sh @@ -1,6 +1,11 @@ #!/usr/bin/env bash set -euo pipefail +if type -p nix &>/dev/null ; then + echo "Aborting: Nix is already installed at $(type -p nix)" + exit +fi + # Configure Nix add_config() { echo "$1" | sudo tee -a /tmp/nix.conf >/dev/null