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.
This commit is contained in:
zimbatm 2020-11-02 12:35:39 +01:00
parent d5ba40b697
commit 334bb6100b
No known key found for this signature in database
GPG key ID: 71BAF6D40C1D63D7

View file

@ -1,6 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
if type -p nix &>/dev/null ; then
echo "Aborting: Nix is already installed at $(type -p nix)"
exit
fi
# Configure Nix # Configure Nix
add_config() { add_config() {
echo "$1" | sudo tee -a /tmp/nix.conf >/dev/null echo "$1" | sudo tee -a /tmp/nix.conf >/dev/null