add: python formatting

This commit is contained in:
hsjobeki 2022-12-28 20:41:52 +01:00
parent 40eb491b8a
commit cad5005cab
2 changed files with 18 additions and 8 deletions

View File

@ -177,10 +177,15 @@
// {
# passes through extra flags to treefmt
format.type = "app";
format.program =
format.program = let
path = lib.makeBinPath [
alejandra.defaultPackage.${system}
pkgs.python3.pkgs.black
];
in
l.toString
(pkgs.writeScript "format" ''
export PATH="${alejandra.defaultPackage.${system}}/bin"
export PATH="${path}"
${pkgs.treefmt}/bin/treefmt --clear-cache "$@"
'');
@ -205,6 +210,11 @@
dream2nix-shell = mkShell {
devshell.name = "dream2nix-devshell";
packages = [
alejandra.defaultPackage.${system}
pkgs.python3.pkgs.black
];
commands =
[
{package = pkgs.nix;}
@ -221,10 +231,6 @@
package = pkgs.treefmt;
category = "formatting";
}
{
package = alejandra.defaultPackage.${system};
category = "formatting";
}
]
# using linux is highly recommended as cntr is amazing for debugging builds
++ lib.optional pkgs.stdenv.isLinux {
@ -273,8 +279,8 @@
};
cleanup = {
enable = true;
name = "cleaned";
entry = l.toString (pkgs.writeScript "cleaned" ''
name = "cleanup";
entry = l.toString (pkgs.writeScript "cleanup" ''
#!${pkgs.bash}/bin/bash
for badFile in $(find ./examples | grep 'flake.lock\|dream2nix-packages'); do
rm -rf $badFile

View File

@ -6,3 +6,7 @@ excludes = [
"src/templates/translators/*",
"src/modules/_template/*",
]
[formatter.py]
command = "black"
includes = ["*.py"]