Fix formatter when devShell is null

The formatter uses `devShell.packages` for its path which is not
available when devShell is null. A default value of empty list should be
used when devShell is null.
This commit is contained in:
Archit Gupta 2023-12-05 02:06:23 -08:00
parent dccabae216
commit 27f9ac981c
2 changed files with 11 additions and 2 deletions

View File

@ -30,7 +30,7 @@ in
(mkIf (config.formatters != null) {
perSystem = { pkgs, lib, fd, coreutils, ... }: {
formatter = mkDefault (pkgs.writeShellScriptBin "formatter" ''
PATH=${lib.makeBinPath (config.devShell.packages pkgs)}
PATH=${lib.makeBinPath ((config.devShell.packages or (_: [ ])) pkgs)}
for f in "$@"; do
if [ -d "$f" ]; then
${fd}/bin/fd "$f" -Htf -x "$0" &

View File

@ -509,7 +509,16 @@ in
formatters-fn = test
(flakelight ./empty {
formatters = { rustfmt, ... }: {
"*.rs" = "rustfmt";
"*.rs" = "${rustfmt}";
};
})
(f: lib.isDerivation f.formatter.x86_64-linux);
formatters-no-devshell = test
(flakelight ./empty {
devShell = lib.mkForce null;
formatters = { rustfmt, ... }: {
"*.rs" = "${rustfmt}";
};
})
(f: lib.isDerivation f.formatter.x86_64-linux);