|
| 1 | +name: "Build and populate cache" |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - master |
| 8 | + schedule: |
| 9 | + # rebuild everyday at 2:51 |
| 10 | + # TIP: Choose a random time here so not all repositories are build at once: |
| 11 | + # https://www.random.org/clock-times/?num=1&earliest=01%3A00&latest=08%3A00&interval=5&format=html&rnd=new |
| 12 | + - cron: '51 2 * * *' |
| 13 | + workflow_dispatch: |
| 14 | +jobs: |
| 15 | + tests: |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + # Set this to notify the global nur package registry that changes are |
| 19 | + # available. |
| 20 | + # |
| 21 | + # The repo name as used in |
| 22 | + # https://github.com/nix-community/NUR/blob/master/repos.json |
| 23 | + nurRepo: |
| 24 | + - <YOUR_REPO_NAME> |
| 25 | + # Set this to cache your build results in cachix for faster builds |
| 26 | + # in CI and for everyone who uses your cache. |
| 27 | + # |
| 28 | + # Format: Your cachix cache host name without the ".cachix.org" suffix. |
| 29 | + # Example: mycache (for mycache.cachix.org) |
| 30 | + # |
| 31 | + # For this to work, you also need to set the CACHIX_SIGNING_KEY or |
| 32 | + # CACHIX_AUTH_TOKEN secret in your repository secrets settings in |
| 33 | + # Github found at |
| 34 | + # https://github.com/<your_githubname>/nur-packages/settings/secrets |
| 35 | + cachixName: |
| 36 | + - <YOUR_CACHIX_NAME> |
| 37 | + nixPath: |
| 38 | + - nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixpkgs-unstable.tar.gz |
| 39 | + - nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixos-unstable.tar.gz |
| 40 | + - nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/heads/nixos-25.11.tar.gz |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - name: Checkout repository |
| 44 | + uses: actions/checkout@v5 |
| 45 | + - name: Install nix |
| 46 | + uses: cachix/install-nix-action@v31 |
| 47 | + with: |
| 48 | + nix_path: "${{ matrix.nixPath }}" |
| 49 | + extra_nix_config: | |
| 50 | + experimental-features = nix-command flakes |
| 51 | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} |
| 52 | + - name: Show nixpkgs version |
| 53 | + run: nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version' |
| 54 | + - name: Setup cachix |
| 55 | + uses: cachix/cachix-action@v16 |
| 56 | + # Don't replace <YOUR_CACHIX_NAME> here! |
| 57 | + if: ${{ matrix.cachixName != '<YOUR_CACHIX_NAME>' }} |
| 58 | + with: |
| 59 | + name: ${{ matrix.cachixName }} |
| 60 | + signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' |
| 61 | + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' |
| 62 | + - name: Check evaluation |
| 63 | + run: | |
| 64 | + nix-env -f . -qa \* --meta --xml \ |
| 65 | + --allowed-uris https://static.rust-lang.org \ |
| 66 | + --option restrict-eval true \ |
| 67 | + --option allow-import-from-derivation true \ |
| 68 | + --drv-path --show-trace \ |
| 69 | + -I nixpkgs=$(nix-instantiate --find-file nixpkgs) \ |
| 70 | + -I $PWD |
| 71 | + - name: Build nix packages |
| 72 | + run: nix shell -f '<nixpkgs>' nix-build-uncached -c nix-build-uncached ci.nix -A cacheOutputs |
| 73 | + - name: Trigger NUR update |
| 74 | + # Don't replace <YOUR_REPO_NAME> here! |
| 75 | + if: ${{ matrix.nurRepo != '<YOUR_REPO_NAME>' }} |
| 76 | + run: curl -XPOST "https://nur-update.nix-community.org/update?repo=${{ matrix.nurRepo }}" |
0 commit comments