|
4 | 4 | dogfood: |
5 | 5 | description: "Whether to use Nix installed from the latest artifact from master branch" |
6 | 6 | required: true # Be explicit about the fact that we are using unreleased artifacts |
| 7 | + experimental-installer: |
| 8 | + description: "Whether to use the experimental installer to install Nix" |
| 9 | + default: false |
7 | 10 | extra_nix_config: |
8 | 11 | description: "Gets appended to `/etc/nix/nix.conf` if passed." |
9 | 12 | install_url: |
@@ -37,14 +40,55 @@ runs: |
37 | 40 |
|
38 | 41 | gh run download "$RUN_ID" --repo "$DOGFOOD_REPO" -n "$INSTALLER_ARTIFACT" -D "$INSTALLER_DOWNLOAD_DIR" |
39 | 42 | echo "installer-path=file://$INSTALLER_DOWNLOAD_DIR" >> "$GITHUB_OUTPUT" |
| 43 | + TARBALL_PATH="$(find "$INSTALLER_DOWNLOAD_DIR" -name 'nix*.tar.xz' -print | head -n 1)" |
| 44 | + echo "tarball-path=file://$TARBALL_PATH" >> "$GITHUB_OUTPUT" |
40 | 45 |
|
41 | 46 | echo "::notice ::Dogfooding Nix installer from master (https://github.com/$DOGFOOD_REPO/actions/runs/$RUN_ID)" |
42 | 47 | env: |
43 | 48 | GH_TOKEN: ${{ inputs.github_token }} |
44 | 49 | DOGFOOD_REPO: "NixOS/nix" |
| 50 | + - name: "Download experimental installer" |
| 51 | + shell: bash |
| 52 | + id: download-experimental-nix-installer |
| 53 | + if: ${{ inputs.experimental-installer == 'true' }} |
| 54 | + run: | |
| 55 | + if [ "$RUNNER_OS" == "Linux" ]; then |
| 56 | + INSTALLER_OS="linux" |
| 57 | + elif [ "$RUNNER_OS" == "macOS" ]; then |
| 58 | + INSTALLER_OS="darwin" |
| 59 | + else |
| 60 | + echo "::error ::Unsupported RUNNER_OS: $RUNNER_OS" |
| 61 | + fi |
| 62 | +
|
| 63 | + if [ "$RUNNER_ARCH" == "X64" ]; then |
| 64 | + INSTALLER_ARCH="x86_64" |
| 65 | + elif [ "$RUNNER_ARCH" == "ARM64" ]; then |
| 66 | + INSTALLER_ARCH="aarch64" |
| 67 | + else |
| 68 | + echo "::error ::Unsupported RUNNER_ARCH: $RUNNER_ARCH" |
| 69 | + fi |
| 70 | +
|
| 71 | + EXPERIMENTAL_INSTALLER_ARTIFACT="nix-installer-$INSTALLER_ARCH-$INSTALLER_OS" |
| 72 | + EXPERIMENTAL_INSTALLER_PATH="$GITHUB_WORKSPACE/$EXPERIMENTAL_INSTALLER_ARTIFACT" |
| 73 | + # TODO: This uses the latest release. It should probably be pinned, or dogfood the experimental repo's default branch - similar to the above |
| 74 | + gh release download -R "$EXPERIMENTAL_INSTALLER_REPO" -D "$EXPERIMENTAL_INSTALLER_PATH" -p "$EXPERIMENTAL_INSTALLER_ARTIFACT" -p "nix-installer.sh" |
| 75 | +
|
| 76 | + echo "installer-path=$EXPERIMENTAL_INSTALLER_PATH" >> "$GITHUB_OUTPUT" |
| 77 | +
|
| 78 | + echo "::notice Using experimental installer from $EXPERIMENTAL_INSTALLER_REPO (https://github.com/$EXPERIMENTAL_INSTALLER_REPO)" |
| 79 | + env: |
| 80 | + GH_TOKEN: ${{ inputs.github_token }} |
| 81 | + EXPERIMENTAL_INSTALLER_REPO: "NixOS/experimental-nix-installer" |
45 | 82 | - uses: cachix/install-nix-action@c134e4c9e34bac6cab09cf239815f9339aaaf84e # v31.5.1 |
| 83 | + if: ${{ inputs.experimental-installer != 'true' }} |
46 | 84 | with: |
47 | 85 | # Ternary operator in GHA: https://www.github.com/actions/runner/issues/409#issuecomment-752775072 |
48 | 86 | install_url: ${{ inputs.dogfood == 'true' && format('{0}/install', steps.download-nix-installer.outputs.installer-path) || inputs.install_url }} |
49 | 87 | install_options: ${{ inputs.dogfood == 'true' && format('--tarball-url-prefix {0}', steps.download-nix-installer.outputs.installer-path) || '' }} |
50 | 88 | extra_nix_config: ${{ inputs.extra_nix_config }} |
| 89 | + - uses: DeterminateSystems/nix-installer-action@786fff0690178f1234e4e1fe9b536e94f5433196 # v20 |
| 90 | + if: ${{ inputs.experimental-installer == 'true' }} |
| 91 | + with: |
| 92 | + diagnostic-endpoint: "" |
| 93 | + local-root: ${{ steps.download-experimental-nix-installer.outputs.installer-path }} |
| 94 | + nix-package-url: ${{ inputs.dogfood && steps.download-nix-installer.outputs.tarball-path || '' }} |
0 commit comments