Skip to content

Commit

Permalink
rust: Add treefmt-nix
Browse files Browse the repository at this point in the history
  • Loading branch information
akirak committed Oct 8, 2023
1 parent f9a131b commit 4196d9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rust/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
inputs = {
rust-overlay.url = "github:oxalica/rust-overlay";
systems.url = "github:nix-systems/default";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.url = "nixpkgs";
};
};

outputs = {
self,
systems,
nixpkgs,
treefmt-nix,
...
} @ inputs: let
eachSystem = f:
Expand All @@ -17,6 +23,8 @@
overlays = [inputs.rust-overlay.overlays.default];
})
);

treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
in {
devShells = eachSystem (pkgs: {
default = pkgs.mkShell {
Expand All @@ -28,5 +36,11 @@
];
};
});

formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);

checks = eachSystem (pkgs: {
formatting = treefmtEval.${pkgs.system}.config.build.check self;
});
};
}
6 changes: 6 additions & 0 deletions rust/treefmt.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
projectRootFile = "treefmt.nix";

programs.alejandra.enable = true;
programs.rustfmt.enable = true;
}

0 comments on commit 4196d9c

Please sign in to comment.