diff --git a/builtinModules/formatter.nix b/builtinModules/formatter.nix index 0c379b6..77b69fa 100644 --- a/builtinModules/formatter.nix +++ b/builtinModules/formatter.nix @@ -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" & diff --git a/tests/default.nix b/tests/default.nix index 705d099..a35158d 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -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);