Skip to content
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

Use cabal 3.8 #1641

Merged
merged 17 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from 11 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/comp-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ let
(lib.concatMap (c: if c.isHaskell or false
then builtins.attrValues (c.components.exes or {})
else [c]) build-tools) ++
lib.optional (pkgconfig != []) buildPackages.pkgconfig;
lib.optional (pkgconfig != []) buildPackages.cabalPkgConfigWrapper;

# Unfortunately, we need to wrap ghc commands for cabal builds to
# work in the nix-shell. See ../doc/removing-with-package-wrapper.md.
Expand Down
2 changes: 1 addition & 1 deletion builder/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let
# in the native case, it would be the same in the cross case however
# we *really* want to build the Setup.hs on the build machine and not
# have the stdenv confuse it with the target/host env.
inherit (buildPackages) stdenv pkgconfig;
inherit (buildPackages) stdenv;
inherit buildPackages;
inherit haskellLib nonReinstallablePkgs makeSetupConfigFiles;
};
Expand Down
2 changes: 1 addition & 1 deletion builder/hspkg-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let
||
# These are the dependencies of `Cabal`
!builtins.elem package.identifier.name
["nix-tools" "alex" "happy" "hscolour" "Cabal" "bytestring" "aeson" "time"
["nix-tools" "alex" "happy" "hscolour" "Cabal" "Cabal-syntax" "bytestring" "aeson" "time"
"filepath" "base-compat-batteries" "base-compat" "unix" "directory" "transformers"
"containers" "binary" "mtl" "text" "process" "parsec"];

Expand Down
4 changes: 2 additions & 2 deletions builder/setup-builder.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, stdenv, lib, buildPackages, haskellLib, ghc, nonReinstallablePkgs, hsPkgs, makeSetupConfigFiles, pkgconfig }@defaults:
{ pkgs, stdenv, lib, buildPackages, haskellLib, ghc, nonReinstallablePkgs, hsPkgs, makeSetupConfigFiles }@defaults:

let self =
{ component, package, name, src, enableDWARF ? false, flags ? {}, revision ? null, patches ? [], defaultSetupSrc
Expand Down Expand Up @@ -38,7 +38,7 @@ let
(lib.concatMap (c: if c.isHaskell or false
then builtins.attrValues (c.components.exes or {})
else [c]) component.build-tools) ++
lib.optional (component.pkgconfig != []) pkgconfig;
lib.optional (component.pkgconfig != []) buildPackages.cabalPkgConfigWrapper;

drv =
stdenv.mkDerivation ({
Expand Down
30 changes: 30 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
This file contains a summary of changes to Haskell.nix and `nix-tools`
that will impact users.

## Sep 6, 2022
* A `pkgconfigSelector` must now be passed to cabal projects that have
`pkgconfig-depends`. Use the pkg-config names. For instance if the
project uses `gi-gtk` pass:
```
pkgconfigSelector = p: [ p."gtk+-3.0" p."gobject-introspection-1.0" ];
```
The dependencies of gtk will be included automatically.

Why?

Cabal 3.8 fixes a bug https://github.com/haskell/cabal/issues/6771
that haskell.nix relied on (probably wrongly), to create a plan
for a haskell project without knowing the pkg-config versions
available ahead of time.

This was probably a bad idea.

We could try to provide every pkg-config derivation in nixpkgs to
the derivation that generates the cabal plan. Unfortunately:
* That would introduce a massive dependency tree to the plan-nix
dervaition.
* Some of those packages may not build.

The `pkgconfigSelector` allows haskell.nix to filter out only the
packages we need from the available map (`lib/pkgconf-nixpkgs-map.nix`).

It should be thought of as the haskell.nix equivalent of installing
your pkg-config dependencies before running `cabal build`.

## Jul 27, 2022
* Removed reliance on `builtins.currentSystem`. It was used it to provide
`pkgs.evalPackages` via an overlay that it used to run derivations
Expand Down
14 changes: 10 additions & 4 deletions lib/call-cabal-project-to-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ in
# any plutus-apps input being used for a
# package.
, evalPackages
, pkgconfigSelector ? (_: [])
, ...
}@args:

Expand Down Expand Up @@ -167,6 +168,8 @@ let

index-state-pinned = index-state != null || cabalProjectIndexState != null;

pkgconfPkgs = import ./pkgconf-nixpkgs-map.nix pkgs;

in
assert (if index-state-found == null
then throw "No index state passed and none found in ${cabalProjectFileName}" else true);
Expand Down Expand Up @@ -329,14 +332,14 @@ let
# when `checkMaterialization` is set.
dummy-ghc-data =
let
materialized = ../materialized/dummy-ghc + "/${ghc.targetPrefix}${ghc.name}-${pkgs.stdenv.buildPlatform.system}";
materialized = ../materialized/dummy-ghc + "/${ghc.targetPrefix}${ghc.name}-${pkgs.stdenv.buildPlatform.system}"
+ pkgs.lib.optionalString (builtins.compareVersions ghc.version "8.10" < 0 && ghc.targetPrefix == "" && builtins.compareVersions pkgs.lib.version "22.05" < 0) "-old";
in pkgs.haskell-nix.materialize ({
sha256 = null;
sha256Arg = "sha256";
materialized = if __pathExists materialized
then materialized
else __trace ("WARNING: No materialized dummy-ghc-data for "
+ "${ghc.targetPrefix}${ghc.name}-${pkgs.stdenv.buildPlatform.system}.")
else __trace "WARNING: No materialized dummy-ghc-data. mkdir ${toString materialized}"
null;
reasonNotSafe = null;
} // pkgs.lib.optionalAttrs (checkMaterialization != null) {
Expand Down Expand Up @@ -463,7 +466,10 @@ let
} // pkgs.lib.optionalAttrs (checkMaterialization != null) {
inherit checkMaterialization;
}) (evalPackages.runCommand (nameAndSuffix "plan-to-nix-pkgs") {
nativeBuildInputs = [ nix-tools dummy-ghc dummy-ghc-pkg cabal-install evalPackages.rsync evalPackages.gitMinimal ];
nativeBuildInputs = [ nix-tools dummy-ghc dummy-ghc-pkg cabal-install evalPackages.rsync evalPackages.gitMinimal evalPackages.pkgconfig ];
# We only need the `.dev` derivation (if there is one), since it will have
# the pkgconfig files needed by cabal.
buildInputs = map pkgs.lib.getDev (builtins.concatLists (pkgconfigSelector pkgconfPkgs));
# Needed or stack-to-nix will die on unicode inputs
LOCALE_ARCHIVE = pkgs.lib.optionalString (evalPackages.stdenv.buildPlatform.libc == "glibc") "${evalPackages.glibcLocales}/lib/locale/locale-archive";
LANG = "en_US.UTF-8";
Expand Down
4 changes: 2 additions & 2 deletions lib/ghcjs-project.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
if (builtins.compareVersions ghcjsVersion "8.10.0.0" >= 0)
then pkgs.haskell-nix.tool compiler-nix-name "cabal" {
index-state = pkgs.haskell-nix.internalHackageIndexState;
version = "3.6.2.0";
version = "3.8.1.0";
materialized = ../materialized/ghcjs/cabal + "/${compiler-nix-name}";
}
else pkgs.haskell-nix.tool compiler-nix-name "cabal" {
Expand All @@ -48,7 +48,7 @@
# Cabal 3.2.1.0 no longer supports he mix of `cabal-version`,
# lack of `custom-setup` and `v1-install` used by ghcjs boot.
cabalProjectLocal = ''
constraints: Cabal <3.2.1.0
constraints: Cabal <3.2.1.0, Cabal-syntax <0
'';
materialized = ../materialized/ghcjs/cabal + "/${compiler-nix-name}";
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading