diff --git a/builder/default.nix b/builder/default.nix index 98c1b977c..27ae6f2f3 100644 --- a/builder/default.nix +++ b/builder/default.nix @@ -79,7 +79,7 @@ let # Same as haskellPackages.shellFor in nixpkgs. shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix { - inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib pkgsBuildBuild evalPackages compiler; + inherit hsPkgs ghcForComponent makeConfigFiles hoogleLocal haskellLib pkgsBuildBuild evalPackages compiler ghc; inherit (buildPackages) glibcLocales; }; diff --git a/builder/shell-for.nix b/builder/shell-for.nix index 7fa92118b..2bb4ede06 100644 --- a/builder/shell-for.nix +++ b/builder/shell-for.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, mkShell, glibcLocales, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, pkgsBuildBuild, evalPackages, compiler }: +{ lib, stdenv, mkShell, glibcLocales, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, pkgsBuildBuild, evalPackages, compiler, haskell-nix, ghc }: { # `packages` function selects packages that will be worked on in the shell itself. # These packages will not be built by `shellFor`, but their @@ -120,7 +120,10 @@ let # Set up a "dummy" component to use with ghcForComponent. component = { depends = packageInputs; - pre-existing = lib.unique (lib.concatMap (x: (haskellLib.dependToLib x).pre-existing or []) allConfigs); + pre-existing = + if exactDeps + then lib.unique (lib.concatMap (x: (haskellLib.dependToLib x).pre-existing or []) allConfigs) + else haskell-nix.ghc-pre-existing ghc; libs = haskellLib.uniqueWithName (lib.concatMap (x: (haskellLib.dependToLib x).libs or []) allConfigs); pkgconfig = haskellLib.uniqueWithName (lib.concatMap (x: (haskellLib.dependToLib x).pkgconfig or []) allConfigs); frameworks = haskellLib.uniqueWithName (lib.concatMap (x: (haskellLib.dependToLib x).frameworks or []) allConfigs); diff --git a/lib/call-cabal-project-to-nix.nix b/lib/call-cabal-project-to-nix.nix index 96da9715d..4e7b3a73d 100644 --- a/lib/call-cabal-project-to-nix.nix +++ b/lib/call-cabal-project-to-nix.nix @@ -366,57 +366,6 @@ let ''; }; - ghc-pkgs = [ - "Cabal" - "array" - "base" - "binary" - "bytestring" - "containers" - "deepseq" - "directory" - "filepath" - "ghc-boot" - "ghc-boot-th" - "ghc-compact" - "ghc-heap" - "ghc-prim" - "ghci" - "integer-gmp" - "mtl" - "parsec" - "pretty" - "process" - "rts" - "template-haskell" - "text" - "time" - "transformers" - ] ++ pkgs.lib.optionals (!pkgs.stdenv.targetPlatform.isGhcjs || builtins.compareVersions ghc.version "9.0" > 0) [ - # GHCJS 8.10 does not have these - "Cabal-syntax" - "exceptions" - "file-io" - "ghc" - "ghc-bignum" - "ghc-experimental" - "ghc-internal" - "ghc-platform" - "ghc-toolchain" - "haskeline" - "hpc" - "libiserv" - "os-string" - "semaphore-compat" - "stm" - "xhtml" - ] ++ pkgs.lib.optionals (!pkgs.stdenv.targetPlatform.isGhcjs) [ - "terminfo" - ] ++ (if pkgs.stdenv.targetPlatform.isWindows - then [ "Win32" ] - else [ "unix" ] - ); - dummy-ghc-pkg-dump = evalPackages.runCommand "dummy-ghc-pkg-dump" { nativeBuildInputs = [ evalPackages.haskell-nix.nix-tools-unchecked.exes.cabal2json @@ -557,7 +506,7 @@ let PKGS+=" ${name}" LAST_PKG="${name}" fi - '') ghc-pkgs) + '') (pkgs.haskell-nix.ghc-pre-existing ghc)) } ${ # There is no .cabal file for system-cxx-std-lib pkgs.lib.optionalString (builtins.compareVersions ghc.version "9.2" >= 0) ( diff --git a/overlays/haskell.nix b/overlays/haskell.nix index a7fb6e301..d6f2a7c9b 100644 --- a/overlays/haskell.nix +++ b/overlays/haskell.nix @@ -1074,6 +1074,60 @@ final: prev: { }; }) final.haskell-nix.compiler; + ghc-pre-existing = ghc: [ + "Cabal" + "array" + "base" + "binary" + "bytestring" + "containers" + "deepseq" + "directory" + "filepath" + "ghc-boot" + "ghc-boot-th" + "ghc-compact" + "ghc-heap" + "ghc-prim" + "ghci" + "integer-gmp" + "mtl" + "parsec" + "pretty" + "process" + "rts" + "template-haskell" + "text" + "time" + "transformers" + ] ++ final.lib.optionals (!final.stdenv.targetPlatform.isGhcjs || builtins.compareVersions ghc.version "9.0" > 0) [ + # GHCJS 8.10 does not have these + "Cabal-syntax" + "exceptions" + "file-io" + "ghc" + "ghc-bignum" + "ghc-experimental" + "ghc-internal" + "ghc-platform" + "ghc-toolchain" + "haskeline" + "hpc" + "libiserv" + "os-string" + "semaphore-compat" + "stm" + "xhtml" + ] ++ final.lib.optionals ( + !final.stdenv.targetPlatform.isGhcjs + && !final.stdenv.targetPlatform.isWindows + && ghc.enableTerminfo or true) [ + "terminfo" + ] ++ (if final.stdenv.targetPlatform.isWindows + then [ "Win32" ] + else [ "unix" ] + ); + # Add this to your tests to make all the dependencies of haskell.nix # are tested and cached. Consider using `p.roots` where `p` is a # project as it will automatically match the `compiler-nix-name`