Skip to content

Commit 6b9e0a6

Browse files
committed
ci: enable use of the experimental installer
1 parent 5e17a3f commit 6b9e0a6

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/actions/install-nix-action/action.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ inputs:
44
dogfood:
55
description: "Whether to use Nix installed from the latest artifact from master branch"
66
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
710
extra_nix_config:
811
description: "Gets appended to `/etc/nix/nix.conf` if passed."
912
install_url:
1013
description: "URL of the Nix installer"
1114
required: false
1215
default: "https://releases.nixos.org/nix/nix-2.30.2/install"
16+
tarball_url:
17+
description: "URL of the Nix tarball to use with the experimental installer"
18+
required: false
1319
github_token:
1420
description: "Github token"
1521
required: true
@@ -37,14 +43,57 @@ runs:
3743
3844
gh run download "$RUN_ID" --repo "$DOGFOOD_REPO" -n "$INSTALLER_ARTIFACT" -D "$INSTALLER_DOWNLOAD_DIR"
3945
echo "installer-path=file://$INSTALLER_DOWNLOAD_DIR" >> "$GITHUB_OUTPUT"
46+
TARBALL_PATH="$(find "$INSTALLER_DOWNLOAD_DIR" -name 'nix*.tar.xz' -print | head -n 1)"
47+
echo "tarball-path=file://$TARBALL_PATH" >> "$GITHUB_OUTPUT"
4048
4149
echo "::notice ::Dogfooding Nix installer from master (https://github.com/$DOGFOOD_REPO/actions/runs/$RUN_ID)"
4250
env:
4351
GH_TOKEN: ${{ inputs.github_token }}
4452
DOGFOOD_REPO: "NixOS/nix"
53+
- name: "Download experimental installer"
54+
shell: bash
55+
id: download-experimental-nix-installer
56+
if: ${{ inputs.experimental-installer == 'true' }}
57+
run: |
58+
if [ "$RUNNER_OS" == "Linux" ]; then
59+
INSTALLER_OS="linux"
60+
elif [ "$RUNNER_OS" == "macOS" ]; then
61+
INSTALLER_OS="darwin"
62+
else
63+
echo "::error ::Unsupported RUNNER_OS: $RUNNER_OS"
64+
fi
65+
66+
if [ "$RUNNER_ARCH" == "X64" ]; then
67+
INSTALLER_ARCH="x86_64"
68+
elif [ "$RUNNER_ARCH" == "ARM64" ]; then
69+
INSTALLER_ARCH="aarch64"
70+
else
71+
echo "::error ::Unsupported RUNNER_ARCH: $RUNNER_ARCH"
72+
fi
73+
74+
EXPERIMENTAL_INSTALLER_ARTIFACT="nix-installer-$INSTALLER_ARCH-$INSTALLER_OS"
75+
EXPERIMENTAL_INSTALLER_PATH="$GITHUB_WORKSPACE/$EXPERIMENTAL_INSTALLER_ARTIFACT"
76+
# TODO: This uses the latest release. It should probably be pinned, or dogfood the experimental repo's default branch - similar to the above
77+
gh release download -R "$EXPERIMENTAL_INSTALLER_REPO" -D "$EXPERIMENTAL_INSTALLER_PATH" -p "nix-installer.sh" -p "$EXPERIMENTAL_INSTALLER_ARTIFACT"
78+
chmod +x "$EXPERIMENTAL_INSTALLER_PATH/$EXPERIMENTAL_INSTALLER_ARTIFACT"
79+
80+
echo "installer-path=$EXPERIMENTAL_INSTALLER_PATH" >> "$GITHUB_OUTPUT"
81+
82+
echo "::notice Using experimental installer from $EXPERIMENTAL_INSTALLER_REPO (https://github.com/$EXPERIMENTAL_INSTALLER_REPO)"
83+
env:
84+
GH_TOKEN: ${{ inputs.github_token }}
85+
EXPERIMENTAL_INSTALLER_REPO: "NixOS/experimental-nix-installer"
4586
- uses: cachix/install-nix-action@c134e4c9e34bac6cab09cf239815f9339aaaf84e # v31.5.1
87+
if: ${{ inputs.experimental-installer != 'true' }}
4688
with:
4789
# Ternary operator in GHA: https://www.github.com/actions/runner/issues/409#issuecomment-752775072
4890
install_url: ${{ inputs.dogfood == 'true' && format('{0}/install', steps.download-nix-installer.outputs.installer-path) || inputs.install_url }}
4991
install_options: ${{ inputs.dogfood == 'true' && format('--tarball-url-prefix {0}', steps.download-nix-installer.outputs.installer-path) || '' }}
5092
extra_nix_config: ${{ inputs.extra_nix_config }}
93+
- uses: DeterminateSystems/nix-installer-action@786fff0690178f1234e4e1fe9b536e94f5433196 # v20
94+
if: ${{ inputs.experimental-installer == 'true' }}
95+
with:
96+
diagnostic-endpoint: ""
97+
local-root: ${{ steps.download-experimental-nix-installer.outputs.installer-path }}
98+
nix-package-url: ${{ inputs.dogfood == 'true' && steps.download-nix-installer.outputs.tarball-path || (inputs.tarball_url || '') }}
99+
extra-conf: ${{ inputs.extra_nix_config }}

0 commit comments

Comments
 (0)