Skip to content

Drop Hadrian Materialization #2339

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 19 commits into from
Mar 28, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 14 additions & 7 deletions ci.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
ghc910 = true;
ghc912 = true;
} // nixpkgs.lib.optionalAttrs (nixpkgsName == "unstable") {
ghc96 = false;
ghc96 = true;
ghc96X = true;
ghc98 = true;
ghc98llvm = false;
Expand Down Expand Up @@ -121,12 +121,18 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: pinnedNixpkgsSrc:
# Native builds
# TODO: can we merge this into the general case by picking an appropriate "cross system" to mean native?
native = pkgs.recurseIntoAttrs ({
roots = pkgs.haskell-nix.roots' compiler-nix-name ifdLevel;
ghc = pkgs.buildPackages.haskell-nix.compiler.${compiler-nix-name};
roots = pkgs.haskell-nix.roots' { inherit compiler-nix-name evalPackages; } ifdLevel;
} // pkgs.lib.optionalAttrs runTests {
inherit (build) tests tools maintainer-scripts maintainer-script-cache;
} // pkgs.lib.optionalAttrs (ifdLevel >= 3) {
hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; inherit evalPackages compiler-nix-name; }).getComponent "exe:hello";
} // pkgs.lib.optionalAttrs (ifdLevel >= 3) rec {
hello = (pkgs.haskell-nix.hackage-package ({ name = "hello"; version = "1.0.0.2"; inherit evalPackages compiler-nix-name; }
// lib.optionalAttrs (builtins.compareVersions pkgs.buildPackages.haskell-nix.compiler.${compiler-nix-name}.version "9.13" >= 0) {
shell.tools.hoogle.cabalProjectLocal = ''
allow-newer: *:*
'';
})).getComponent "exe:hello";
# Make sure the default shell tools (hoogle) are built
simple-shell = (hello.project.flake {}).devShells.default;
});
}
//
Expand All @@ -135,8 +141,9 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: pinnedNixpkgsSrc:
let pkgs = import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system crossSystem; });
build = import ./build.nix { inherit pkgs evalPackages ifdLevel compiler-nix-name haskellNix; };
in pkgs.recurseIntoAttrs (pkgs.lib.optionalAttrs (ifdLevel >= 1) ({
roots = pkgs.haskell-nix.roots' compiler-nix-name ifdLevel;
ghc = pkgs.buildPackages.haskell-nix.compiler.${compiler-nix-name};
roots = pkgs.haskell-nix.roots' { inherit compiler-nix-name evalPackages; } ifdLevel // {
ghc = pkgs.buildPackages.haskell-nix.compiler.${compiler-nix-name}.override { hadrianEvalPackages = evalPackages; };
};
# TODO: look into cross compiling ghc itself
# ghc = pkgs.haskell-nix.compiler.${compiler-nix-name};
# TODO: look into making tools work when cross compiling
Expand Down
44 changes: 18 additions & 26 deletions compiler/ghc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ let self =

# extra values we want to have available as passthru values.
, extra-passthru ? {}

, hadrianEvalPackages ? buildPackages
}@args:

assert !(enableIntegerSimple || enableNativeBignum) -> gmp != null;
Expand All @@ -99,7 +101,9 @@ let
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
inherit (haskell-nix.haskellLib) isCrossTarget;

inherit (bootPkgs) ghc;
ghc = if bootPkgs.ghc.isHaskellNixCompiler or false
then bootPkgs.ghc.override { inherit hadrianEvalPackages; }
else bootPkgs.ghc;

ghcHasNativeBignum = builtins.compareVersions ghc-version "9.0" >= 0;
hadrianHasNativeBignumFlavour = builtins.compareVersions ghc-version "9.6" >= 0;
Expand Down Expand Up @@ -250,7 +254,7 @@ let
# value for us.
installStage1 = useHadrian && (with haskell-nix.haskellLib; isCrossTarget || isNativeMusl);

hadrian =
hadrianProject =
let
compiler-nix-name =
if builtins.compareVersions ghc-version "9.4.7" < 0
Expand All @@ -259,28 +263,12 @@ let
then "ghc964"
else "ghc962";
in
buildPackages.haskell-nix.tool compiler-nix-name "hadrian" {
buildPackages.haskell-nix.cabalProject' {
inherit compiler-nix-name;
name = "hadrian";
compilerSelection = p: p.haskell.compiler;
index-state = buildPackages.haskell-nix.internalHackageIndexState;
# Verions of hadrian that comes with 9.6 depends on `time`
materialized =
if builtins.compareVersions ghc-version "9.4" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc92
else if builtins.compareVersions ghc-version "9.4.8" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc947
else if builtins.compareVersions ghc-version "9.6" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc94
else if builtins.compareVersions ghc-version "9.6.5" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc964
else if builtins.compareVersions ghc-version "9.8" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc96
else if builtins.compareVersions ghc-version "9.8.2" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc981
else if builtins.compareVersions ghc-version "9.9" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc98
else if builtins.compareVersions ghc-version "9.11" < 0
then ../../materialized/${compiler-nix-name}/hadrian-ghc910
else null;
evalPackages = hadrianEvalPackages;
modules = [{
reinstallableLibGhc = false;
# Apply the patches in a way that does not require using something
Expand Down Expand Up @@ -310,6 +298,8 @@ let
};
};

hadrian = hadrianProject.hsPkgs.hadrian.components.exes.hadrian;

# For a discription of hadrian command line args
# see https://gitlab.haskell.org/ghc/ghc/blob/master/hadrian/README.md
# For build flavours and flavour transformers
Expand Down Expand Up @@ -389,7 +379,7 @@ let
};

in
stdenv.mkDerivation (rec {
haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
version = ghc-version;
name = "${targetPrefix}ghc-${version}" + lib.optionalString (useLLVM) "-llvm";

Expand Down Expand Up @@ -677,7 +667,7 @@ stdenv.mkDerivation (rec {
'';

passthru = {
inherit bootPkgs targetPrefix libDir llvmPackages enableShared useLLVM;
inherit bootPkgs targetPrefix libDir llvmPackages enableShared useLLVM hadrian hadrianProject;

# Our Cabal compiler name
haskellCompilerName = "ghc-${version}";
Expand Down Expand Up @@ -771,7 +761,9 @@ stdenv.mkDerivation (rec {
smallAddressSpace = lib.makeOverridable self (args // {
disableLargeAddressSpace = true;
});
} // extra-passthru;
} // extra-passthru // {
buildGHC = extra-passthru.buildGHC.override { inherit hadrianEvalPackages; };
};

meta = {
homepage = "https://haskell.org/ghc";
Expand Down Expand Up @@ -915,5 +907,5 @@ stdenv.mkDerivation (rec {
cd ../../..
runHook postInstall
'';
});
}));
in self
4 changes: 2 additions & 2 deletions docs/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pushd tutorials

## Getting started
pushd getting-started
nix-build
nix-build -A hsPkgs.hello.components.exes.hello
nix-shell --pure --run "cabal build hello"
popd

Expand Down Expand Up @@ -50,4 +50,4 @@ pushd iohk-nix
nix build --accept-flake-config
popd

popd
popd
2 changes: 1 addition & 1 deletion docs/tutorials/development/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ in pkgs.haskell-nix.project {
src = ./.;
};
# Specify the GHC version to use.
compiler-nix-name = "ghc92"; # Not required for `stack.yaml` based projects.
compiler-nix-name = "ghc96"; # Not required for `stack.yaml` based projects.
}
18 changes: 3 additions & 15 deletions docs/tutorials/development/nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,10 @@
"homepage": "https://input-output-hk.github.io/haskell.nix",
"owner": "input-output-hk",
"repo": "haskell.nix",
"rev": "d61a3f429425e57108ca2b5355f10df94dafe39d",
"sha256": "1fra8grb1jzfb794vm9kw090bb5kiq5g11xmb3nkm2lk60yixjx3",
"rev": "3e51feeed915183f4aaca8ce7761f61e5436867c",
"sha256": "18v45m7alipxvs47nfnc2hsk50gvlph8ig3x25qdp799z5d9wsp7",
"type": "tarball",
"url": "https://github.com/input-output-hk/haskell.nix/archive/d61a3f429425e57108ca2b5355f10df94dafe39d.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "release-22.11",
"description": "Nix Packages collection",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b7ce17b1ebf600a72178f6302c77b6382d09323f",
"sha256": "sha256-uNvD7fzO5hNlltNQUAFBPlcEjNG5Gkbhl/ROiX+GZU4=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/b7ce17b1ebf600a72178f6302c77b6382d09323f.tar.gz",
"url": "https://github.com/input-output-hk/haskell.nix/archive/3e51feeed915183f4aaca8ce7761f61e5436867c.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
6 changes: 3 additions & 3 deletions docs/tutorials/getting-started-flakes/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
helloProject =
final.haskell-nix.project' {
src = ./.;
compiler-nix-name = "ghc92";
compiler-nix-name = "ghc96";
# This is used by `nix develop .` to open a shell for use with
# `cabal`, `hlint` and `haskell-language-server`
shell.tools = {
cabal = {};
hlint = {};
haskell-language-server = {};
# hlint = {};
# haskell-language-server = {};
};
# Non-Haskell shell tools go here
shell.buildInputs = with pkgs; [
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/getting-started/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ in pkgs.haskell-nix.project {
src = ./.;
};
# Specify the GHC version to use.
compiler-nix-name = "ghc92"; # Not required for `stack.yaml` based projects.
compiler-nix-name = "ghc96"; # Not required for `stack.yaml` based projects.
}
18 changes: 3 additions & 15 deletions docs/tutorials/getting-started/nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,10 @@
"homepage": "https://input-output-hk.github.io/haskell.nix",
"owner": "input-output-hk",
"repo": "haskell.nix",
"rev": "d61a3f429425e57108ca2b5355f10df94dafe39d",
"sha256": "1fra8grb1jzfb794vm9kw090bb5kiq5g11xmb3nkm2lk60yixjx3",
"rev": "3e51feeed915183f4aaca8ce7761f61e5436867c",
"sha256": "18v45m7alipxvs47nfnc2hsk50gvlph8ig3x25qdp799z5d9wsp7",
"type": "tarball",
"url": "https://github.com/input-output-hk/haskell.nix/archive/d61a3f429425e57108ca2b5355f10df94dafe39d.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "release-21.05",
"description": "Nix Packages collection",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5f244caea76105b63d826911b2a1563d33ff1cdc",
"sha256": "1xlgynfw9svy7nvh9nkxsxdzncv9hg99gbvbwv3gmrhmzc3sar75",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/5f244caea76105b63d826911b2a1563d33ff1cdc.tar.gz",
"url": "https://github.com/input-output-hk/haskell.nix/archive/3e51feeed915183f4aaca8ce7761f61e5436867c.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
6 changes: 3 additions & 3 deletions docs/tutorials/getting-started/shell.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(import ./default.nix).shellFor {
tools = {
cabal = "latest";
hlint = "latest";
haskell-language-server = "latest";
# hlint = "latest";
# haskell-language-server = "latest";
};
}
}
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
# for core of haskell.nix E.g. this should always work:
# nix build .#roots.x86_64-linux --accept-flake-config --option allow-import-from-derivation false
roots = forEachSystem (system:
self.legacyPackagesUnstable.${system}.haskell-nix.roots defaultCompiler);
self.legacyPackagesUnstable.${system}.haskell-nix.roots { compiler-nix-name = defaultCompiler; });

# Note: `nix flake check` evaluates outputs for all platforms, and haskell.nix
# uses IFD heavily, you have to have the ability to build for all platforms
Expand Down
2 changes: 1 addition & 1 deletion lib/call-cabal-project-to-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
, cabalProjectLocal ? null
, cabalProjectFreeze ? null
, caller ? "callCabalProjectToNix" # Name of the calling function for better warning messages
, compilerSelection ? p: p.haskell-nix.compiler
, compilerSelection ? p: builtins.mapAttrs (_: x: x.override { hadrianEvalPackages = evalPackages; }) p.haskell-nix.compiler
, ghcOverride ? null # Used when we need to set ghc explicitly during bootstrapping
, configureArgs ? "" # Extra arguments to pass to `cabal v2-configure`.
# `--enable-tests --enable-benchmarks` are included by default.
Expand Down
10 changes: 2 additions & 8 deletions lib/make-compiler-deps.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ lib, runCommand }:
let
makeCompilerDeps = ghc: ghc // {
ghc: ghc // {
cachedDeps = runCommand "${ghc.name}-deps" {}
# First checks that ghc-pkg runs first with `--version` as failures in the `for` and
# `if` statements will be masked.
Expand Down Expand Up @@ -34,9 +33,4 @@ let
fi
done
'';
} // lib.optionalAttrs (ghc ? dwarf) {
dwarf = makeCompilerDeps ghc.dwarf;
} // lib.optionalAttrs (ghc ? smallAddressSpace) {
smallAddressSpace = makeCompilerDeps ghc.smallAddressSpace;
};
in makeCompilerDeps
}
Loading
Loading