mirror of
https://github.com/NixOS/nix
synced 2025-07-17 22:48:29 +02:00
ci: Dogfood Nix from master
This commit is contained in:
parent
e8314e69ab
commit
04f6974d2c
2 changed files with 59 additions and 5 deletions
50
.github/actions/install-nix-action/action.yaml
vendored
Normal file
50
.github/actions/install-nix-action/action.yaml
vendored
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
name: "Install Nix"
|
||||||
|
description: "Helper action for installing Nix with support for dogfooding from master"
|
||||||
|
inputs:
|
||||||
|
dogfood:
|
||||||
|
description: "Whether to use Nix installed from the latest artifact from master branch"
|
||||||
|
required: true # Be explicit about the fact that we are using unreleased artifacts
|
||||||
|
extra_nix_config:
|
||||||
|
description: "Gets appended to `/etc/nix/nix.conf` if passed."
|
||||||
|
install_url:
|
||||||
|
description: "URL of the Nix installer"
|
||||||
|
required: false
|
||||||
|
default: "https://releases.nixos.org/nix/nix-2.30.1/install"
|
||||||
|
github_token:
|
||||||
|
description: "Github token"
|
||||||
|
required: true
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: "Download nix install artifact from master"
|
||||||
|
shell: bash
|
||||||
|
id: download-nix-installer
|
||||||
|
if: ${{ inputs.dogfood }}
|
||||||
|
run: |
|
||||||
|
RUN_ID=$(gh run list --repo "$DOGFOOD_REPO" --workflow ci.yml --branch master --status success --json databaseId --jq ".[0].databaseId")
|
||||||
|
|
||||||
|
if [ "$RUNNER_OS" == "Linux" ]; then
|
||||||
|
INSTALLER_ARTIFACT="installer-linux"
|
||||||
|
elif [ "$RUNNER_OS" == "macOS" ]; then
|
||||||
|
INSTALLER_ARTIFACT="installer-darwin"
|
||||||
|
else
|
||||||
|
echo "::error ::Unsupported RUNNER_OS: $RUNNER_OS"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
INSTALLER_DOWNLOAD_DIR="$GITHUB_WORKSPACE/$INSTALLER_ARTIFACT"
|
||||||
|
mkdir -p "$INSTALLER_DOWNLOAD_DIR"
|
||||||
|
|
||||||
|
gh run download "$RUN_ID" --repo "$DOGFOOD_REPO" -n "$INSTALLER_ARTIFACT" -D "$INSTALLER_DOWNLOAD_DIR"
|
||||||
|
echo "installer-path=file://$INSTALLER_DOWNLOAD_DIR" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
echo "::notice ::Dogfooding Nix installer from master (https://github.com/$DOGFOOD_REPO/actions/runs/$RUN_ID)"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ inputs.github_token }}
|
||||||
|
DOGFOOD_REPO: "NixOS/nix"
|
||||||
|
- uses: cachix/install-nix-action@c134e4c9e34bac6cab09cf239815f9339aaaf84e # v31.5.1
|
||||||
|
with:
|
||||||
|
# Ternary operator in GHA: https://www.github.com/actions/runner/issues/409#issuecomment-752775072
|
||||||
|
install_url: ${{ inputs.dogfood && format('{0}/install', steps.download-nix-installer.outputs.installer-path) || inputs.install_url }}
|
||||||
|
install_options: ${{ inputs.dogfood && format('--tarball-url-prefix {0}', steps.download-nix-installer.outputs.installer-path) || '' }}
|
||||||
|
extra_nix_config: ${{ inputs.extra_nix_config }}
|
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
|
@ -13,10 +13,13 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: cachix/install-nix-action@v31
|
- uses: ./.github/actions/install-nix-action
|
||||||
with:
|
with:
|
||||||
install_url: "https://releases.nixos.org/nix/nix-2.29.1/install"
|
dogfood: true
|
||||||
- run: nix --experimental-features 'nix-command flakes' flake show --all-systems --json
|
extra_nix_config:
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- run: nix flake show --all-systems --json
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
strategy:
|
strategy:
|
||||||
|
@ -36,9 +39,10 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: cachix/install-nix-action@v31
|
- uses: ./.github/actions/install-nix-action
|
||||||
with:
|
with:
|
||||||
install_url: "https://releases.nixos.org/nix/nix-2.29.1/install"
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
dogfood: true
|
||||||
# The sandbox would otherwise be disabled by default on Darwin
|
# The sandbox would otherwise be disabled by default on Darwin
|
||||||
extra_nix_config: |
|
extra_nix_config: |
|
||||||
sandbox = true
|
sandbox = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue