@@ -189,7 +189,7 @@ final: prev: {
189 hackageTarball = { index-state, sha256, nix-tools ? final.haskell-nix.nix-tools, ... }:
189 hackageTarball = { index-state, sha256, nix-tools ? final.haskell-nix.nix-tools, ... }:
190 assert sha256 != null;
190 assert sha256 != null;
191 let at = builtins.replaceStrings [":"] [""] index-state; in
191 let at = builtins.replaceStrings [":"] [""] index-state; in
192− { "hackage.haskell.org-at-${at}" = final.evalPackages.fetchurl {
192+ { "hackage.haskell.org-at-${at}" = final.fetchurl {
193 name = "01-index.tar.gz-at-${at}";
193 name = "01-index.tar.gz-at-${at}";
194 url = "https://hackage.haskell.org/01-index.tar.gz";
194 url = "https://hackage.haskell.org/01-index.tar.gz";
195 downloadToTemp = true;
195 downloadToTemp = true;
@@ -211,7 +211,7 @@ final: prev: {
211 # dotCabalName anyway.
211 # dotCabalName anyway.
212 dotCabalName = "dot-cabal-" + allNames;
212 dotCabalName = "dot-cabal-" + allNames;
213 # This is very big, and cheap to build: prefer building it locally
213 # This is very big, and cheap to build: prefer building it locally
214− tarballRepos = final.evalPackages.runCommand dotCabalName { nativeBuildInputs = [ cabal-install ]; preferLocalBuild = true; } ''
214+ tarballRepos = final.runCommand dotCabalName { nativeBuildInputs = [ cabal-install ]; preferLocalBuild = true; } ''
215 mkdir -p $out/.cabal
215 mkdir -p $out/.cabal
216 cat <<EOF > $out/.cabal/config
216 cat <<EOF > $out/.cabal/config
217 ${final.lib.concatStrings (
217 ${final.lib.concatStrings (
@@ -239,7 +239,7 @@ final: prev: {
241 # Add the extra-hackage-repos where we have all the files needed.
241 # Add the extra-hackage-repos where we have all the files needed.
242− final.evalPackages.runCommand dotCabalName { nativeBuildInputs = [ final.evalPackages.xorg.lndir ]; } ''
242+ final.runCommand dotCabalName { nativeBuildInputs = [ final.xorg.lndir ]; } ''
243 mkdir $out
243 mkdir $out
244 lndir ${tarballRepos} $out
244 lndir ${tarballRepos} $out
@@ -261,10 +261,9 @@ final: prev: {
262 # Helps materialize the output of derivations
262 # Helps materialize the output of derivations
263 materialize = import ../lib/materialize.nix {
263 materialize = import ../lib/materialize.nix {
264− inherit (final.evalPackages) nix;
265+ inherit (final) nix runCommand writeShellScript;
265 inherit (final.haskell-nix) checkMaterialization;
266 inherit (final.haskell-nix) checkMaterialization;
266− pkgs = final.evalPackages.pkgs;
267− inherit (final.evalPackages.pkgs) runCommand writeShellScript;
270 update-index-state-hashes = import ../scripts/update-index-state-hashes.nix {
269 update-index-state-hashes = import ../scripts/update-index-state-hashes.nix {
@@ -275,11 +274,7 @@ final: prev: {
277 # Function to call stackToNix
276 # Function to call stackToNix
278− callStackToNix = import ../lib/call-stack-to-nix.nix {
277+ callStackToNix = import ../lib/call-stack-to-nix.nix;
279− pkgs = final.evalPackages.pkgs;
280− inherit (final.evalPackages.pkgs) runCommand;
281− inherit (final.evalPackages.haskell-nix) mkCacheFile materialize haskellLib;
284 # given a source location call `cabal-to-nix` (from nix-tools) on it
279 # given a source location call `cabal-to-nix` (from nix-tools) on it
285 # to produce the nix representation of it.
280 # to produce the nix representation of it.
@@ -325,7 +320,7 @@ final: prev: {
325 # pkgs.fetchgit doesn't have any way of fetching from a given
320 # pkgs.fetchgit doesn't have any way of fetching from a given
327 assert isNull ref;
322 assert isNull ref;
328− final.evalPackages.fetchgit {
323+ final.fetchgit {
329 url = url;
324 url = url;
330 rev = rev;
325 rev = rev;
331 sha256 = sha256;
326 sha256 = sha256;
@@ -382,10 +377,7 @@ final: prev: {
385− genStackCache = import ../lib/stack-cache-generator.nix {
380+ genStackCache = import ../lib/stack-cache-generator.nix;
386− inherit (final.evalPackages) pkgs;
387− inherit (final.evalPackages.haskell-nix) haskellLib;
390 mkCacheModule = cache:
382 mkCacheModule = cache:
391 # for each item in the `cache`, set
383 # for each item in the `cache`, set
@@ -414,7 +406,7 @@ final: prev: {
414 final.buildPackages.lib.optionalAttrs (ref != null) { inherit ref; }
406 final.buildPackages.lib.optionalAttrs (ref != null) { inherit ref; }
417− final.evalPackages.fetchgit { inherit url rev sha256; };
409+ final.fetchgit { inherit url rev sha256; };
418 } // final.buildPackages.lib.optionalAttrs (subdir != null && subdir != ".") { postUnpack = "sourceRoot+=/${subdir}; echo source root reset to $sourceRoot"; };
410 } // final.buildPackages.lib.optionalAttrs (subdir != null && subdir != ".") { postUnpack = "sourceRoot+=/${subdir}; echo source root reset to $sourceRoot"; };
@@ -428,11 +420,9 @@ final: prev: {
428 # Resulting nix files are added to nix-plan subdirectory.
420 # Resulting nix files are added to nix-plan subdirectory.
429 callCabalProjectToNix = import ../lib/call-cabal-project-to-nix.nix {
421 callCabalProjectToNix = import ../lib/call-cabal-project-to-nix.nix {
430 index-state-hashes = import indexStateHashesPath;
422 index-state-hashes = import indexStateHashesPath;
431− inherit (final.buildPackages.haskell-nix) haskellLib materialize;
423+ inherit (final.buildPackages.haskell-nix) haskellLib;
432 pkgs = final.buildPackages.pkgs;
424 pkgs = final.buildPackages.pkgs;
433− inherit (final) evalPackages;
434− inherit (final.evalPackages.haskell-nix) dotCabal;
435− inherit (final.buildPackages.pkgs) runCommand symlinkJoin cacert;
425+ inherit (final.buildPackages.pkgs) runCommand cacert;
438 # Loads a plan and filters the package directories using cleanSourceWith
428 # Loads a plan and filters the package directories using cleanSourceWith
@@ -455,60 +445,22 @@ final: prev: {
455 # the index-state-hashes is used. This guarantees reproducibility wrt
445 # the index-state-hashes is used. This guarantees reproducibility wrt
456 # to the haskell.nix revision. If reproducibility beyond haskell.nix
446 # to the haskell.nix revision. If reproducibility beyond haskell.nix
457 # is required, a specific index-state should be provided!
447 # is required, a specific index-state should be provided!
458− hackage-package =
448+ hackage-package = projectModule:
459− { name, compiler-nix-name, ... }@args':
449+ let project = hackage-project projectModule;
460− let args = { caller = "hackage-package"; } // args';
461− in (hackage-project args).getPackage name;
450+ in project.getPackage project.args.name;
462− hackage-project =
451+ hackage-project = projectModule:
463− { name
452+ cabalProject' ([
464− , compiler-nix-name
453+ (import ../modules/hackage-project.nix)
465− , version ? "latest"
454+ ] ++ (import ../modules/hackage-quirks.nix)
466− , revision ? "default"
455+ ++ (if builtins.isList projectModule then projectModule else [projectModule]));
468− let version' = if version == "latest"
469− then builtins.head (
471− (a: b: builtins.compareVersions a b > 0)
472− (builtins.attrNames hackage.${name}))
474− args = { caller = "hackage-project"; } // args';
475− tarball = final.pkgs.fetchurl {
476− url = "mirror://hackage/${name}-${version'}.tar.gz";
477− inherit (hackage.${name}.${version'}) sha256; };
478− rev = hackage.${name}.${version'}.revisions.${revision};
479− cabalFile = final.pkgs.fetchurl {
480− url = "https://hackage.haskell.org/package/${name}-${version'}/revision/${toString rev.revNum}.cabal";
481− inherit (rev) sha256;
483− revSuffix = final.lib.optionalString (rev.revNum > 0) "-r${toString rev.revNum}";
484− in let src = final.buildPackages.pkgs.runCommand "${name}-${version'}${revSuffix}-src" {} (''
488− mv "${name}-${version'}" $out
489− '' + final.lib.optionalString (rev.revNum > 0) ''
490− cp ${cabalFile} $out/${name}.cabal
492− # TODO remove once nix >=2.4 is widely adopted (will trigger rebuilds of everything).
493− # Disable filtering keeps pre ond post nix 2.4 behaviour the same. This means that
494− # the same `alex`, `happy` and `hscolour` are used to build GHC. It also means that
495− # that `tools` in the shell will be built the same.
496− filterPath = { path, ... }: path;
499− # Avoid readDir and readFile IFD functions looking for these files in the hackage source
500− cabalProject = null; cabalProjectLocal = null; cabalProjectFreeze = null;
501− } // final.haskell-nix.hackageQuirks { inherit name; version = version'; } //
502− builtins.removeAttrs args [ "version" "revision" ] // { inherit src; });
504 # This function is like `cabalProject` but it makes the plan-nix available
457 # This function is like `cabalProject` but it makes the plan-nix available
505 # separately from the hsPkgs. The advantage is that the you can get the
458 # separately from the hsPkgs. The advantage is that the you can get the
506 # plan-nix without building the project.
459 # plan-nix without building the project.
507 cabalProject' =
460 cabalProject' =
508 projectModule: haskellLib.evalProjectModule ../modules/cabal-project.nix projectModule (
461 projectModule: haskellLib.evalProjectModule ../modules/cabal-project.nix projectModule (
509− { src, compiler-nix-name, ... }@args':
462+ { src, compiler-nix-name, evalPackages, ... }@args:
511− args = { caller = "cabalProject'"; } // args';
512 callProjectResults = callCabalProjectToNix args;
464 callProjectResults = callCabalProjectToNix args;
513 plan-pkgs = importAndFilterProject {
465 plan-pkgs = importAndFilterProject {
514 inherit (callProjectResults) projectNix sourceRepos src;
466 inherit (callProjectResults) projectNix sourceRepos src;
@@ -522,6 +474,7 @@ final: prev: {
522 config = {
474 config = {
523 compiler.nix-name = compiler-nix-name;
475 compiler.nix-name = compiler-nix-name;
524 hsPkgs = {};
476 hsPkgs = {};
477+ inherit evalPackages;
527 else mkCabalProjectPkgSet
480 else mkCabalProjectPkgSet
@@ -531,7 +484,10 @@ final: prev: {
531 ++ (args.modules or [])
484 ++ (args.modules or [])
532 ++ final.lib.optional (args.ghcOverride != null || args.ghc != null)
485 ++ final.lib.optional (args.ghcOverride != null || args.ghc != null)
533 { ghc.package = if args.ghcOverride != null then args.ghcOverride else args.ghc; }
486 { ghc.package = if args.ghcOverride != null then args.ghcOverride else args.ghc; }
534− ++ [ { compiler.nix-name = final.lib.mkForce args.compiler-nix-name; } ];
488+ compiler.nix-name = final.lib.mkForce args.compiler-nix-name;
489+ evalPackages = final.lib.mkDefault evalPackages;
535 extra-hackages = args.extra-hackages or [] ++ callProjectResults.extra-hackages;
491 extra-hackages = args.extra-hackages or [] ++ callProjectResults.extra-hackages;
@@ -708,7 +664,7 @@ final: prev: {
708 # not exist at all). The derivation will never build
664 # not exist at all). The derivation will never build
709 # and simple outputs the result of cabal configure.
665 # and simple outputs the result of cabal configure.
710 getComponent = componentName:
666 getComponent = componentName:
711− final.evalPackages.runCommand "cabal-configure-error" {
667+ final.rawProject.config.evalPackages.runCommand "cabal-configure-error" {
712 passthru = {
668 passthru = {
713 inherit project package;
669 inherit project package;
@@ -807,7 +763,7 @@ final: prev: {
808 stackProject' =
764 stackProject' =
809 projectModule: haskellLib.evalProjectModule ../modules/stack-project.nix projectModule (
765 projectModule: haskellLib.evalProjectModule ../modules/stack-project.nix projectModule (
810− { src, ... }@args:
766+ { src, evalPackages, ... }@args:
811 let callProjectResults = callStackToNix (args
767 let callProjectResults = callStackToNix (args
812 // final.lib.optionalAttrs (args.cache == null) { inherit cache; });
768 // final.lib.optionalAttrs (args.cache == null) { inherit cache; });
813 generatedCache = genStackCache args;
769 generatedCache = genStackCache args;
@@ -824,7 +780,8 @@ final: prev: {
824 ++ (args.modules or [])
780 ++ (args.modules or [])
825 ++ final.lib.optional (args.ghc != null) { ghc.package = args.ghc; }
781 ++ final.lib.optional (args.ghc != null) { ghc.package = args.ghc; }
826 ++ final.lib.optional (args.compiler-nix-name != null)
782 ++ final.lib.optional (args.compiler-nix-name != null)
827− { compiler.nix-name = final.lib.mkForce args.compiler-nix-name; };
783+ { compiler.nix-name = final.lib.mkForce args.compiler-nix-name; }
784+ ++ [ { evalPackages = final.lib.mkDefault evalPackages; } ];
830 project = addProjectAndPackageAttrs {
787 project = addProjectAndPackageAttrs {
@@ -860,6 +817,7 @@ final: prev: {
860 (import ../modules/stack-project.nix)
817 (import ../modules/stack-project.nix)
861 (import ../modules/cabal-project.nix)
818 (import ../modules/cabal-project.nix)
862 (import ../modules/project.nix)
819 (import ../modules/project.nix)
820+ {_module.args.pkgs = final;} # Needed to make `src = config.evalPackages.haskell-nix.haskellLib.cleanGit ...` work
863 ] ++ projectModule';
821 ] ++ projectModule';
864 }).config) src projectFileName;
822 }).config) src projectFileName;
865 dir = __readDir (src.origSrcSubDir or src);
823 dir = __readDir (src.origSrcSubDir or src);
@@ -881,12 +839,12 @@ final: prev: {
881 if final.lib.hasSuffix ".yaml" selectedFileName
839 if final.lib.hasSuffix ".yaml" selectedFileName
882 then stackProject' ([
840 then stackProject' ([
883 (import ../modules/project.nix)
841 (import ../modules/project.nix)
884− { caller = "project'"; stackYaml = selectedFileName; }
842+ { stackYaml = selectedFileName; }
885 ] ++ projectModule'
843 ] ++ projectModule'
887 else cabalProject' ([
845 else cabalProject' ([
888 (import ../modules/project.nix)
846 (import ../modules/project.nix)
889− { caller = "project'"; cabalProjectFileName = selectedFileName; }
847+ { cabalProjectFileName = selectedFileName; }
890 ] ++ projectModule');
848 ] ++ projectModule');
892 # This is the same as the `cabalPackage` and `stackPackage` wrappers
850 # This is the same as the `cabalPackage` and `stackPackage` wrappers