From f0508f0de8ce089801c441eabe024da1a30b7eda Mon Sep 17 00:00:00 2001 From: Ana Hobden Date: Fri, 13 Jan 2023 12:09:36 -0800 Subject: [PATCH] Add reinstall option --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++++ action.yml | 14 +++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d83523..71d57db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,21 @@ jobs: run: nix-instantiate -E 'builtins.currentTime' --eval if: success() || failure() shell: sh -l {0} + - name: Install Nix again (noop) + uses: ./ + with: + logger: pretty + log-directives: nix_installer=trace + backtrace: full + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Reinstall Nix + uses: ./ + with: + logger: pretty + log-directives: nix_installer=trace + backtrace: full + github-token: ${{ secrets.GITHUB_TOKEN }} + reinstall: true run-x86_64-darwin: name: Run x86_64 Darwin @@ -71,4 +86,19 @@ jobs: run: nix-instantiate -E 'builtins.currentTime' --eval if: success() || failure() shell: zsh --login --interactive {0} + - name: Install Nix again (noop) + uses: ./ + with: + logger: pretty + log-directives: nix_installer=trace + backtrace: full + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Reinstall Nix + uses: ./ + with: + logger: pretty + log-directives: nix_installer=trace + backtrace: full + github-token: ${{ secrets.GITHUB_TOKEN }} + reinstall: true \ No newline at end of file diff --git a/action.yml b/action.yml index c6fb830..86c5b70 100644 --- a/action.yml +++ b/action.yml @@ -2,7 +2,7 @@ name: Nix Installer branding: icon: 'box' color: 'purple' -description: An experimental Nix installer using `nix-install` +description: Install Nix inputs: planner: description: A planner to use @@ -75,6 +75,8 @@ inputs: nix-installer-branch: description: The branch of `nix-installer` to use required: false + reinstall: + description: Force a reinstall if the runs: using: composite @@ -82,6 +84,16 @@ runs: - name: Install Nix shell: bash run: | + if [ -f "/nix/receipt.json" ]; then + if [ -n "${{ inputs.reinstall }}" ]; then + /nix/nix-installer uninstall --no-confirm + else + echo "Nix was already installed, using existing install" + exit 0 + fi + + fi + if [ -n "${{ inputs.nix-installer-tag }}" ]; then export NIX_INSTALLER_TAG=${{ inputs.tag }} echo "Set NIX_INSTALLER_TAG=$NIX_INSTALLER_TAG"