nix-ci.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. name: Nix CI
  2. on:
  3. workflow_dispatch: # allows manual triggering
  4. push:
  5. branches:
  6. - master
  7. paths: ['.github/workflows/nix-ci.yml', '**/flake.nix', '**/flake.lock', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal']
  8. pull_request:
  9. types: [opened, synchronize, reopened]
  10. paths: ['.github/workflows/nix-ci.yml', '**/flake.nix', '**/flake.lock', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal']
  11. concurrency:
  12. group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
  13. cancel-in-progress: true
  14. # Fine-grant permission
  15. # https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
  16. permissions:
  17. # https://github.com/DeterminateSystems/nix-installer-action?tab=readme-ov-file#with-flakehub
  18. id-token: write
  19. contents: read
  20. jobs:
  21. nix-eval:
  22. strategy:
  23. fail-fast: false
  24. matrix:
  25. os: [ ubuntu-latest, macos-latest ]
  26. runs-on: ${{ matrix.os }}
  27. steps:
  28. - name: Checkout repository
  29. uses: actions/checkout@v4
  30. - name: Install Nix
  31. uses: DeterminateSystems/nix-installer-action@v9
  32. with:
  33. github-token: ${{ secrets.GITHUB_TOKEN }}
  34. extra-conf: |
  35. extra-substituters = https://llama-cpp.cachix.org https://cuda-maintainers.cachix.org
  36. extra-trusted-public-keys = llama-cpp.cachix.org-1:H75X+w83wUKTIPSO1KWy9ADUrzThyGs8P5tmAbkWhQc= cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=
  37. - uses: DeterminateSystems/magic-nix-cache-action@v2
  38. with:
  39. upstream-cache: https://${{ matrix.cachixName }}.cachix.org
  40. - name: List all flake outputs
  41. run: nix flake show --all-systems
  42. - name: Show all output paths
  43. run: >
  44. nix run github:nix-community/nix-eval-jobs
  45. -- --gc-roots-dir gcroot
  46. --flake
  47. ".#packages.$(nix eval --raw --impure --expr builtins.currentSystem)"
  48. nix-build:
  49. strategy:
  50. fail-fast: false
  51. matrix:
  52. os: [ ubuntu-latest, macos-latest ]
  53. runs-on: ${{ matrix.os }}
  54. steps:
  55. - name: Checkout repository
  56. uses: actions/checkout@v4
  57. - name: Install Nix
  58. uses: DeterminateSystems/nix-installer-action@v9
  59. with:
  60. github-token: ${{ secrets.GITHUB_TOKEN }}
  61. extra-conf: |
  62. extra-substituters = https://llama-cpp.cachix.org https://cuda-maintainers.cachix.org
  63. extra-trusted-public-keys = llama-cpp.cachix.org-1:H75X+w83wUKTIPSO1KWy9ADUrzThyGs8P5tmAbkWhQc= cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=
  64. - uses: DeterminateSystems/magic-nix-cache-action@v2
  65. with:
  66. upstream-cache: https://${{ matrix.cachixName }}.cachix.org
  67. - name: Set-up cachix to push the results to
  68. uses: cachix/cachix-action@v13
  69. with:
  70. authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
  71. name: llama-cpp
  72. - name: Build
  73. run: >
  74. nix run github:Mic92/nix-fast-build
  75. -- --skip-cached --no-nom
  76. --flake
  77. ".#checks.$(nix eval --raw --impure --expr builtins.currentSystem)"