on master help sign in
Properly differentiate between derivation and store path.

The previous check was actually not differentiating between the two cases defined in `test.sh` (both cases were ignore and the if branch was never used). By using `isDerivation` we now properly distinguish between the two cases, and add the missing context when necessary.

commit876dda82702382d72bc7201977fc4516ee726e73 authorAlois Cochard <alois.cochard@gmail.com> dateTue 4 May 2021, 17:10 (5 years ago) parent8e39653
1 file changed+4−3
default.nix+4−3
default.nix+4−3
@@ -11,10 +11,11 @@ let
1111 });
1212in rec {
1313 toStorePath = target:
14− # If a store path has been given but is a string, add the missing context
14+ # If a store path has been given but is not a derivation, add the missing context
1515 # to it so it will be propagated properly as a build input.
16− if builtins.isString target && lib.isStorePath target then
17− builtins.appendContext target { "${target}" = { path = true; }; }
16+ if !(lib.isDerivation target) && lib.isStorePath target then
17+ let path = toString target; in
18+ builtins.appendContext path { "${path}" = { path = true; }; }
1819 # Otherwise, add to the store. This takes care of appending the store path
1920 # in the context automatically.
2021 else "${target}";