@@ -300,6 +300,10 @@ self: super: {
300300 text = self . buildPackages . lib . concatMapStringsSep "\n " mkCacheLine repos ;
301301 } ;
302302
303+ genStackCache = import ../lib/stack-cache-generator.nix {
304+ inherit ( self . buildPackages ) pkgs ;
305+ } ;
306+
303307 mkCacheModule = cache :
304308 # for each item in the `cache`, set
305309 # packages.$name.src = fetchgit ...
@@ -315,8 +319,6 @@ self: super: {
315319 # src value.
316320 #
317321 # TODO: this should be moved into `call-stack-to-nix`
318- # it should be automatic and not the burden of
319- # the end user to work around nix peculiarities.
320322 { packages =
321323 let
322324 repoToAttr = { name , url , rev , ref ? null , sha256 ? null , subdir ? null , is-private ? false , ... } : {
@@ -334,6 +336,7 @@ self: super: {
334336 cacheMap = builtins . map repoToAttr cache ;
335337 in
336338 builtins . foldl' ( x : y : x // y ) { } cacheMap ;
339+
337340 } ;
338341
339342 # Takes a haskell src directory runs cabal new-configure and plan-to-nix.
@@ -408,13 +411,21 @@ self: super: {
408411
409412 stackProject' =
410413 { ... } @args :
411- let stack = importAndFilterProject ( callStackToNix args ) ;
414+ let stack = importAndFilterProject ( callStackToNix ( { inherit cache ; } // args ) ) ;
415+ cache = if args ? cache
416+ then builtins . trace
417+ "warning: passing `cache' to `stackProject' is deprecated. See #335 #358"
418+ args . cache
419+ else genStackCache {
420+ inherit ( args ) src ;
421+ stackYaml = args . stackYaml or "stack.yaml" ;
422+ } ;
412423 in let pkg-set = mkStackPkgSet
413424 { stack-pkgs = stack . pkgs ;
414425 pkg-def-extras = ( args . pkg-def-extras or [ ] ) ;
415- modules = ( args . modules or [ ] )
416- ++ self . lib . optional ( args ? ghc ) { ghc . package = args . ghc ; }
417- ++ self . lib . optional ( args ? cache ) ( mkCacheModule args . cache ) ;
426+ modules = self . lib . singleton ( mkCacheModule cache )
427+ ++ ( args . modules or [ ] )
428+ ++ self . lib . optional ( args ? ghc ) { ghc . package = args . ghc ; } ;
418429 } ;
419430 in { inherit ( pkg-set . config ) hsPkgs ; stack-nix = stack . nix ; } ;
420431
0 commit comments