Commit graph

277 commits

Author SHA1 Message Date
sternenseemann f45f7cb3e0 haskellPackages: support hadrian libdir layout 2023-02-05 14:01:25 +01:00
sternenseemann a9b8a272ea haskellPackages.mkDerivation: refactor libdir calculation 2023-02-05 14:01:25 +01:00
sternenseemann 18c0c48857 haskellPackages.mkDerivation: buildPkgDb: use haskellCompilerName 2023-02-05 14:01:25 +01:00
sternenseemann d9591db6f6 haskellPackages.mkDerivation: fix shebangs in JS backend binaries
The JavaScript backend emits `#!/usr/bin/env node` shebangs we need to
take care off using patchShebangs in fixupPhase.
2023-01-04 15:50:28 +01:00
sternenseemann 066591a359 haskellPackages.mkDerivation: disable stripping in ghcjs cross set
This line may look odd, but we should not set ghc.isGhcjs if we are
using the JavaScript backend. It is a normal cross backend and no
special code is required to make it work, i.e. everything will be named
as it would be normally. Additionally, passing --ghcjs to Cabal will
make it do the wrong thing.

We need to, of course, stop strip from being thrown at the JS objects in
both cases.
2023-01-04 15:50:28 +01:00
sternenseemann ff2d74b329 haskellPackages.mkDerivation: use CC_FOR_BUILD if !stdenv.hasCC
Previously, we would try to calculate the name of
buildPackages.stdenv.cc and then just hope that it is in PATH somehow.
This definitely doesn't work in all cases.

The new approach is to add buildPackages.stdenv.cc to depsBuildBuild
which also populates CC_FOR_BUILD which we can directly re-use.
2023-01-04 15:50:28 +01:00
maralorn 62074a54da
Merge pull request #172365 from sternenseemann/haskell-mk-derivation-stream-test
haskellPackages.mkDerivation: show test outputs as they happen
2022-05-21 16:44:49 +02:00
sternenseemann 8f5c420450 haskellPackages.mkDerivation: show test outputs as they happen
Currently, the test output is only printed if the test suite fails. If a
test suite gets stuck, however, and is hit with a timeout by Hydra, it
can help to have the log available when diagnosing the issue.
2022-05-10 12:03:55 +02:00
Matthew Bauer 91e4fa278e haskell-modules/generic-builder.nix: use mktemp instead of TMPDIR
Using $TMPDIR here is problematic because it is not always cleared at
the end of each build, for instance when using "nix-shell --run
genericBuild". This can cause confusing errors when a nix-shell build
is trying to pull in dependencies from a previous build since it tries
to use older package conf files.

To fix, we can just use mktemp which will guarantee us a clean
directory for each build. Should have no effect in nix-build, but will
fix a common issue with using generic-builder in nix-shell.
2022-05-05 12:01:23 -05:00
sternenseemann 103d171526
Merge pull request #166548 from sternenseemann/fix-ghclibdir-computation
[haskell-updates] ghcWithPackages: fix ghclibdir computation with variantSuffix
2022-04-03 14:22:34 +02:00
rnhmjoj f649fb8b4a
haskellPackages.mkDerivation: fix pkg-config cross
When cross compiling the pkg-config binary is prefixed and cabal
needs to be made aware of this.

Note: the `--with-pkg-config` flag can't be added unconditionally
because if the package doesn't need pkg-config (thus pkg-config
is not in the PATH) cabal consider this a hard failure.
2022-04-01 09:24:03 +02:00
sternenseemann 78a93b5352 haskellPackages.mkDerivation: get ghclibdir via haskellCompilerName
This is the correctest and clearest way to do it I can think of at the
moment that doesn't need us to add anything.
"${ghcCommand}-${ghc.version}" also works, but is clunkier and harder to
replicate for downstream users.
2022-03-31 12:47:54 +02:00
rnhmjoj 654940f36b haskellPackages.mkDerivation: check haddock availability
This change makes the haskell builder run the haddockPhase only if the
haddock program is availble (for example, it's not when cross-compiling).
2022-03-17 19:43:04 +01:00
Pepe Iborra d68033afae haskellPackages.mkDerivation: add doHaddockInterfaces option
This adds a new builder option `doHaddockInterfaces` to enable the -haddock flag in GHC,
which results in Haddock comments parsed at compile-time and embedded in
interface files. These are used by the :doc command in GHCi, as well as IDE
tools like ghcide and hls to display docs on hover.

The `-haddock` flag has been around since at least 8.2, even though it does not
get a mention in the GHC Users guide.

There are two downsides to turning on this flag:

1. Increased compile times, since Haddocks must be parsed and then encoded
2. Haddock parse errors now become compile errors for GHC < 9.0.1
   (https://gitlab.haskell.org/ghc/ghc/-/issues/8944)

Thus we only enable the feature if we have GHC 9.0.1 and haddock is
enabled; when 9.0.1 becomes the default GHC, we may need to reevaluate
the performance concern.

Co-authored-by: sternenseemann <sternenseemann@systemli.org>
2021-11-10 21:10:35 +01:00
maralorn 1e61298bf5
Merge pull request #129093 from siraben/haskell-mainProgram
haskell-generic-build: allow mainProgram to be set
2021-07-03 13:45:40 +02:00
Ben Siraphob 06fb9a9421 haskell-generic-build: allow mainProgram to be set 2021-07-03 15:52:39 +07:00
sternenseemann 6955f4e4e6 haskell-generic-builder: support badPlatforms
meta.badPlatforms allows us to exclude specific platforms from the list
of supported platforms without the need to explicitly substract it from
lib.platforms.all (or our inferior equivalent allKnownPlatforms) in
platforms. Thus it'll map nicely to unsupported-platforms in the
hackage2nix configuration in the future.
2021-06-27 18:32:28 +02:00
sternenseemann 5e0c55b581 haskell-generic-builder: pass pname and version as is
This is a full set rebuild, however it improves the name generation
for the static and cross case since the respective additional
components are now inserted between pname and version instead of after
name like before. This prevents builtins.parseDrvName from mistaking a
platform config string for a version component.
2021-06-21 14:08:41 +02:00
sternenseemann 57ec1813ff haskell-generic-builder: allow passing flags to the test suite(s)
Every flag the generic builder receives via `testFlags` is passed via
`--test-option` [1] to `Setup.hs` which in turn passes them to the
underlying test suite binary. These wrapped options are added to
`checkFlagsArray` in `checkPhase`. This needs to be done in bash since
without structuredAttrs in nixpkgs so far, Nix arrays aren't properly
translated into bash arrays, so we'd have all sorts of quoting issues
when spaces are involved.

Re-using `checkFlags` and `checkFlagsArray` from standard stdenv
setup.sh also results in an additional feature: Using `overrideAttrs`
`checkFlags` and `checkFlagsArray` can additionally be overridden,
which allows passing extra flags to `Setup.hs` whithout being wrapped
with `--test-option`.

[1]: See also https://cabal.readthedocs.io/en/3.4/setup-commands.html?highlight=test-option#cmdoption-runhaskell-Setup.hs-test-test-option
     According to the cabal-install man page this also allows passing
     special variables which are substituted for other values
     depending on context.
2021-06-09 15:09:00 +02:00
sternenseemann 670d6ac458 haskell-generic-builder: fix buildTarget specification if isLibrary
If we don't pass buildTarget to ./Setup copy and buildTarget is not
empty it will try installing targets that don't exist and thus fail.
2021-06-06 18:40:13 +02:00
rnhmjoj 830ef6422f
haskell-generic-builder: disable static PIE 2021-05-22 01:54:51 +09:00
Isaac Shapira d725ac7942
Add haskell.lib.setBuiltTarget, and support non library compiling of a single target 2021-05-02 13:35:07 +09:00
(cdep)illabout c8ac41fafc haskellPackages: add changelog argument to Haskell generic-builder.nix
changelog was recently added as a new meta field in
https://github.com/NixOS/nixpkgs/pull/60371.

This commit adds similar support to the Haskell generic builder.
2021-04-09 21:32:00 +02:00
Ben Siraphob 2f78ee7e81 pkgs/development: stdenv.lib -> lib 2021-01-24 00:16:29 +07:00
Jonathan Ringer 9bb3fccb5b treewide: pkgs.pkgconfig -> pkgs.pkg-config, move pkgconfig to alias.nix
continuation of #109595

pkgconfig was aliased in 2018, however, it remained in
all-packages.nix due to its wide usage. This cleans
up the remaining references to pkgs.pkgsconfig and
moves the entry to aliases.nix.

python3Packages.pkgconfig remained unchanged because
it's the canonical name of the upstream package
on pypi.
2021-01-19 01:16:25 -08:00
John Ericson a52f9a18bf haskell: Inline static overlay
We don't force `enableStaticLibraries` for Windows or WASM because it
will just fail an assertion.
2021-01-11 03:17:29 +00:00
Joe Hermaszewski 55a9078748 haskell-generic-builder: Add missing preHaddock and postHaddock arguments 2020-10-23 21:00:26 +02:00
Jan Tojnar 58377555ed
Merge branch 'staging-next' into staging 2020-08-23 02:18:27 +02:00
Tyson Whitehead 612f3324c9
haskell-generic-builder: Use args ? attr for passthru (closes #94246)
Comparing to a default value to detect if an argument was provided
forces it to at least WHNF, which can cause failure (e.g., if the
argument is a string with a quoted path from a broken package).
2020-08-15 10:54:11 -04:00
Divam fee55e2bb1 Disable static lib for Haskell wasm libs 2020-08-05 20:18:17 +09:00
Domen Kožar 1f6f0c9b3a
ghc: don't build with profiling on aarch64 #66277
This makes ghc output be lower than 2GB limit.

Also enable aarch64 build parallelism now that it's fixed in GHC 8.6
2020-07-21 20:23:07 +02:00
Robert Hensing 4353027d0b haskell/generic-builder.nix: Fix C lib multiple inclusions
Allow the darwin links code to overwrite libs that were already
copied, because C dependencies can occur multiple times.

Solves errors like

    ln: failed to create symbolic link '/nix/store/higpc9xavwcjjzdipz7m9ly03bh7iy2z-hercules-ci-agent-source-0.7.0/lib/links/libboost_context.dylib': File exists
2020-05-15 21:02:08 +02:00
Peter Simons ccb81f56cf haskell: tune generic-builder for more parallel build performance
Raise the maximum number of cores used for parallel building from 4 to 16.
Increase the size of the allocation area for GHC's garbage collector from 1 MiB
to 64 MiB.

See https://www.twitch.tv/videos/611899011 for the motivation for this change.
2020-05-08 21:11:47 +02:00
Simon Chatterjee 019e86fde9
haskell generic-builder: fix Darwin regression for lmdb
Recent updates to the generic builder have caused haskellPackages.lmdb-simple to
fail to build on Darwin, since it cannot see the lmdb C dynamic library included
by its dependent haskellPackages.lmdb.

The C dynamic library has suffix `.so` not `.dylib`, so this fix allows for
that.

Closes #80190, but that issue may identify a preferable solution.
2020-02-17 09:41:31 +01:00
Silvan Mosberger 8d4509e34d haskell generic-builder: Fix package conf handling
Previously the package conf files were handled without paying attention
to the fact that it's pretty-printed output. One problem was discovered
with GHC 8.8.1 on Darwin, where the dynamic-library-dirs first field
seems to have increased in length, meaning while before it was

    dynamic-library-dirs: some-small-directory-name
                          some-more-directories

Now it is

    dynamic-library-dirs:
        some-larger-directory-name
        some-more-directories

Which breaks the code installed for https://github.com/NixOS/nixpkgs/pull/25537,
because that assumed the former format, resulting in the reoccurence of
the bug in https://github.com/NixOS/nixpkgs/issues/22810, see
https://github.com/Infinisil/all-hies/issues/43

This commit fixes this by "unprettyfying" the package conf files before
processing them.

Closes https://github.com/NixOS/nixpkgs/pull/78738.
2020-01-31 21:05:56 +01:00
Matthew Bauer 07db0b248c Merge remote-tracking branch 'obsidiansystems/work-on-multi-shellFor' 2020-01-17 18:00:27 -05:00
Jacquin Mininger 7d67db3919 shellFor: Refactor for consistency and cross
This makes it work like work-on-multi from Reflex Platform. In
particular, rather than making `.env` from `shellFor`, we make `.env`
the primitive, and `shellFor` works by combining together the arguments
of all the packages to `generic-builder` and taking the `.env` of the
resulting mashup-package.

There are 2 benefits of this:

1. The dependency logic is deduplicated. generic builder just concatted
   lists, whereas all the envs until now would sieve apart haskell and
   system build inputs. Now, they both decide haskell vs system the same
   way: according to the argument list and without reflection.
   Consistency is good, especially because it mean that if the build
   works, the shell is more likely to work.

2. Cross is handled better. For native builds, because the
   `ghcWithPackages` calls would shadow, we through both the regular
   component (lib, exe, test, bench) haskell deps and Setup.hs haskell
   deps in the same `ghcWithPackages` call. But for cross builds we use
   `buildPackages.ghcWithPackages` to get the setup deps. This ensures
   everything works correctly.
2020-01-17 10:46:29 -05:00
Merlin Göttlinger 900a378245 haskell: add quickjump option to the haskell mkDerivation
When visiting local documentation via hoogle, currently for most packages the
quickjump index is missing so you only get a sad error when pressing "s" to
search in the current documentation.

The quickjump option is only supported by the haddock utility that's shipped
with ghc 8.6.x or later.

Closes https://github.com/NixOS/nixpkgs/pull/75942.
2020-01-10 20:56:20 +01:00
John Ericson 9cbbe2b00f Merge branch 'ghcjs-cross-without-cc-common' into ghcjs-cross-without-cc 2019-12-25 14:36:13 -05:00
John Ericson d8dd301412 haskell generic-builder: Hack so CPP without a CC works 2019-12-25 14:34:40 -05:00
John Ericson 49daa0aa64 Merge branch 'ghcjs-cross-without-cc-common' into ghcjs-cross-without-cc 2019-12-25 13:17:00 -05:00
John Ericson 6a23c9ddbe haskell generic-builder: Fix --with-ghc flag for GHCJS as cross
Otherwise it passes `--with-ghc=ghc`, and we do the wrong thing.
2019-12-25 13:14:48 -05:00
John Ericson 6bc456c91c Merge remote-tracking branch 'upstream/master' into ghcjs-cross-without-cc 2019-11-25 00:23:07 +00:00
John Ericson ea9a2c5ec2 haskell genenric-builder: Make the C compiler optional
This is GHCJS, and perhaps other obscure targets.
2019-11-25 00:12:39 +00:00
Yorick van Pelt a1b68b688b ghcjs: disable profiling by default 2019-11-01 21:28:26 +01:00
volth f3282c8d1e treewide: remove unused variables (#63177)
* treewide: remove unused variables

* making ofborg happy
2019-06-16 19:59:05 +00:00
Frederik Rietdijk bae32a9f5c Merge staging-next into staging 2019-04-16 18:54:15 +02:00
(cdep)illabout 757099e8f1 haskell-generic-builder: disable library-for-ghci by default
This commit disables the library-for-ghci flag passed to
`Setup configure` in the Haskell generic-builder.nix file.

This stops the HSfoo.o file from being built.  Building this
HSfoo.o file caused doctest to take an extremely long time
to load dependencies when running.

This is a follow-up from https://github.com/NixOS/nixpkgs/pull/58743.
2019-04-12 11:55:22 +02:00
Matthew Bauer eaa5e85b35 haskell: add more hackage mirrors, use mirrors in more places
Fixes #58971
2019-04-05 13:51:56 -04:00
(cdep)illabout a5b85222ff Add option to disable library-for-ghci in the generic haskell builder.
Closes https://github.com/NixOS/nixpkgs/pull/58743.
2019-04-02 11:46:48 +02:00