|
| 1 | +--- |
| 2 | +name: nix-ci |
| 3 | +description: Use this when setting up CI for a GitHub repository — offers GitHub Actions or Vira depending on the project |
| 4 | +--- |
| 5 | + |
| 6 | +# CI Setup |
| 7 | + |
| 8 | +When the user asks to set up CI, use the **Ask tool** to prompt them to choose: |
| 9 | + |
| 10 | +1. **GitHub public runners** — CI via GitHub Actions |
| 11 | +2. **Vira self-hosted** — self-hosted CI using [Vira](https://vira.nixos.asia) |
| 12 | + |
| 13 | +## Option 1: GitHub Actions |
| 14 | + |
| 15 | +Use the [install-nix](https://github.com/nixbuild/nix-quick-install-action) action (avoid DetSys actions) and invoke Vira to build: |
| 16 | + |
| 17 | +```yaml |
| 18 | +# .github/workflows/ci.yml |
| 19 | +name: CI |
| 20 | +on: [push, pull_request] |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + os: [ubuntu-latest, macos-latest] |
| 26 | + runs-on: ${{ matrix.os }} |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + - uses: nixbuild/nix-quick-install-action@v34 |
| 30 | + - run: nix profile install github:juspay/vira |
| 31 | + - run: vira ci |
| 32 | +``` |
| 33 | +
|
| 34 | +## Option 2: Vira Self-Hosted |
| 35 | +
|
| 36 | +Vira is already running and pointed at the repo. Create a `vira.hs` file in the repo root to configure the build pipeline. Refer to the **[Vira configuration docs](https://vira.nixos.asia/config)** for the DSL format. |
| 37 | + |
| 38 | +### Rules for generating `vira.hs` |
| 39 | + |
| 40 | +- If the repo is on **GitHub**, set `signoff.enable = True` |
| 41 | +- If **multiple `flake.nix` files** exist (e.g., in subdirectories), add all of them to `build.flakes` with appropriate `overrideInputs` settings |
| 42 | +- Leave `cache.url = Nothing` with a comment `-- TODO: configure Attic cache URL` |
| 43 | +- Use the **Ask tool** to ask the user whether `build.systems` should be set to `["x86_64-linux", "aarch64-darwin"]` for multi-platform builds |
| 44 | + |
| 45 | +After creating `vira.hs`, run `vira ci -b` to verify the configuration. |
| 46 | + |
0 commit comments