Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into hkm/embed-file
Browse files Browse the repository at this point in the history
# Conflicts:
#	test/default.nix
  • Loading branch information
hamishmack committed Nov 11, 2024
2 parents 1e19198 + c9a0b67 commit 8db37b7
Show file tree
Hide file tree
Showing 983 changed files with 27,387 additions and 4,631 deletions.
50 changes: 24 additions & 26 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,49 +139,40 @@ jobs:

hydra-ifdLevel-0-and-1:
runs-on: [self-hosted, linux]
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: "Check that jobset will evaluate in Hydra at ifdLevel 0 and 1"
run: |
nix-build build.nix -A maintainer-scripts.check-hydra -o check-hydra.sh
./check-hydra.sh --arg ifdLevel 0
./check-hydra.sh --arg ifdLevel 1
sed -i 's/runningHydraEvalTest = false;/runningHydraEvalTest = true;/' flake.nix
sed -i 's/ifdLevel = 3;/ifdLevel = 0;/' flake.nix
./check-hydra.sh
sed -i 's/ifdLevel = 0;/ifdLevel = 1;/' flake.nix
./check-hydra.sh
hydra-ifdLevel-2:
runs-on: [self-hosted, linux]
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: "Check that jobset will evaluate in Hydra at ifdLevel 2"
run: |
nix-build build.nix -A maintainer-scripts.check-hydra -o check-hydra.sh
./check-hydra.sh --arg ifdLevel 2
sed -i 's/runningHydraEvalTest = false;/runningHydraEvalTest = true;/' flake.nix
sed -i 's/ifdLevel = 3;/ifdLevel = 2;/' flake.nix
./check-hydra.sh
hydra-ifdLevel-3-and-ghc-8-10:
hydra-ifdLevel-3:
runs-on: [self-hosted, linux]
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: "Check that jobset will evaluate in Hydra at ifdLevel 3 and ghc 8.10"
- name: "Check that jobset will evaluate in Hydra at ifdLevel 3"
run: |
nix-build build.nix -A maintainer-scripts.check-hydra -o check-hydra.sh
./check-hydra.sh --arg ifdLevel 3 --arg include 'x: __substring 0 6 x == "ghc810"'
hydra-ifdLevel-3-and-ghc-9-2:
runs-on: [self-hosted, linux]
steps:
- uses: actions/checkout@v4
- name: "Check that jobset will evaluate in Hydra at ifdLevel 3 and ghc 9.2"
run: |
nix-build build.nix -A maintainer-scripts.check-hydra -o check-hydra.sh
./check-hydra.sh --arg ifdLevel 3 --arg include 'x: __substring 0 5 x == "ghc92"'
hydra-ifdLevel-3-and-not-ghc-8-10-or-9-2:
runs-on: [self-hosted, linux]
steps:
- uses: actions/checkout@v4
- name: "Check that jobset will evaluate in Hydra at ifdLevel 3 and not (ghc 8.10 or ghc 9.2)"
run: |
nix-build build.nix -A maintainer-scripts.check-hydra -o check-hydra.sh
./check-hydra.sh --arg ifdLevel 3 --arg include 'x: !(__substring 0 6 x == "ghc810" || __substring 0 5 x == "ghc92")'
sed -i 's/runningHydraEvalTest = false;/runningHydraEvalTest = true;/' flake.nix
./check-hydra.sh
closure-size:
runs-on: [self-hosted, linux]
Expand Down Expand Up @@ -227,13 +218,20 @@ jobs:
- name: "Check that the haskell.nix roots do not require IFDs"
run: nix build .#roots.x86_64-linux --accept-flake-config --option allow-import-from-derivation false

hydra-without-remote-builders:
hydra-without-remote-builders-ghc8107:
runs-on: [self-hosted, linux]
steps:
- uses: actions/checkout@v4
- name: "Check that evaluation of hydra jobs works without using remote builders"
- name: "Check that evaluation of hydra jobs works without using remote builders for GHC 8.10.7"
run: nix path-info --derivation .#requiredJobs.x86_64-darwin.required-unstable-ghc8107-native --show-trace --builders ''

hydra-without-remote-builders-ghc9101:
runs-on: [self-hosted, linux]
steps:
- uses: actions/checkout@v4
- name: "Check that evaluation of hydra jobs works without using remote builders for GHC 9.10.1"
run: nix path-info --derivation .#requiredJobs.x86_64-darwin.required-unstable-ghc9101-native --show-trace --builders ''

hix-cabal:
runs-on: [self-hosted, linux]
steps:
Expand Down
8 changes: 4 additions & 4 deletions build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ in rec {
pkgs.recurseIntoAttrs ({
cabal-latest = tool compiler-nix-name "cabal" ({
inherit evalPackages;
} // pkgs.lib.optionalAttrs (ghcFromTo "9.10" "9.12") {
} // pkgs.lib.optionalAttrs (ghcFromTo "9.12" "9.13") {
cabalProjectLocal = builtins.readFile ./test/cabal.project.local;
});
} // pkgs.lib.optionalAttrs (__compareVersions haskell.compiler.${compiler-nix-name}.version "9.8" < 0) {
Expand Down Expand Up @@ -62,7 +62,7 @@ in rec {
inherit evalPackages;
src = pkgs.haskell-nix.sources."hls-2.2";
};
} // pkgs.lib.optionalAttrs (ghcFromTo "9.0" "9.11") {
} // pkgs.lib.optionalAttrs (ghcFromTo "9.0" "9.8.3" || ghcFromTo "9.10" "9.11") {
"hls-29" = tool compiler-nix-name "haskell-language-server" {
inherit evalPackages;
src = pkgs.haskell-nix.sources."hls-2.9";
Expand All @@ -77,14 +77,14 @@ in rec {
maintainer-scripts = pkgs.dontRecurseIntoAttrs {
update-hackage = import ./scripts/update-hackage.nix {
inherit (pkgs) stdenv lib writeScript coreutils glibc git
openssh nixFlakes gawk bash curl findutils;
openssh nixVersions gawk bash curl findutils;
# Update scripts use the internal nix-tools (compiled with a fixed GHC version)
nix-tools = haskell.nix-tools-unchecked;
inherit (haskell) update-index-state-hashes cabal-issue-8352-workaround;
};
update-stackage = haskell.callPackage ./scripts/update-stackage.nix {
inherit (pkgs) stdenv lib writeScript coreutils glibc git
openssh nixFlakes gawk bash curl findutils;
openssh nixVersions gawk bash curl findutils;
# Update scripts use the internal nix-tools (compiled with a fixed GHC version)
nix-tools = haskell.nix-tools-unchecked;
inherit (haskell) cabal-issue-8352-workaround;
Expand Down
5 changes: 4 additions & 1 deletion builder/comp-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let self =
# (not just the one we are building).
# Enable for tests in packages that use cabal-doctest.
( haskellLib.isTest componentId &&
lib.any (x: x.identifier.name or "" == "cabal-doctest") package.setup-depends
lib.any (x: x.identifier.name or "" == "cabal-doctest") (package.setup-depends ++ setup.config.depends or [])
)
, allComponent # Used when `configureAllComponents` is set to get a suitable configuration.

Expand Down Expand Up @@ -197,6 +197,9 @@ let
"--with-gcc=${pkgsBuildBuild.emscripten}/bin/emcc"
"--with-ld=${pkgsBuildBuild.emscripten}/bin/emcc"
]
++ lib.optionals (stdenv.hostPlatform.isGhcjs && stdenv.buildPlatform.isDarwin) [
"--ar-options=--format=gnu" # Avoid `--format=darwin` it can cause `section too large` errors
]
++ [ # other flags
(disableFeature dontStrip "executable-stripping")
(disableFeature dontStrip "library-stripping")
Expand Down
8 changes: 1 addition & 7 deletions builder/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@ let
then pkgs.path
else pkgs.haskell-nix.sources.nixpkgs-2205;
nixpkgsHoogle = import (nixpkgs + /pkgs/development/haskell-modules/hoogle.nix);
in { packages ? [], hoogle ? pkgs.buildPackages.haskell-nix.tool "ghc928" "hoogle" {
inherit evalPackages;
version = "5.0.18.3";
# index-state = pkgs.haskell-nix.internalHackageIndexState;
index-state = "2023-06-05T00:00:00Z";
}
}:
in { packages ? [], hoogle }:
let
haskellPackages = {
# For musl we can use haddock from the buildGHC
Expand Down
1 change: 1 addition & 0 deletions builder/ghc-for-component-wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ let
''
+ lib.optionalString (stdenv.targetPlatform.isMusl && !haskellLib.isNativeMusl && builtins.compareVersions ghc.version "9.9" >0) ''
ln -s $wrappedGhc/bin/${targetPrefix}unlit $wrappedGhc/bin/unlit
ln -s $wrappedGhc/bin/${ghcCommand}-iserv $wrappedGhc/bin/ghc-iserv
ln -s $wrappedGhc/bin/${ghcCommand}-iserv-prof $wrappedGhc/bin/ghc-iserv-prof
''
Expand Down
2 changes: 1 addition & 1 deletion builder/make-config-files.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let
# Sort and remove duplicates from nonReinstallablePkgs.
# That way changes to the order of nonReinstallablePkgs does not require rebuilds.
nonReinstallablePkgs' = __attrNames (lib.genAttrs nonReinstallablePkgs (x: x));
nonReinstallablePkgs' = __attrNames (lib.genAttrs (component.pre-existing or [] ++ nonReinstallablePkgs) (x: x));

ghc = if enableDWARF then defaults.ghc.dwarf else defaults.ghc;

Expand Down
26 changes: 12 additions & 14 deletions builder/shell-for.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, stdenv, mkShell, glibcLocales, pkgconfig, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, pkgsBuildBuild, evalPackages, compiler }:
{ lib, stdenv, mkShell, glibcLocales, ghcForComponent, makeConfigFiles, hsPkgs, hoogleLocal, haskellLib, pkgsBuildBuild, evalPackages, compiler }:

{ # `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 @@ -68,7 +68,8 @@ let
selectedComponents =
lib.filter isSelectedComponent (lib.attrValues transitiveDependenciesComponents);

allHsPkgsComponents = lib.concatMap haskellLib.getAllComponents (builtins.attrValues hsPkgs);
allHsPkgsComponents = lib.concatMap haskellLib.getAllComponents
(lib.filter (x: !(x.isRedirect or false)) (builtins.attrValues hsPkgs));

# Given a list of `depends`, removes those which are selected components
removeSelectedInputs =
Expand Down Expand Up @@ -114,9 +115,10 @@ let
# Set up a "dummy" component to use with ghcForComponent.
component = {
depends = packageInputs;
libs = [];
pkgconfig = [];
frameworks = [];
pre-existing = lib.concatMap (x: (haskellLib.dependToLib x).config.pre-existing or []) packageInputs;
libs = lib.concatMap (x: (haskellLib.dependToLib x).config.libs or []) packageInputs;
pkgconfig = lib.concatMap (x: (haskellLib.dependToLib x).config.pkgconfig or []) packageInputs;
frameworks = lib.concatMap (x: (haskellLib.dependToLib x).config.frameworks or []) packageInputs;
doExactConfig = false;
};
configFiles = makeConfigFiles {
Expand All @@ -142,21 +144,17 @@ let
pname = p.identifier.name;
haddockDir = p.haddockDir;
};
in hoogleLocal ({
in hoogleLocal {
packages = map docPackage (haskellLib.flatLibDepends component);

# Need to add hoogle to hsPkgs.
# inherit (hsPkgs) hoogle;
} // (
lib.optionalAttrs (args ? tools && args.tools ? hoogle) {
hoogle = pkgsBuildBuild.haskell-nix.hackage-tool (
haskellLib.versionOrModToMods args.tools.hoogle ++ [{
hoogle = pkgsBuildBuild.haskell-nix.hackage-tool (
lib.optionals (args ? tools && args.tools ? hoogle) (haskellLib.versionOrModToMods args.tools.hoogle)
++ [{
name = "hoogle";
compiler-nix-name = compiler.nix-name;
inherit evalPackages;
}]);
}
));
};

mkDrvArgs = builtins.removeAttrs args ["packages" "components" "additional" "withHoogle" "tools"];
in
Expand Down
76 changes: 76 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,82 @@
This file contains a summary of changes to Haskell.nix and `nix-tools`
that will impact users.

## Sep 17, 2024

Cabal projects now use the more granular Unit IDs from plan.json
to identify packages. This allows for different versions of a
package to be used when building `built-tool-depends` and setup
dependencies.

Overrides in the `modules` argument apply to all versions of
the package. However to make this work we needed to make
each `packages.somepackage` an option (instead of using an
`attrsOf` the submodule type).

It is now an error to override a package that is not in the
plan. This can be a problem if different GHC versions, target
platforms, or cabal flag settings cause the package to be
excluded from the plan. Adding `package-keys` can tell
haskell.nix to include the option anyway:

```
modules = [{
# Tell haskell.nix that `somepackage` may exist.
package-keys = ["somepackage"];
# Now the following will not cause an error even
# if `somepackage` is not in the plan
packages.somepackage.flags.someflag = true;
}];
```

There is a helper function you can use to add `package-keys`
for all of the `builtins.attrNames` of `packages`:

```
modules = [(pkgs.haskell-nix.haskellLib.addPackageKeys {
packages.somepackage.flags.someflag = true;
})];
```

Do not use the module's `pkgs` arg to look `addPackageKeys` up
though or it will result an `infinite recursion` error.

Code that uses `options.packages` will also need to be updated.
For instance the following code that uses `options.packages`
to set `--Werror` for local packages:

```
({ lib, ... }: {
options.packages = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule (
{ config, lib, ... }:
lib.mkIf config.package.isLocal
{
configureFlags = [ "--ghc-option=-Werror"];
}
));
};
})
```

Now needs to do it for each of the entry in `config.package-keys`
instead of using `attrsOf`:

```
({ config, lib, ... }: {
options.packages = lib.genAttrs config.package-keys (_:
lib.mkOption {
type = lib.types.submodule (
{ config, lib, ... }:
lib.mkIf config.package.isLocal
{
configureFlags = [ "--ghc-option=-Werror"];
}
);
});
})
```

## Jun 5, 2024

Haskell.nix now respects the `pre-existing` packages selected
Expand Down
23 changes: 11 additions & 12 deletions ci.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,19 @@
# from here (so that is no longer cached) also remove ./materialized/ghcXXX.
# Update supported-ghc-versions.md to reflect any changes made here.
nixpkgs.lib.optionalAttrs (nixpkgsName == "R2405") {
ghc94 = false;
ghc96 = false;
ghc98 = false;
} // nixpkgs.lib.optionalAttrs (nixpkgsName == "unstable") {
ghc810 = true;
ghc90 = false;
ghc92 = true;
ghc94 = true;
ghc92 = false;
ghc94 = false;
ghc96 = true;
ghc96llvm = true;
ghc98 = true;
ghc98llvm = true;
ghc98llvm = false;
ghc910 = true;
ghc911 = true;
ghc910llvm = true;
ghc912X = true;
ghc913 = true;
})));
crossSystems = nixpkgsName: nixpkgs: compiler-nix-name:
# We need to use the actual nixpkgs version we're working with here, since the values
Expand All @@ -85,21 +84,21 @@
&& (__match ".*llvm" compiler-nix-name == null)
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc884" "ghc902" "ghc928" "ghc948"])
|| (system == "aarch64-linux" && !builtins.elem compiler-nix-name ["ghc884" "ghc902" "ghc928" "ghc948"])
|| (system == "x86_64-darwin" && !builtins.elem compiler-nix-name ["ghc884" "ghc902" "ghc928" "ghc948"])
|| (system == "aarch64-darwin" && !builtins.elem compiler-nix-name ["ghc884" "ghc902" "ghc928" "ghc948"])
|| (system == "x86_64-darwin" && !builtins.elem compiler-nix-name ["ghc884" "ghc902" "ghc928" "ghc948" "ghc966" "ghc982" "ghc983"])
|| (system == "aarch64-darwin" && !builtins.elem compiler-nix-name ["ghc884" "ghc902" "ghc928" "ghc948" "ghc966" "ghc982" "ghc983"])
)) {
inherit (lib.systems.examples) ghcjs;
} // lib.optionalAttrs (
(__match ".*llvm" compiler-nix-name == null)
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc884" "ghc91120240620"]) # Including GHC HEAD here because the patches for rts/RtsSymbols.c no longer apply and mingwW64 GHC build fails without them
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc884" "ghc902" "ghc928" "ghc91220241014" "ghc91320241101"]) # Including GHC HEAD here because the patches for rts/RtsSymbols.c no longer apply and mingwW64 GHC build fails without them
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
inherit (lib.systems.examples) mingwW64;
} // lib.optionalAttrs (nixpkgsName == "unstable"
&& (__match ".*llvm" compiler-nix-name == null)
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc884" "ghc8107" "ghc902" "ghc928"])
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc884" "ghc8107" "ghc902" "ghc928" "ghc948"])
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
inherit (lib.systems.examples) ucrt64;
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc884"]) {
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc884" "ghc902" "ghc928" "ghc948"]) {
# Musl cross only works on linux
# aarch64 cross only works on linux
inherit (lib.systems.examples) musl64 aarch64-multiplatform;
Expand Down
Loading

0 comments on commit 8db37b7

Please sign in to comment.