mirror of
https://codeberg.org/icewind/mill-scale.git
synced 2026-06-03 18:04:09 +02:00
parent
823fb3493c
commit
4cd19c5267
1 changed files with 78 additions and 1 deletions
79
README.md
79
README.md
|
|
@ -30,6 +30,25 @@ Included checks:
|
|||
}
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
(Native) build dependencies can be specified with the following
|
||||
|
||||
```nix
|
||||
{
|
||||
# ...
|
||||
outputs = { mill-scale, ... }: mill-scale ./. {
|
||||
nativeBuildInputs = pkgs: [pkgs.libfoo];
|
||||
buildInputs = pkgs: [pkgs.libbar];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Additionally, dependencies for the following crates should be automatically detected
|
||||
|
||||
- openssl
|
||||
- udev
|
||||
|
||||
## Usage with GitHub Actions
|
||||
|
||||
### Single runner
|
||||
|
|
@ -71,7 +90,7 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v27
|
||||
- id: set-matrix
|
||||
run: echo "matrix={\"check\":$(nix eval --json '.#checks.x86_64-linux' --apply 'builtins.attrNames')}" | tee $GITHUB_OUTPUT
|
||||
run: echo "matrix={\"check\":$(nix eval --json '.#checks.x86_64-linux' --apply 'builtins.attrNames')}" | tee -a $GITHUB_OUTPUT
|
||||
|
||||
checks:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
@ -87,6 +106,64 @@ jobs:
|
|||
- run: nix build .#checks.x86_64-linux.${{ matrix.check }}
|
||||
```
|
||||
|
||||
## Cross-compiling
|
||||
|
||||
Cross-compiling can be enabled with the following
|
||||
|
||||
```nix
|
||||
{
|
||||
# ...
|
||||
outputs = { mill-scale, ... }: mill-scale ./. {
|
||||
crossTargets = [
|
||||
"x86_64-unknown-linux-musl"
|
||||
"x86_64-pc-windows-gnu"
|
||||
];
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
This adds cross-compiled package with the same name as the target to the `packages`.
|
||||
|
||||
### Cross-compiling with GitHub Action
|
||||
|
||||
A `lib.crossMatrix` flake output is provided to help with setting up cross-compiling in CI.
|
||||
|
||||
This contains a list of targets and the binary suffix (e.g. `.exe`) for each target.
|
||||
|
||||
```yaml
|
||||
on: [push, pull_request]
|
||||
|
||||
name: CI
|
||||
|
||||
jobs:
|
||||
matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
cross-matrix: ${{ steps.set-matrix.outputs.cross-matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v27
|
||||
- id: set-matrix
|
||||
run: |
|
||||
echo "cross-matrix={\"include\":$(nix eval --json '.#lib.crossMatrix')}" | tee -a $GITHUB_OUTPUT
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [matrix]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{fromJson(needs.matrix.outputs.cross-matrix)}}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v27
|
||||
# insert cache setup here
|
||||
- run: nix build .#${{ matrix.target }}
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: crate-name-${{ matrix.target }}
|
||||
path: result/bin/crate-name${{ matrix.binary-suffix }}
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
This flake is based on [flakelight-rust](https://github.com/accelbread/flakelight-rust), credit for most ideas got to accelbread.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue