Skip to content

Commit 9c13908

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

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ 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:
@@ -37,14 +40,55 @@ runs:
3740
3841
gh run download "$RUN_ID" --repo "$DOGFOOD_REPO" -n "$INSTALLER_ARTIFACT" -D "$INSTALLER_DOWNLOAD_DIR"
3942
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"
4045
4146
echo "::notice ::Dogfooding Nix installer from master (https://github.com/$DOGFOOD_REPO/actions/runs/$RUN_ID)"
4247
env:
4348
GH_TOKEN: ${{ inputs.github_token }}
4449
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"
4582
- uses: cachix/install-nix-action@c134e4c9e34bac6cab09cf239815f9339aaaf84e # v31.5.1
83+
if: ${{ inputs.experimental-installer != 'true' }}
4684
with:
4785
# Ternary operator in GHA: https://www.github.com/actions/runner/issues/409#issuecomment-752775072
4886
install_url: ${{ inputs.dogfood == 'true' && format('{0}/install', steps.download-nix-installer.outputs.installer-path) || inputs.install_url }}
4987
install_options: ${{ inputs.dogfood == 'true' && format('--tarball-url-prefix {0}', steps.download-nix-installer.outputs.installer-path) || '' }}
5088
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 || '' }}

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
required: false
1212
default: true
1313
type: boolean
14+
experimental-installer:
15+
description: 'Use the experimental installer'
16+
required: false
17+
default: false
18+
type: boolean
1419

1520
permissions: read-all
1621

@@ -24,6 +29,7 @@ jobs:
2429
- uses: ./.github/actions/install-nix-action
2530
with:
2631
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
32+
experimental-installer: ${{ github.event_name == 'workflow_dispatch' && inputs.experimental-installer || false }}
2733
extra_nix_config:
2834
experimental-features = nix-command flakes
2935
github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -63,6 +69,7 @@ jobs:
6369
with:
6470
github_token: ${{ secrets.GITHUB_TOKEN }}
6571
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
72+
experimental-installer: ${{ github.event_name == 'workflow_dispatch' && inputs.experimental-installer || false }}
6673
# The sandbox would otherwise be disabled by default on Darwin
6774
extra_nix_config: "sandbox = true"
6875
- uses: DeterminateSystems/magic-nix-cache-action@main
@@ -220,6 +227,7 @@ jobs:
220227
- uses: ./.github/actions/install-nix-action
221228
with:
222229
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
230+
experimental-installer: ${{ github.event_name == 'workflow_dispatch' && inputs.experimental-installer || false }}
223231
extra_nix_config:
224232
experimental-features = nix-command flakes
225233
github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -251,6 +259,7 @@ jobs:
251259
- uses: ./.github/actions/install-nix-action
252260
with:
253261
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
262+
experimental-installer: ${{ github.event_name == 'workflow_dispatch' && inputs.experimental-installer || false }}
254263
extra_nix_config:
255264
experimental-features = nix-command flakes
256265
github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -272,6 +281,7 @@ jobs:
272281
with:
273282
github_token: ${{ secrets.GITHUB_TOKEN }}
274283
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
284+
experimental-installer: ${{ github.event_name == 'workflow_dispatch' && inputs.experimental-installer || false }}
275285
extra_nix_config: |
276286
experimental-features = flakes nix-command ca-derivations impure-derivations
277287
max-jobs = 1

0 commit comments

Comments
 (0)