nix.yml

 1name: "Nix build"
 2
 3on:
 4  workflow_call:
 5    inputs:
 6      flake-output:
 7        type: string
 8        default: "default"
 9      cachix-filter:
10        type: string
11        default: ""
12
13jobs:
14  nix-build:
15    timeout-minutes: 60
16    name: (${{ matrix.system.os }}) Nix Build
17    continue-on-error: true # TODO: remove when we want this to start blocking CI
18    strategy:
19      fail-fast: false
20      matrix:
21        system:
22          - os: x86 Linux
23            runner: namespace-profile-16x32-ubuntu-2204
24            install_nix: true
25          - os: arm Mac
26            runner: [macOS, ARM64, test]
27            install_nix: false
28    if: github.repository_owner == 'zed-industries'
29    runs-on: ${{ matrix.system.runner }}
30    env:
31      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
32      ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
33      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
34      GIT_LFS_SKIP_SMUDGE: 1 # breaks the livekit rust sdk examples which we don't actually depend on
35    steps:
36      - name: Checkout repo
37        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
38        with:
39          clean: false
40
41      # on our macs we manually install nix. for some reason the cachix action is running
42      # under a non-login /bin/bash shell which doesn't source the proper script to add the
43      # nix profile to PATH, so we manually add them here
44      - name: Set path
45        if: ${{ ! matrix.system.install_nix }}
46        run: |
47          echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
48          echo "/Users/administrator/.nix-profile/bin" >> "$GITHUB_PATH"
49
50      - uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # v31
51        if: ${{ matrix.system.install_nix }}
52        with:
53          github_access_token: ${{ secrets.GITHUB_TOKEN }}
54
55      - uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
56        with:
57          name: zed
58          authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
59          pushFilter: "${{ inputs.cachix-filter }}"
60          cachixArgs: "-v"
61
62      - run: nix build .#${{ inputs.flake-output }} -L --accept-flake-config
63
64      - name: Limit /nix/store to 50GB on macs
65        if: ${{ ! matrix.system.install_nix }}
66        run: |
67          if [ "$(du -sm /nix/store | cut -f1)" -gt 50000 ]; then
68            nix-collect-garbage -d || true
69          fi