mirror of
https://github.com/DeterminateSystems/nix-installer-action.git
synced 2025-01-11 06:42:19 +01:00
Ensure we still set GITHUB_PATH
Further improve logic
This commit is contained in:
parent
2ec668c456
commit
3c9332283c
1 changed files with 15 additions and 5 deletions
26
action.yml
26
action.yml
|
@ -76,7 +76,8 @@ inputs:
|
||||||
description: The branch of `nix-installer` to use
|
description: The branch of `nix-installer` to use
|
||||||
required: false
|
required: false
|
||||||
reinstall:
|
reinstall:
|
||||||
description: Force a reinstall if the
|
description: Force a reinstall if an existing installation is detected
|
||||||
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
|
@ -84,18 +85,27 @@ runs:
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [ -f "/nix/receipt.json" ]; then
|
if [ -f "/nix/receipt.json" ] && [ -f "/nix/nix-installer" ]; then
|
||||||
if [ -n "${{ inputs.reinstall }}" ]; then
|
if ([ -n "${{ inputs.nix-installer-revision }}" ] || [ -n "${{ inputs.nix-installer-branch }}" ]) && [ "${{ inputs.reinstall }}" != "true" ]; then
|
||||||
/nix/nix-installer uninstall --no-confirm
|
echo "When `nix-installer-revision` or `nix-installer-branch` are set the detection of existing installs (and versions) may be unreliable, `reinstall: true` should also be set"
|
||||||
else
|
|
||||||
echo "Nix was already installed, using existing install"
|
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${{ inputs.reinstall }}" ] && [ "${{ inputs.reinstall }}" == "true" ]; then
|
||||||
|
/nix/nix-installer uninstall --no-confirm
|
||||||
|
else
|
||||||
|
EXISTING_VERSION=$(/nix/nix-installer --version | awk '{ print $2 }')
|
||||||
|
if [ -n "${{ inputs.nix-installer-tag }}" ] && [ "${{ inputs.nix-installer-tag }}" != "$EXISTING_VERSION" ]; then
|
||||||
|
echo "`nix-installer` version mismatch, if attempting to upgrade to a new tag, use `reinstall: true`, you may want to back up your `/nix/store` first"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Nix was already installed, using existing install"
|
||||||
|
echo "/nix/var/nix/profiles/default/bin" >> $GITHUB_PATH
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${{ inputs.nix-installer-tag }}" ]; then
|
if [ -n "${{ inputs.nix-installer-tag }}" ]; then
|
||||||
export NIX_INSTALLER_TAG=${{ inputs.tag }}
|
export NIX_INSTALLER_TAG=${{ inputs.nix-installer-tag }}
|
||||||
echo "Set NIX_INSTALLER_TAG=$NIX_INSTALLER_TAG"
|
echo "Set NIX_INSTALLER_TAG=$NIX_INSTALLER_TAG"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue