|
| 1 | +name: Nix |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - '.github/workflows/nix.yml' |
| 9 | + - 'flake.*' |
| 10 | + - 'setup.cfg' |
| 11 | + - '*.nix' |
| 12 | + - '*.py' |
| 13 | + - '*.ini' |
| 14 | + pull_request: |
| 15 | + paths: |
| 16 | + - '.github/workflows/nix.yml' |
| 17 | + - 'flake.*' |
| 18 | + - 'setup.cfg' |
| 19 | + - '*.nix' |
| 20 | + - '*.py' |
| 21 | + - '*.ini' |
| 22 | + |
| 23 | +jobs: |
| 24 | + check: |
| 25 | + name: unitests |
| 26 | + runs-on: ubuntu-22.04 |
| 27 | + strategy: |
| 28 | + fail-fast: false |
| 29 | + matrix: |
| 30 | + python-version: |
| 31 | + - 39 |
| 32 | + - 310 |
| 33 | + - 311 |
| 34 | + nixpkgs: |
| 35 | + - unstable |
| 36 | + steps: |
| 37 | + - name: Checkout |
| 38 | + id: checkout |
| 39 | + uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - name: Install Nix |
| 42 | + id: install_nix |
| 43 | + uses: nixbuild/nix-quick-install-action@v28 |
| 44 | + |
| 45 | + - name: Check Nix Flake |
| 46 | + id: check |
| 47 | + env: |
| 48 | + NIXPKGS_ALLOW_BROKEN: 1 |
| 49 | + run: | |
| 50 | + nix flake show --impure |
| 51 | + #nix flake check --impure |
| 52 | +
|
| 53 | + - name: Restore and cache Nix store for python${{ matrix.python-version }}-nixpkgs-${{ matrix.nixpkgs }} |
| 54 | + uses: nix-community/cache-nix-action@v5 |
| 55 | + with: |
| 56 | + # restore and save a cache using this key |
| 57 | + primary-key: Nix-python${{ matrix.python-version }}-nixpkgs-${{ matrix.nixpkgs }}-${{ hashFiles('flake.*', '*.nix') }} |
| 58 | + # if there's no cache hit, restore a cache by this prefix |
| 59 | + restore-prefixes-first-match: Nix-python${{ matrix.python-version }}-${{ matrix.nixpkgs }}- |
| 60 | + # collect garbage until Nix store size (in bytes) is at most this number |
| 61 | + # before trying to save a new cache |
| 62 | + gc-max-store-size-linux: 1073741824 |
| 63 | + # do purge caches |
| 64 | + purge: true |
| 65 | + # purge all versions of the cache |
| 66 | + purge-prefixes: Nix-python${{ matrix.python-version }}-nixpkgs-${{ matrix.nixpkgs }}- |
| 67 | + # created more than 0 seconds ago relative to the start of the `Post Restore` phase |
| 68 | + purge-created: 0 |
| 69 | + # except the version with the `primary-key`, if it exists |
| 70 | + purge-primary-key: never |
| 71 | + |
| 72 | + - name: Prepare environment |
| 73 | + # The Nix package doesn't know how to do this part, unfortunately. |
| 74 | + run: | |
| 75 | + # Get some build environment dependencies and let them float on a |
| 76 | + # certain release branch. These aren't involved in the actual |
| 77 | + # package build (only in CI environment setup) so the fact that |
| 78 | + # they float shouldn't hurt reproducibility. |
| 79 | + #echo NIXPKGS=$(nix flake metadata | grep -E '[^\w]+nixpkgs-${{ matrix.nixpkgs }}[^\w]+:' | cut -d' ' -f2) >> $GITHUB_ENV |
| 80 | + echo NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/439ba0789ff84dddea64eb2d47a4a0d4887dbb1f.tar.gz >> $GITHUB_ENV |
| 81 | +
|
| 82 | + - name: Generate version |
| 83 | + # The Nix package doesn't know how to do this part, unfortunately. |
| 84 | + run: | |
| 85 | + nix-shell \ |
| 86 | + -p 'python3.withPackages (ps: [ ps.setuptools ])' \ |
| 87 | + --run 'python setup.py update_version' |
| 88 | +
|
| 89 | + - name: Build Package |
| 90 | + run: | |
| 91 | + nix build \ |
| 92 | + --verbose \ |
| 93 | + --print-build-logs \ |
| 94 | + --cores "$DEPENDENCY_CORES" \ |
| 95 | + --override-input nixpkgs "$NIXPKGS" \ |
| 96 | + .#python${{ matrix.python-version }}-tahoe-lafs |
0 commit comments