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: buildjet-16vcpu-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_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
33      GIT_LFS_SKIP_SMUDGE: 1 # breaks the livekit rust sdk examples which we don't actually depend on
34    steps:
35      - name: Checkout repo
36        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
37        with:
38          clean: false
39
40      # on our macs we manually install nix. for some reason the cachix action is running
41      # under a non-login /bin/bash shell which doesn't source the proper script to add the
42      # nix profile to PATH, so we manually add them here
43      - name: Set path
44        if: ${{ ! matrix.system.install_nix }}
45        run: |
46          echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
47          echo "/Users/administrator/.nix-profile/bin" >> "$GITHUB_PATH"
48
49      - uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # v31
50        if: ${{ matrix.system.install_nix }}
51        with:
52          github_access_token: ${{ secrets.GITHUB_TOKEN }}
53
54      - uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
55        with:
56          name: zed
57          authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
58          pushFilter: "${{ inputs.cachix-filter }}"
59          cachixArgs: "-v"
60
61      - run: nix build .#${{ inputs.flake-output }} -L --accept-flake-config
62
63      - name: Limit /nix/store to 50GB on macs
64        if: ${{ ! matrix.system.install_nix }}
65        run: |
66          if [ "$(du -sm /nix/store | cut -f1)" -gt 50000 ]; then
67            nix-collect-garbage -d || true
68          fi