mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-26 09:46:04 +03:00
chore: more formatter into separate flake module
This commit is contained in:
parent
bc2e8ddb64
commit
954bacb0a6
31
flake.nix
31
flake.nix
@ -35,35 +35,7 @@
|
||||
nixpkgs,
|
||||
pre-commit-hooks,
|
||||
...
|
||||
} @ inp: let
|
||||
l = nixpkgs.lib // builtins;
|
||||
|
||||
inputs = inp;
|
||||
|
||||
perSystem = {
|
||||
config,
|
||||
pkgs,
|
||||
system,
|
||||
inputs',
|
||||
...
|
||||
}: {
|
||||
apps = {
|
||||
# passes through extra flags to treefmt
|
||||
format.type = "app";
|
||||
format.program = let
|
||||
path = l.makeBinPath [
|
||||
pkgs.alejandra
|
||||
pkgs.python3.pkgs.black
|
||||
];
|
||||
in
|
||||
l.toString
|
||||
(pkgs.writeScript "format" ''
|
||||
export PATH="${path}"
|
||||
${pkgs.treefmt}/bin/treefmt --clear-cache "$@"
|
||||
'');
|
||||
};
|
||||
};
|
||||
in
|
||||
} @ inputs:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
imports = [
|
||||
./modules/flake-parts/all-modules.nix
|
||||
@ -75,6 +47,5 @@
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
inherit perSystem;
|
||||
};
|
||||
}
|
||||
|
17
modules/flake-parts/formatter.nix
Normal file
17
modules/flake-parts/formatter.nix
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
perSystem = {
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
formatter = let
|
||||
path = lib.makeBinPath [
|
||||
pkgs.alejandra
|
||||
pkgs.python3.pkgs.black
|
||||
];
|
||||
in (pkgs.writeScriptBin "format" ''
|
||||
export PATH="${path}"
|
||||
${pkgs.treefmt}/bin/treefmt --clear-cache "$@"
|
||||
'');
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user