Skip to content

Commit 4e77783

Browse files
committed
Fix support for pkgsStatic
This should fix using both the haskell.nix GHC and nixpkgs GHC with pkgsStatic: ``` nix-build -E '((import ./. {}).pkgs.pkgsStatic.haskell-nix.tool "ghc9122" "hello" {})' nix-build -E '((import ./. {}).pkgs.pkgsStatic.haskell-nix.tool "ghc9122" "hello" { compilerSelection = p: p.haskell.compiler; })' ``` Fixes #2421
1 parent fb04d42 commit 4e77783

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed

builder/ghc-for-component-wrapper.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let
2525
docDir = "$wrappedGhc/share/doc/ghc/html";
2626
# For musl we can use haddock from the buildGHC
2727
haddock = if stdenv.hostPlatform.isMusl
28-
then ghc.buildGHC
28+
then ghc.buildGHC or ghc
2929
else ghc;
3030

3131
script = ''

ci.nix

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -82,36 +82,40 @@
8282
# of 'lib.systems.examples' are not understood between all versions
8383
let lib = nixpkgs.lib;
8484
in lib.optionalAttrs (nixpkgsName == "unstable"
85-
&& (__match ".*llvm" compiler-nix-name == null)
86-
&& !builtins.elem compiler-nix-name ["ghc9102"]) {
87-
inherit (lib.systems.examples) ghcjs;
88-
} // lib.optionalAttrs (nixpkgsName == "unstable"
89-
&& (__match ".*llvm" compiler-nix-name == null)
90-
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928"])
91-
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
92-
inherit (lib.systems.examples) mingwW64;
93-
} // lib.optionalAttrs (nixpkgsName == "unstable"
94-
&& (__match ".*llvm" compiler-nix-name == null)
95-
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902" "ghc928" "ghc948"])
96-
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
97-
inherit (lib.systems.examples) ucrt64;
98-
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
99-
# Musl cross only works on linux
100-
# aarch64 cross only works on linux
101-
inherit (lib.systems.examples) musl64 aarch64-multiplatform;
102-
} // lib.optionalAttrs (__match ".*llvm" compiler-nix-name == null && system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
103-
# Out llvm versions of GHC seem to break for musl32
104-
inherit (lib.systems.examples) musl32;
105-
} // lib.optionalAttrs (system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
106-
inherit (lib.systems.examples) aarch64-android-prebuilt;
107-
} // lib.optionalAttrs (system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948" "ghc91320250523"]) {
108-
inherit (lib.systems.examples) armv7a-android-prebuilt;
109-
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902"]) {
110-
# TODO fix this for the compilers we build with hadrian (ghc >=9.4)
111-
inherit (lib.systems.examples) aarch64-multiplatform-musl;
112-
} // lib.optionalAttrs (system == "aarch64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902"]) {
113-
inherit (lib.systems.examples) aarch64-multiplatform-musl;
114-
};
85+
&& __match ".*llvm" compiler-nix-name == null
86+
&& builtins.elem system ["aarch64-linux" "x86_64-linux"]) {
87+
static = p: p.pkgsStatic;
88+
} // lib.optionalAttrs (nixpkgsName == "unstable"
89+
&& (__match ".*llvm" compiler-nix-name == null)
90+
&& !builtins.elem compiler-nix-name ["ghc9102"]) {
91+
inherit (lib.systems.examples) ghcjs;
92+
} // lib.optionalAttrs (nixpkgsName == "unstable"
93+
&& (__match ".*llvm" compiler-nix-name == null)
94+
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928"])
95+
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
96+
inherit (lib.systems.examples) mingwW64;
97+
} // lib.optionalAttrs (nixpkgsName == "unstable"
98+
&& (__match ".*llvm" compiler-nix-name == null)
99+
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902" "ghc928" "ghc948"])
100+
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
101+
inherit (lib.systems.examples) ucrt64;
102+
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
103+
# Musl cross only works on linux
104+
# aarch64 cross only works on linux
105+
inherit (lib.systems.examples) musl64 aarch64-multiplatform;
106+
} // lib.optionalAttrs (__match ".*llvm" compiler-nix-name == null && system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
107+
# Out llvm versions of GHC seem to break for musl32
108+
inherit (lib.systems.examples) musl32;
109+
} // lib.optionalAttrs (system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
110+
inherit (lib.systems.examples) aarch64-android-prebuilt;
111+
} // lib.optionalAttrs (system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948" "ghc91320250523"]) {
112+
inherit (lib.systems.examples) armv7a-android-prebuilt;
113+
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902"]) {
114+
# TODO fix this for the compilers we build with hadrian (ghc >=9.4)
115+
inherit (lib.systems.examples) aarch64-multiplatform-musl;
116+
} // lib.optionalAttrs (system == "aarch64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902"]) {
117+
inherit (lib.systems.examples) aarch64-multiplatform-musl;
118+
};
115119
isDisabled = d: d.meta.disabled or false;
116120
in
117121
dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: pinnedNixpkgsSrc:
@@ -140,8 +144,10 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: pinnedNixpkgsSrc:
140144
}
141145
//
142146
dimension "Cross system" (crossSystems nixpkgsName evalPackages compiler-nix-name) (crossSystemName: crossSystem:
143-
# Cross builds
144-
let pkgs = import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system crossSystem; });
147+
let pkgs =
148+
if builtins.isAttrs crossSystem
149+
then import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system crossSystem; })
150+
else crossSystem (import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system; }));
145151
build = import ./build.nix { inherit pkgs evalPackages ifdLevel compiler-nix-name haskellNix; };
146152
in pkgs.recurseIntoAttrs (pkgs.lib.optionalAttrs (ifdLevel >= 1) ({
147153
roots = pkgs.haskell-nix.roots' { inherit compiler-nix-name evalPackages; } ifdLevel // {

compiler/ghc/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let self =
3939

4040
, # Whether to build dynamic libs for the standard library (on the target
4141
# platform). Static libs are always built.
42-
enableShared ? !haskell-nix.haskellLib.isCrossTarget
42+
enableShared ? !haskell-nix.haskellLib.isCrossTarget && !stdenv.targetPlatform.isStatic
4343

4444
, enableLibraryProfiling ? true
4545

@@ -328,7 +328,7 @@ let
328328
# see https://gitlab.haskell.org/ghc/ghc/blob/master/hadrian/doc/flavours.md
329329
hadrianArgs = "--flavour=${
330330
(if targetPlatform.isGhcjs then "quick" else "default")
331-
+ lib.optionalString (!enableShared) "+no_dynamic_ghc"
331+
+ lib.optionalString (!enableShared) "+no_dynamic_libs+no_dynamic_ghc"
332332
+ lib.optionalString useLLVM "+llvm"
333333
+ lib.optionalString enableDWARF "+debug_info"
334334
+ lib.optionalString ((enableNativeBignum && hadrianHasNativeBignumFlavour) || targetPlatform.isGhcjs) "+native_bignum"

0 commit comments

Comments
 (0)