Skip to content

Commit 3e0e9ca

Browse files
committed
Merge branch 'master' of github.com:input-output-hk/haskell.nix into circuithub
2 parents a9f592e + 0b0ee03 commit 3e0e9ca

File tree

13 files changed

+109
-77
lines changed

13 files changed

+109
-77
lines changed

build.nix

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
, nixpkgsArgs ? haskellNix.nixpkgsArgs
77
, pkgs ? import nixpkgs nixpkgsArgs
88
, evalPackages ? import nixpkgs nixpkgsArgs
9-
, nixpkgsForHydra ? haskellNix.sources.nixpkgs-2105
10-
, pkgsForHydra ? import nixpkgsForHydra (nixpkgsArgs // { inherit (pkgs) system; })
9+
# This version is used to make our GitHub Action runners happy
10+
# Using `nixpkgs-unstable` currently results in:
11+
# version `GLIBCXX_3.4.30' not found
12+
, nixpkgsForGitHubAction ? haskellNix.sources.nixpkgs-2211
13+
, pkgsForGitHubAction ? import nixpkgsForGitHubAction (nixpkgsArgs // { inherit (pkgs) system; })
1114
, ifdLevel ? 1000
1215
, compiler-nix-name ? throw "No `compiler-nix-name` passed to build.nix"
1316
, haskellNix ? (import ./default.nix {})
@@ -75,12 +78,7 @@ in rec {
7578
update-docs = pkgs.buildPackages.callPackage ./scripts/update-docs.nix {
7679
generatedOptions = pkgs.callPackage ./scripts/options-doc.nix { };
7780
};
78-
# Because this is going to be used to test caching on hydra, it must not
79-
# use the darcs package from the haskell.nix we are testing. For that reason
80-
# it uses `pkgs.buildPackages.callPackage` not `haskell.callPackage`
81-
# (We could pull in darcs from a known good haskell.nix for hydra to
82-
# use)
83-
check-hydra = pkgsForHydra.buildPackages.callPackage ./scripts/check-hydra.nix {};
81+
check-hydra = pkgs.buildPackages.callPackage ./scripts/check-hydra.nix {};
8482
check-closure-size = pkgs.buildPackages.callPackage ./scripts/check-closure-size.nix {
8583
# Includes cabal-install since this is commonly used.
8684
nix-tools = pkgs.linkFarm "common-tools" [
@@ -89,21 +87,15 @@ in rec {
8987
];
9088
};
9189
check-materialization-concurrency = pkgs.buildPackages.callPackage ./scripts/check-materialization-concurrency/check.nix {};
92-
# Forcing nixpkgs-unstable here because this test makes a script
93-
# that when run will build `aeson` (used by `tests/cabal-simple`)
94-
# and we currently do not build that on hydra for nixpkgs-2205 (used by `pkgs`).
95-
# Using nixpkgs-unstable should allow buildkite to find what it needs
96-
# in the hydra cache when it runs the script.
97-
check-path-support = (import haskellNix.sources.nixpkgs-unstable nixpkgsArgs)
98-
.buildPackages.callPackage ./scripts/check-path-support.nix {
90+
check-path-support = pkgsForGitHubAction.buildPackages.callPackage ./scripts/check-path-support.nix {
9991
inherit compiler-nix-name;
10092
};
10193
};
10294

10395
# These are pure parts of maintainer-script so they can be built by hydra
10496
# and added to the cache to speed up buildkite.
10597
maintainer-script-cache = pkgs.recurseIntoAttrs (
106-
(pkgs.lib.optionalAttrs (pkgsForHydra.system == "x86_64-linux") {
98+
(pkgs.lib.optionalAttrs (pkgs.system == "x86_64-linux") {
10799
inherit (maintainer-scripts) check-hydra;
108100
})
109101
// (pkgs.lib.optionalAttrs (ifdLevel > 2) {

builder/comp-builder.nix

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,11 @@ let
201201
++ lib.optional stdenv.hostPlatform.isLinux (enableFeature enableDeadCodeElimination "split-sections")
202202
++ lib.optionals haskellLib.isCrossHost (
203203
map (arg: "--hsc2hs-option=" + arg) (["--cross-compile"] ++ lib.optionals (stdenv.hostPlatform.isWindows) ["--via-asm"])
204-
++ lib.optional (package.buildType == "Configure") "--configure-option=--host=${stdenv.hostPlatform.config}" )
204+
++ lib.optional (package.buildType == "Configure") "--configure-option=--host=${
205+
# Older ghcjs patched config.sub to support "js-unknown-ghcjs" (not "javascript-unknown-ghcjs")
206+
if stdenv.hostPlatform.isGhcjs && builtins.compareVersions defaults.ghc.version "9" < 0
207+
then "js-unknown-ghcjs"
208+
else stdenv.hostPlatform.config}" )
205209
++ configureFlags
206210
++ (ghc.extraConfigureFlags or [])
207211
++ lib.optional enableDebugRTS "--ghc-option=-debug"
@@ -373,21 +377,21 @@ let
373377
mainProgram = exeName;
374378
};
375379

376-
propagatedBuildInputs =
377-
frameworks # Frameworks will be needed at link time
380+
propagatedBuildInputs = haskellLib.checkUnique "${ghc.targetPrefix}${fullName} propagatedBuildInputs" (
381+
haskellLib.uniqueWithName frameworks # Frameworks will be needed at link time
378382
# Not sure why pkgconfig needs to be propagatedBuildInputs but
379383
# for gi-gtk-hs it seems to help.
380-
++ map pkgs.lib.getDev (builtins.concatLists pkgconfig)
384+
++ haskellLib.uniqueWithName (map pkgs.lib.getDev (builtins.concatLists pkgconfig))
381385
# These only need to be propagated for library components (otherwise they
382386
# will be in `buildInputs`)
383-
++ lib.optionals (haskellLib.isLibrary componentId) configFiles.libDeps
387+
++ lib.optionals (haskellLib.isLibrary componentId) configFiles.libDeps # libDeps is already deduplicated
384388
++ lib.optionals (stdenv.hostPlatform.isWindows)
385-
(lib.flatten component.libs);
389+
(haskellLib.uniqueWithName (lib.flatten component.libs)));
386390

387-
buildInputs =
388-
lib.optionals (!haskellLib.isLibrary componentId) configFiles.libDeps
391+
buildInputs = haskellLib.checkUnique "${ghc.targetPrefix}${fullName} buildInputs" (
392+
lib.optionals (!haskellLib.isLibrary componentId) configFiles.libDeps # libDeps is already deduplicated
389393
++ lib.optionals (!stdenv.hostPlatform.isWindows)
390-
(lib.flatten component.libs);
394+
(haskellLib.uniqueWithName (lib.flatten component.libs)));
391395

392396
nativeBuildInputs =
393397
[ghc buildPackages.removeReferencesTo]

builder/haddock-builder.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ let
7272
outputs = ["out" "configFiles" "ghc"]
7373
++ lib.optional doHaddock' "doc";
7474

75-
propagatedBuildInputs =
76-
builtins.concatLists pkgconfig
77-
++ configFiles.libDeps;
75+
propagatedBuildInputs = haskellLib.checkUnique "${fullName} propagatedBuildInputs" (
76+
haskellLib.uniqueWithName (map lib.getDev (builtins.concatLists pkgconfig))
77+
++ configFiles.libDeps); # libDeps is already deduplicated
7878

79-
buildInputs = component.libs;
79+
buildInputs = haskellLib.uniqueWithName (lib.flatten component.libs);
8080

8181
nativeBuildInputs =
8282
[ ghc buildPackages.removeReferencesTo ]

builder/make-config-files.nix

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ let
5151
libDir = ghc.libDir or "lib/${ghcCommand}-${ghc.version}";
5252
packageCfgDir = "${libDir}/package.conf.d";
5353

54-
libDeps = map chooseDrv (
55-
(if enableDWARF then (x: map (p: p.dwarf or p) x) else x: x)
56-
((if needsProfiling then (x: map (p: p.profiled or p) x) else x: x)
57-
(map haskellLib.dependToLib component.depends))
54+
libDeps = haskellLib.uniqueWithName (
55+
map chooseDrv (
56+
(if enableDWARF then (x: map (p: p.dwarf or p) x) else x: x)
57+
((if needsProfiling then (x: map (p: p.profiled or p) x) else x: x)
58+
(map haskellLib.dependToLib component.depends))
59+
)
5860
);
5961
script = ''
6062
${target-pkg} init $configFiles/${packageCfgDir}

builder/shell-for.nix

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ let
8888
name = if (mkDrvArgs.name or null) == null then identifierName else mkDrvArgs.name;
8989

9090
# We need to remove any dependencies which would bring in selected components (see above).
91-
packageInputs = removeSelectedInputs (lib.concatMap (cfg: cfg.depends) selectedConfigs)
92-
++ additionalPackages;
91+
packageInputs = haskellLib.uniqueWithName
92+
(removeSelectedInputs (haskellLib.uniqueWithName (lib.concatMap (cfg: cfg.depends) selectedConfigs))
93+
++ additionalPackages);
9394

9495
# Add the system libraries and build tools of the selected haskell packages to the shell.
9596
# We need to remove any inputs which are selected components (see above).
@@ -98,17 +99,11 @@ let
9899
#
99100
# Also, we take care to keep duplicates out of the list, otherwise we may see
100101
# "Argument list too long" errors from bash when entering a shell.
101-
#
102-
# Version of `lib.unique` that should be fast if the name attributes are unique
103-
uniqueWithName = list:
104-
lib.concatMap lib.unique (
105-
builtins.attrValues (
106-
builtins.groupBy (x: if __typeOf x == "set" then x.name or "noname" else "notset") list));
107102
allSystemInputs = lib.concatMap (c: c.buildInputs ++ c.propagatedBuildInputs) selectedComponents;
108-
systemInputs = removeSelectedInputs (uniqueWithName allSystemInputs);
103+
systemInputs = removeSelectedInputs (haskellLib.uniqueWithName allSystemInputs);
109104

110105
nativeBuildInputs = removeSelectedInputs
111-
(uniqueWithName (lib.concatMap (c: c.executableToolDepends)
106+
(haskellLib.uniqueWithName (lib.concatMap (c: c.executableToolDepends)
112107
# When not using `exactDeps` cabal may try to build arbitrary dependencies
113108
# so in this case we need to provide the build tools for all of `hsPkgs`.
114109
# In some cases those tools may be unwanted or broken so the `allToolDeps`

compiler/ghc/default.nix

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,20 @@ let
275275
+ lib.optionalString useLLVM "+llvm"
276276
+ lib.optionalString enableDWARF "+debug_info"
277277
+ lib.optionalString targetPlatform.isGhcjs "+native_bignum+no_profiled_libs"
278-
} --docs=no-sphinx -j --verbose";
278+
} --docs=no-sphinx -j --verbose"
279+
# This is needed to prevent $GCC from emitting out of line atomics.
280+
# Those would then result in __aarch64_ldadd1_sync and others being referenced, which
281+
# we don't handle in the RTS properly yet. Until we figure out how to _properly_ deal
282+
# with the RTS_SYMBOLS in GHC, we are better off disableing the out of line atomics.
283+
+ lib.optionalString ( hostPlatform.isAarch64 && targetPlatform.isLinux && targetPlatform.isAarch64)
284+
" '*.*.ghc.c.opts += -optc-mno-outline-atomics'"
285+
# For cross compilers only the RTS should be built with -mno-outline-atomics
286+
+ lib.optionalString (!hostPlatform.isAarch64 && targetPlatform.isLinux && targetPlatform.isAarch64)
287+
" '*.rts.ghc.c.opts += -optc-mno-outline-atomics'"
288+
# The following is required if we build on aarch64-darwin for aarch64-iOS. Otherwise older
289+
# iPhones/iPads/... won't understand the compiled code, as the compiler will emit LDSETALH
290+
# + lib.optionalString (targetPlatform.???) "'*.rts.ghc.c.opts += -optc-mcpu=apple-a7 -optc-march=armv8-a+norcpc'"
291+
;
279292

280293
# When installation is done by copying the stage1 output the directory layout
281294
# is different.
@@ -319,7 +332,7 @@ stdenv.mkDerivation (rec {
319332

320333
# configure was run by configured-src already.
321334
phases = [ "unpackPhase" "patchPhase" ]
322-
++ lib.optional (ghc-patches != []) "autoreconfPhase"
335+
++ lib.optional (ghc-patches != [] && !stdenv.targetPlatform.isGhcjs) "autoreconfPhase" # autoreconf can replace config.sub with one that is missing ghcjs
323336
++ [ "configurePhase" "buildPhase"
324337
"checkPhase" "installPhase"
325338
"fixupPhase"

flake.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/default.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,4 +588,19 @@ in {
588588

589589
# How to run ldd when checking for static linking
590590
lddForTests = "${pkgs.pkgsBuildBuild.glibc.bin}/bin/ldd";
591+
592+
# Version of `lib.unique` that should be fast if the name attributes are unique
593+
uniqueWithName = list:
594+
lib.concatMap lib.unique (
595+
builtins.attrValues (
596+
builtins.groupBy (x: if __typeOf x == "set" then x.name or "noname" else "notset") list));
597+
598+
# Assert that each item in the list is unique
599+
checkUnique = msg: x:
600+
if __length x == __length (uniqueWithName x)
601+
then x
602+
else builtins.throw "Duplicate items found in ${msg} ${
603+
__toJSON (__attrNames (lib.filterAttrs (_: v: __length v > 1) (
604+
builtins.groupBy (x: if __typeOf x == "set" then x.name or "noname" else "notset") x)))
605+
}";
591606
}

lib/pkgconf-nixpkgs-map.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,10 +2552,10 @@ pkgs:
25522552
"libavc1394" = [ "libavc1394" ];
25532553
"libavif" = [ "libavif" ];
25542554
"ayatana-appindicator3-0.1" = [ "libayatana-appindicator" ];
2555-
"ayatana-appindicator-0.1" = [ "libayatana-appindicator-gtk2" ];
2555+
# "ayatana-appindicator-0.1" = [ "libayatana-appindicator-gtk2" ];
25562556
# "ayatana-appindicator3-0.1" = [ "libayatana-appindicator-gtk3" ];
25572557
"ayatana-indicator3-0.4" = [ "libayatana-indicator" ];
2558-
"ayatana-indicator-0.4" = [ "libayatana-indicator-gtk2" ];
2558+
# "ayatana-indicator-0.4" = [ "libayatana-indicator-gtk2" ];
25592559
# "ayatana-indicator3-0.4" = [ "libayatana-indicator-gtk3" ];
25602560
"libb2" = [ "libb2" ];
25612561
"baseencode" = [ "libbaseencode" ];

nix-tools/.buildkite/nix-tools-build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#! /usr/bin/env nix-shell
22
#! nix-shell -I "nixpkgs=channel:nixos-22.11" -i bash -p nixUnstable cabal-install ghc git nix-prefetch-git cacert
33

4+
# This file uses nixpkgs 22.11 to make our GHA runners happy
5+
# Using `nixpkgs-unstable` currently results in:
6+
# version `GLIBCXX_3.4.30' not found
7+
48
# The `nix-shell` is set to run without `--pure`.
59
# It is possible to use `--pure` if we need to, but it requires setting these.
610
# export LANG=en_US.UTF-8
@@ -22,7 +26,7 @@ cabal new-update
2226

2327
echo
2428
echo "+++ Run stable version of make-install-plan and plan-to-nix"
25-
nix build --impure --expr '(let haskellNix = import (builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz") {}; in (import haskellNix.sources.nixpkgs haskellNix.nixpkgsArgs).haskell-nix.nix-tools.ghc8107)' -o nt
29+
nix build --impure --expr '(let haskellNix = import (builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz") {}; in (import haskellNix.sources.nixpkgs-2211 haskellNix.nixpkgsArgs).haskell-nix.nix-tools.ghc8107)' -o nt
2630
./nt/bin/make-install-plan
2731
rm -rf .buildkite/nix1
2832
./nt/bin/plan-to-nix --output .buildkite/nix1 --plan-json dist-newstyle/cache/plan.json

0 commit comments

Comments
 (0)