Skip to content

Commit 11110b7

Browse files
committed
_
1 parent 94c3526 commit 11110b7

File tree

4 files changed

+51
-5
lines changed

4 files changed

+51
-5
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/nix/store/kgi0468mzxv9pszs5xsp3irdphpfzg53-pre-commit-config.json
1+
/nix/store/vvcxaq0sx84qgsgv7vxr187zwxn6qniw-pre-commit-config.json

.treefmt.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[formatter.nix]
2+
command = "nixpkgs-fmt"
3+
includes = ["*.nix"]
4+
5+
[formatter.rust]
6+
command = "rustfmt"
7+
includes = ["*.rs"]
8+
options = ["--edition", "2024"]

flake.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
flake-utils.url = "github:numtide/flake-utils";
66
pre-commit-hooks.url = "github:cachix/git-hooks.nix";
77
workflow-parts.url = "github:valeratrades/.github?dir=.github/workflows/nix-parts";
8+
hooks.url = "github:valeratrades/.github?dir=hooks";
89
};
910

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, ... }:
1112
flake-utils.lib.eachDefaultSystem (system:
1213
let
1314
overlays = builtins.trace "flake.nix sourced" [ (import rust-overlay) ];
@@ -18,7 +19,16 @@
1819
pre-commit-check = pre-commit-hooks.lib.${system}.run {
1920
src = ./.;
2021
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+
};
2232
};
2333
};
2434
};
@@ -28,9 +38,16 @@
2838
packages =
2939
let
3040
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+
};
3148
in
3249
{
33-
default = pkgs.rustPlatform.buildRustPackage rec {
50+
default = rustPlatform.buildRustPackage rec {
3451
pname = manifest.name;
3552
version = manifest.version;
3653

@@ -47,11 +64,14 @@
4764
};
4865

4966
devShells.default = with pkgs; mkShell {
67+
inherit stdenv;
5068
shellHook = checks.pre-commit-check.shellHook + ''
5169
rm -f ./.github/workflows/errors.yml; cp ${workflowContents.errors} ./.github/workflows/errors.yml
5270
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
5374
'';
54-
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv;
5575
packages = [
5676
mold-wrapped
5777
openssl

0 commit comments

Comments
 (0)