|
5 | 5 | flake-utils.url = "github:numtide/flake-utils"; |
6 | 6 | pre-commit-hooks.url = "github:cachix/git-hooks.nix"; |
7 | 7 | workflow-parts.url = "github:valeratrades/.github?dir=.github/workflows/nix-parts"; |
| 8 | + hooks.url = "github:valeratrades/.github?dir=hooks"; |
8 | 9 | }; |
9 | 10 |
|
10 | | - outputs = { nixpkgs, rust-overlay, flake-utils, pre-commit-hooks, workflow-parts, ... }: |
| 11 | + outputs = { nixpkgs, rust-overlay, flake-utils, pre-commit-hooks, workflow-parts, hooks, ... }: |
11 | 12 | flake-utils.lib.eachDefaultSystem (system: |
12 | 13 | let |
13 | 14 | overlays = builtins.trace "flake.nix sourced" [ (import rust-overlay) ]; |
|
18 | 19 | pre-commit-check = pre-commit-hooks.lib.${system}.run { |
19 | 20 | src = ./.; |
20 | 21 | hooks = { |
21 | | - nixpkgs-fmt.enable = true; |
| 22 | + treefmt = { |
| 23 | + enable = true; |
| 24 | + settings = { |
| 25 | + #BUG: this option does NOTHING |
| 26 | + fail-on-change = false; # that's GHA's job, pre-commit hooks stricty *do* |
| 27 | + formatters = with pkgs; [ |
| 28 | + nixpkgs-fmt |
| 29 | + ]; |
| 30 | + }; |
| 31 | + }; |
22 | 32 | }; |
23 | 33 | }; |
24 | 34 | }; |
|
28 | 38 | packages = |
29 | 39 | let |
30 | 40 | manifest = (pkgs.lib.importTOML ./Cargo.toml).package; |
| 41 | + rust = (pkgs.rust-bin.fromRustupToolchainFile ./.cargo/rust-toolchain.toml); |
| 42 | + rustc = rust; |
| 43 | + cargo = rust; |
| 44 | + stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv; |
| 45 | + rustPlatform = pkgs.makeRustPlatform { |
| 46 | + inherit rustc cargo stdenv; |
| 47 | + }; |
31 | 48 | in |
32 | 49 | { |
33 | | - default = pkgs.rustPlatform.buildRustPackage rec { |
| 50 | + default = rustPlatform.buildRustPackage rec { |
34 | 51 | pname = manifest.name; |
35 | 52 | version = manifest.version; |
36 | 53 |
|
|
47 | 64 | }; |
48 | 65 |
|
49 | 66 | devShells.default = with pkgs; mkShell { |
| 67 | + inherit stdenv; |
50 | 68 | shellHook = checks.pre-commit-check.shellHook + '' |
51 | 69 | rm -f ./.github/workflows/errors.yml; cp ${workflowContents.errors} ./.github/workflows/errors.yml |
52 | 70 | rm -f ./.github/workflows/warnings.yml; cp ${workflowContents.warnings} ./.github/workflows/warnings.yml |
| 71 | +
|
| 72 | + cargo -Zscript -q ${hooks.appendCustom} ./.git/hooks/pre-commit |
| 73 | + cp -f ${(import hooks.treefmt {inherit pkgs;})} ./.treefmt.toml |
53 | 74 | ''; |
54 | | - stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv; |
55 | 75 | packages = [ |
56 | 76 | mold-wrapped |
57 | 77 | openssl |
|
0 commit comments