|
| 1 | +{ |
| 2 | + root, |
| 3 | + ... |
| 4 | +}: |
1 | 5 | { |
2 | 6 | perSystem = |
3 | 7 | { pkgs, ... }: |
| 8 | + let |
| 9 | + statixBuild = pkgs.statix-workspace.workspaceMembers.statix.build; |
| 10 | + src = pkgs.lib.fileset.toSource { |
| 11 | + inherit root; |
| 12 | + fileset = pkgs.lib.fileset.fileFilter ( |
| 13 | + file: |
| 14 | + pkgs.lib.any pkgs.lib.id [ |
| 15 | + (file.name == "Cargo.toml") |
| 16 | + (file.hasExt "rs") |
| 17 | + (file.hasExt "snap") |
| 18 | + ] |
| 19 | + ) root; |
| 20 | + }; |
| 21 | + in |
4 | 22 | { |
5 | 23 | treefmt.settings.global.excludes = [ "bin/tests/data/*.nix" ]; |
6 | | - checks.build = pkgs.statix; |
| 24 | + checks = { |
| 25 | + inherit (pkgs) statix; |
| 26 | + statix-tests = statixBuild.override { |
| 27 | + runTests = true; |
| 28 | + testPreRun = '' |
| 29 | + mkdir -p $TMPDIR/cargo-wrapper/bin |
| 30 | + cat > $TMPDIR/cargo-wrapper/bin/cargo << 'WRAPPER' |
| 31 | + #!/bin/sh |
| 32 | + if [ "$1" = "run" ] && [ "$2" = "--" ]; then |
| 33 | + shift 2 |
| 34 | + exec ${pkgs.statix}/bin/statix "$@" |
| 35 | + fi |
| 36 | + exec ${pkgs.cargo}/bin/cargo "$@" |
| 37 | + WRAPPER |
| 38 | + chmod +x $TMPDIR/cargo-wrapper/bin/cargo |
| 39 | + export PATH=$TMPDIR/cargo-wrapper/bin:${pkgs.cargo}/bin:$PATH |
| 40 | + export INSTA_SNAPSHOT_DIR=${root}/bin/tests/snapshots |
| 41 | + ''; |
| 42 | + }; |
| 43 | + clippy = pkgs.rustPlatform.buildRustPackage { |
| 44 | + pname = "statix-clippy"; |
| 45 | + version = "0.6.0-git"; |
| 46 | + src = pkgs.lib.fileset.toSource { |
| 47 | + inherit root; |
| 48 | + fileset = pkgs.lib.fileset.unions [ |
| 49 | + (pkgs.lib.fileset.fileFilter ( |
| 50 | + file: |
| 51 | + pkgs.lib.any pkgs.lib.id [ |
| 52 | + (file.name == "Cargo.toml") |
| 53 | + (file.hasExt "rs") |
| 54 | + (file.hasExt "snap") |
| 55 | + ] |
| 56 | + ) root) |
| 57 | + (root + "/Cargo.lock") |
| 58 | + ]; |
| 59 | + }; |
| 60 | + cargoLock.lockFile = root + "/Cargo.lock"; |
| 61 | + RUSTFLAGS = "-D warnings"; |
| 62 | + nativeBuildInputs = [ pkgs.clippy ]; |
| 63 | + buildPhase = "cargo clippy --all-targets --all-features"; |
| 64 | + installPhase = "touch $out"; |
| 65 | + doCheck = false; |
| 66 | + }; |
| 67 | + }; |
7 | 68 | }; |
8 | 69 | } |
0 commit comments