Skip to content

Include all pre-existing ghc pkgs in shell, unless exactDeps #2375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builder/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
7 changes: 5 additions & 2 deletions builder/shell-for.nix
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand Down
53 changes: 1 addition & 52 deletions lib/call-cabal-project-to-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) (
Expand Down
54 changes: 54 additions & 0 deletions overlays/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Loading