Skip to content

Commit 9f73309

Browse files
committed
modules: pre-commit: make pkgs.buildEnv composable
Passing a git-hooks.lib.<SYSTEM>.run derivation as a path to pkgs.buildEnv results in the following error due to derivations with an empty file being treated differently from derivations with an empty directory: The store path <TARGET> is a file and can't be merged into an environment using pkgs.buildEnv! Since Nixpkgs rejected explicitly handling derivations with an empty file in pkgs.buildEnv [1], affected derivations should transition from 'touch $out' to 'mkdir $out' to be pkgs.buildEnv composable. This change replaces 'touch $out' with 'mkdir $out' and makes the following command work: nix \ build \ --expr ' let flake = builtins.getFlake (toString ./.); system = builtins.currentSystem; in flake.inputs.nixpkgs.legacyPackages.${system}.buildEnv { name = ""; paths = [(flake.outputs.lib.${system}.run {src = ./.;})]; } ' \ --impure [1]: NixOS/nixpkgs#325140 Link: #498
1 parent 85f7a71 commit 9f73309

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/pre-commit.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ let
7878
fi
7979
exitcode=$?
8080
git --no-pager diff --color
81-
touch $out
81+
mkdir $out
8282
[ $? -eq 0 ] && exit $exitcode
8383
'';
8484

0 commit comments

Comments
 (0)