add treefmt-nix
parent
05bce1e1f8
commit
cc78160e6e
@ -0,0 +1,68 @@
|
||||
{inputs, ...}: {
|
||||
imports = [
|
||||
inputs.treefmt-nix.flakeModule
|
||||
];
|
||||
perSystem = {
|
||||
self',
|
||||
inputs',
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}: {
|
||||
treefmt = {
|
||||
# Used to find the project root
|
||||
projectRootFile = "flake.lock";
|
||||
|
||||
programs.gofumpt.enable = true;
|
||||
programs.prettier.enable = true;
|
||||
|
||||
settings.formatter = {
|
||||
nix = {
|
||||
command = "sh";
|
||||
options = [
|
||||
"-eucx"
|
||||
''
|
||||
# First deadnix
|
||||
${pkgs.lib.getExe pkgs.deadnix} --edit "$@"
|
||||
# Then nixpkgs-fmt
|
||||
${pkgs.lib.getExe pkgs.nixpkgs-fmt} "$@"
|
||||
''
|
||||
"--"
|
||||
];
|
||||
includes = ["*.nix"];
|
||||
};
|
||||
|
||||
python = {
|
||||
command = "sh";
|
||||
options = [
|
||||
"-eucx"
|
||||
''
|
||||
${pkgs.lib.getExe pkgs.ruff} --fix "$@"
|
||||
${pkgs.lib.getExe pkgs.python3.pkgs.black} "$@"
|
||||
''
|
||||
"--" # this argument is ignored by bash
|
||||
];
|
||||
includes = ["*.py"];
|
||||
};
|
||||
};
|
||||
|
||||
checks =
|
||||
let
|
||||
nixosTests = pkgs.callPackages ./nixos-test.nix {
|
||||
makeTest = import (pkgs.path + "/nixos/tests/make-test-python.nix");
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit (nixosTests) unittests vault-agent systemd-vaultd;
|
||||
};
|
||||
};
|
||||
|
||||
checks = let
|
||||
nixosTests = pkgs.callPackages ./nix/checks/nixos-test.nix {
|
||||
makeTest = import (pkgs.path + "/nixos/tests/make-test-python.nix");
|
||||
};
|
||||
in {
|
||||
inherit (nixosTests) unittests vault-agent systemd-vaultd;
|
||||
};
|
||||
};
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
{
|
||||
runCommand,
|
||||
gofumpt,
|
||||
alejandra,
|
||||
python3,
|
||||
treefmt,
|
||||
}:
|
||||
runCommand "treefmt" {
|
||||
nativeBuildInputs = [
|
||||
gofumpt
|
||||
treefmt
|
||||
alejandra
|
||||
python3.pkgs.flake8
|
||||
python3.pkgs.black
|
||||
];
|
||||
} ''
|
||||
# keep timestamps so that treefmt is able to detect mtime changes
|
||||
cp --no-preserve=mode --preserve=timestamps -r ${../..} source
|
||||
cd source
|
||||
HOME=$TMPDIR treefmt --no-cache --fail-on-change
|
||||
touch $out
|
||||
''
|
@ -1,21 +0,0 @@
|
||||
[formatter.nix]
|
||||
command = "alejandra"
|
||||
includes = ["*.nix"]
|
||||
|
||||
[formatter.python]
|
||||
command = "sh"
|
||||
options = [
|
||||
"-eucx",
|
||||
"""
|
||||
flake8 "$@"
|
||||
black "$@"
|
||||
"""
|
||||
]
|
||||
includes = ["*.py"]
|
||||
excludes = []
|
||||
|
||||
[formatter.go]
|
||||
command = "gofumpt"
|
||||
options = ["-w"]
|
||||
includes = ["*.go"]
|
||||
excludes = []
|
Loading…
Reference in New Issue