@@ -211,14 +211,16 @@ in rec {
211
211
filterOpamRepo = packages : repo :
212
212
linkFarm "opam-repo" ( [ ( namePathPair "repo" "${ repo } /repo" ) ] ++ attrValues
213
213
( mapAttrs ( name : version :
214
- if isNull version then
215
- namePathPair "packages/${ name } /${ name } .dev"
216
- "${ repo } /packages/${ name } /${
217
- head ( attrNames ( readDir "${ repo } /packages/${ name } " ) )
218
- } "
214
+ let
215
+ defaultPath = "${ repo } /packages/${ name } /${
216
+ head ( attrNames ( readDir "${ repo } /packages/${ name } " ) )
217
+ } " ;
218
+ in if isNull version then
219
+ namePathPair "packages/${ name } /${ name } .dev" defaultPath
219
220
else
220
221
namePathPair "packages/${ name } /${ name } .${ version } "
221
- "${ repo } /packages/${ name } /${ name } .${ version } " ) packages ) )
222
+ ( let path = "${ repo } /packages/${ name } /${ name } .${ version } " ;
223
+ in if builtins . pathExists path then path else defaultPath ) ) packages ) )
222
224
// optionalAttrs ( repo ? passthru ) {
223
225
passthru = let
224
226
pickRelevantVersions = from :
@@ -227,7 +229,7 @@ in rec {
227
229
if isNull version then
228
230
head ( attrValues from . ${ name } )
229
231
else
230
- from . ${ name } . ${ version } ;
232
+ from . ${ name } . ${ version } or head ( attrValues from . ${ name } ) ;
231
233
} ) packages ;
232
234
in repo . passthru // mapAttrs ( _ : pickRelevantVersions ) {
233
235
inherit ( repo . passthru ) sourceMap pkgdefs ;
@@ -404,7 +406,7 @@ in rec {
404
406
// {
405
407
inherit url ;
406
408
} ;
407
- repo = filterOpamRepo { ${ name } = null ; } ( makeOpamRepo path ) ;
409
+ repo = filterOpamRepo { ${ name } = version ; } ( makeOpamRepo path ) ;
408
410
in if ! hasRev && ! isImpure then
409
411
lib . warn
410
412
"pin-depends without an explicit sha1 is not supported in pure evaluation mode; try with --impure"
0 commit comments