mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
shell: Introduce treefmt
Introduces treefmt with a simple nixfmt-rfc-style configuration to format all Nix files. This is only practically usable with the following commit that formats all files accordingly.
This commit is contained in:
parent
02b2743b6a
commit
398e74f70b
2 changed files with 38 additions and 5 deletions
|
@ -21,9 +21,42 @@ let
|
||||||
config = { };
|
config = { };
|
||||||
overlays = [ ];
|
overlays = [ ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fmt =
|
||||||
|
let
|
||||||
|
treefmtNixSrc = fetchTarball {
|
||||||
|
# Master at 2025-02-12
|
||||||
|
url = "https://github.com/numtide/treefmt-nix/archive/4f09b473c936d41582dd744e19f34ec27592c5fd.tar.gz";
|
||||||
|
sha256 = "051vh6raskrxw5k6jncm8zbk9fhbzgm1gxpq9gm5xw1b6wgbgcna";
|
||||||
|
};
|
||||||
|
treefmtEval = (import treefmtNixSrc).evalModule pkgs {
|
||||||
|
# Important: The auto-rebase script uses `git filter-branch --tree-filter`,
|
||||||
|
# which creates trees within the Git repository under `.git-rewrite/t`,
|
||||||
|
# notably without having a `.git` themselves.
|
||||||
|
# So if this projectRootFile were the default `.git/config`,
|
||||||
|
# having the auto-rebase script use treefmt on such a tree would make it
|
||||||
|
# format all files in the _parent_ Git tree as well.
|
||||||
|
projectRootFile = ".git-blame-ignore-revs";
|
||||||
|
|
||||||
|
# Be a bit more verbose by default, so we can see progress happening
|
||||||
|
settings.verbose = 1;
|
||||||
|
|
||||||
|
# By default it's info, which is too noisy since we have many unmatched files
|
||||||
|
settings.on-unmatched = "debug";
|
||||||
|
|
||||||
|
# This uses nixfmt-rfc-style underneath,
|
||||||
|
# the default formatter for Nix code.
|
||||||
|
# See https://github.com/NixOS/nixfmt
|
||||||
|
programs.nixfmt.enable = true;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
shell = treefmtEval.config.build.devShell;
|
||||||
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit pkgs;
|
inherit pkgs fmt;
|
||||||
requestReviews = pkgs.callPackage ./request-reviews { };
|
requestReviews = pkgs.callPackage ./request-reviews { };
|
||||||
codeownersValidator = pkgs.callPackage ./codeowners-validator { };
|
codeownersValidator = pkgs.callPackage ./codeowners-validator { };
|
||||||
eval = pkgs.callPackage ./eval { };
|
eval = pkgs.callPackage ./eval { };
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
nixpkgs ? null,
|
nixpkgs ? null,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (import ./ci { inherit nixpkgs system; }) pkgs;
|
inherit (import ./ci { inherit nixpkgs system; }) pkgs fmt;
|
||||||
|
|
||||||
# For `nix-shell -A hello`
|
# For `nix-shell -A hello`
|
||||||
curPkgs = builtins.removeAttrs (import ./. { inherit system; }) [
|
curPkgs = builtins.removeAttrs (import ./. { inherit system; }) [
|
||||||
|
@ -28,10 +28,10 @@ let
|
||||||
in
|
in
|
||||||
curPkgs
|
curPkgs
|
||||||
// pkgs.mkShellNoCC {
|
// pkgs.mkShellNoCC {
|
||||||
|
inputsFrom = [
|
||||||
|
fmt.shell
|
||||||
|
];
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
# The default formatter for Nix code
|
|
||||||
# See https://github.com/NixOS/nixfmt
|
|
||||||
nixfmt-rfc-style
|
|
||||||
# Helper to review Nixpkgs PRs
|
# Helper to review Nixpkgs PRs
|
||||||
# See CONTRIBUTING.md
|
# See CONTRIBUTING.md
|
||||||
nixpkgs-review
|
nixpkgs-review
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue