@@ -496,6 +496,7 @@ final: prev: {
496496 # separately from the hsPkgs. The advantage is that the you can get the
497497 # plan-nix without building the project.
498498 cabalProject' =
499+ projectModule: haskellLib.evalProjectModule ../modules/cabal-project.nix projectModule (
499500 { src, compiler-nix-name, ... }@args':
500501 let
501502 args = { caller = "cabalProject'"; } // args';
@@ -515,10 +516,9 @@ final: prev: {
515516 { inherit compiler-nix-name plan-pkgs;
516517 pkg-def-extras = args.pkg-def-extras or [];
517518 modules = (args.modules or [])
518− ++ final.lib.optional (args ? ghcOverride || args ? ghc)
519− { ghc.package = args.ghcOverride or args.ghc; }
520− ++ final.lib.optional (args ? compiler-nix-name)
521− { compiler.nix-name = final.lib.mkForce args.compiler-nix-name; };
519+ ++ final.lib.optional (args.ghcOverride != null || args.ghc != null)
520+ { ghc.package = if args.ghcOverride != null then args.ghcOverride else args.ghc; }
521+ ++ [ { compiler.nix-name = final.lib.mkForce args.compiler-nix-name; } ];
522522 extra-hackages = args.extra-hackages or [];
523523 };
524524
@@ -531,9 +531,9 @@ final: prev: {
531531 tools = final.buildPackages.haskell-nix.tools pkg-set.config.compiler.nix-name;
532532 roots = final.haskell-nix.roots pkg-set.config.compiler.nix-name;
533533 projectFunction = haskell-nix: haskell-nix.cabalProject';
534− projectArgs = args';
534+ inherit projectModule;
535535 };
536− in project;
536+ in project);
537537
538538
539539 # Take `hsPkgs` from the `rawProject` and update all the packages and
@@ -583,7 +583,7 @@ final: prev: {
583583 projectCoverageReport = haskellLib.projectCoverageReport project (map (pkg: pkg.coverageReport) (final.lib.attrValues (haskellLib.selectProjectPackages hsPkgs)));
584584
585585 projectCross = (final.lib.mapAttrs (_: pkgs:
586− rawProject.projectFunction pkgs.haskell-nix rawProject.projectArgs
586+ rawProject.projectFunction pkgs.haskell-nix rawProject.projectModule
587587 ) final.pkgsCross) // { recurseForDerivations = false; };
588588
589589 # Like `.hsPkgs.${packageName}` but when compined with `getComponent` any
@@ -684,25 +684,23 @@ final: prev: {
684684 inherit (rawProject.hsPkgs) makeConfigFiles ghcWithHoogle ghcWithPackages shellFor;
685685 });
686686
687− cabalProject =
688− { src, compiler-nix-name, ... }@args':
689− let
690− args = { caller = "hackage-package"; } // args';
691− p = cabalProject' args;
687+ cabalProject = args: let p = cabalProject' args;
692688 in p.hsPkgs // p;
693689
694690 stackProject' =
691+ projectModule: haskellLib.evalProjectModule ../modules/stack-project.nix projectModule (
695692 { src, ... }@args:
696− let callProjectResults = callStackToNix ({ inherit cache; } // args);
693+ let callProjectResults = callStackToNix (args
694+ // final.lib.optionalAttrs (args.cache == null) { inherit cache; });
697695 generatedCache = genStackCache args;
698− cache = args.cache or generatedCache;
696+ cache = if args.cache != null then args.cache else generatedCache;
699697 in let pkg-set = mkStackPkgSet
700698 { stack-pkgs = importAndFilterProject callProjectResults;
701699 pkg-def-extras = (args.pkg-def-extras or []);
702700 modules = final.lib.singleton (mkCacheModule cache)
703701 ++ (args.modules or [])
704− ++ final.lib.optional (args ? ghc) { ghc.package = args.ghc; }
705− ++ final.lib.optional (args ? compiler-nix-name)
702+ ++ final.lib.optional (args.ghc != null) { ghc.package = args.ghc; }
703+ ++ final.lib.optional (args.compiler-nix-name != null)
706704 { compiler.nix-name = final.lib.mkForce args.compiler-nix-name; };
707705 };
708706
@@ -714,9 +712,9 @@ final: prev: {
714712 tools = final.buildPackages.haskell-nix.tools pkg-set.config.compiler.nix-name;
715713 roots = final.haskell-nix.roots pkg-set.config.compiler.nix-name;
716714 projectFunction = haskell-nix: haskell-nix.stackProject';
717− projectArgs = args;
715+ inherit projectModule;
718716 };
719− in project;
717+ in project);
720718
721719 stackProject = args: let p = stackProject' args;
722720 in p.hsPkgs // p;
@@ -732,7 +730,7 @@ final: prev: {
732730 # used (as it will use a default `cabal.project`).
733731 project' = { src, projectFileName ? null, ... }@args':
734732 let
735− args = { caller = "project'"; } // args';
733+ args = { caller = "project'"; } // final.lib.filterAttrs (n: _: n != "projectFileName") args';
736734 dir = __readDir (src.origSrcSubDir or src);
737735 exists = fileName: builtins.elem (dir.${fileName} or "") ["regular" "symlink"];
738736 stackYamlExists = exists "stack.yaml";