# Generated from xtask::workflows::nix_build
# Rebuild with `cargo xtask workflows`.
name: nix_build
env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: '1'
  CARGO_INCREMENTAL: '0'
on:
  pull_request:
    branches:
    - '**'
    paths:
    - nix/**
    - flake.*
    - Cargo.*
    - rust-toolchain.toml
    - .cargo/config.toml
  push:
    branches:
    - main
    - v[0-9]+.[0-9]+.x
    paths:
    - nix/**
    - flake.*
    - Cargo.*
    - rust-toolchain.toml
    - .cargo/config.toml
  workflow_call: {}
jobs:
  build_nix_linux_x86_64:
    if: github.repository_owner == 'zed-industries'
    runs-on: namespace-profile-32x64-ubuntu-2004
    env:
      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
      ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
      GIT_LFS_SKIP_SMUDGE: '1'
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: nix_build::install_nix
      uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f
      with:
        github_access_token: ${{ secrets.GITHUB_TOKEN }}
    - name: nix_build::cachix_action
      uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad
      with:
        name: zed
        authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
        cachixArgs: -v
        pushFilter: -zed-editor-[0-9.]*-nightly
    - name: nix_build::build
      run: nix build .#debug -L --accept-flake-config
      shell: bash -euxo pipefail {0}
    timeout-minutes: 60
    continue-on-error: true
  build_nix_mac_aarch64:
    if: github.repository_owner == 'zed-industries'
    runs-on: self-mini-macos
    env:
      ZED_CLIENT_CHECKSUM_SEED: ${{ secrets.ZED_CLIENT_CHECKSUM_SEED }}
      ZED_MINIDUMP_ENDPOINT: ${{ secrets.ZED_SENTRY_MINIDUMP_ENDPOINT }}
      ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON: ${{ secrets.ZED_CLOUD_PROVIDER_ADDITIONAL_MODELS_JSON }}
      GIT_LFS_SKIP_SMUDGE: '1'
    steps:
    - name: steps::checkout_repo
      uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
      with:
        clean: false
    - name: nix_build::set_path
      run: |
        echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
        echo "/Users/administrator/.nix-profile/bin" >> "$GITHUB_PATH"
      shell: bash -euxo pipefail {0}
    - name: nix_build::cachix_action
      uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad
      with:
        name: zed
        authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
        cachixArgs: -v
        pushFilter: -zed-editor-[0-9.]*-nightly
    - name: nix_build::build
      run: nix build .#debug -L --accept-flake-config
      shell: bash -euxo pipefail {0}
    - name: nix_build::limit_store
      run: |-
        if [ "$(du -sm /nix/store | cut -f1)" -gt 50000 ]; then
            nix-collect-garbage -d || true
        fi
      shell: bash -euxo pipefail {0}
    timeout-minutes: 60
    continue-on-error: true
concurrency:
  group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.ref_name == 'main' && github.sha || 'anysha' }}
  cancel-in-progress: true
