From 981e22f8512e9eda12c90eee391ac90b121a5ff7 Mon Sep 17 00:00:00 2001 From: Archit Gupta Date: Mon, 19 Feb 2024 02:03:21 -0800 Subject: [PATCH] Fix usage of devShell packages in formatters Formatters should have the packages from devShell.packages, though a regression caused PATH to not be set in the formatter. This fixes that issue. --- builtinModules/formatter.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builtinModules/formatter.nix b/builtinModules/formatter.nix index 4b48cf5..091d0c7 100644 --- a/builtinModules/formatter.nix +++ b/builtinModules/formatter.nix @@ -28,8 +28,13 @@ in (mkIf (config.formatters != null) { outputs.formatter = mkDefault (genSystems ({ pkgs, lib, fd, coreutils, ... }: + let + packages = + if config.devShell == null then [ ] + else (config.devShell pkgs).packages pkgs; + in pkgs.writeShellScriptBin "formatter" '' - PATH=${lib.makeBinPath (config.devShell.packages or (_: [ ]) pkgs)} + PATH=${lib.makeBinPath packages} for f in "$@"; do if [ -d "$f" ]; then ${fd}/bin/fd "$f" -Htf -x "$0" &