Compare commits
11 commits
vlinkz/dar
...
main
Author | SHA1 | Date | |
---|---|---|---|
8be7956fc0 | |||
isabel roses | c13b60bc67 | ||
Julie Tyché Bettens | 9ed579059e | ||
Julie Tyché Bettens | 7ec6274c37 | ||
d60eb7471e | |||
ef1e2ef8c2 | |||
ff4126b6ba | |||
Victor Fuentes | be166796d2 | ||
Julie Tyché Bettens | 2da6177b87 | ||
isabel roses | f760a7e9bf | ||
Julie Tyché Bettens | 9f588014cb |
|
@ -1,68 +1,52 @@
|
||||||
/* List of NixOS maintainers.
|
/*
|
||||||
```nix
|
List of Aux maintainers.
|
||||||
handle = {
|
```nix
|
||||||
# Required
|
handle = {
|
||||||
name = "Your name";
|
# Required
|
||||||
|
name = "Your name";
|
||||||
|
forgejo = "forgejoUsername";
|
||||||
|
forgejoId = your-forgejo-id;
|
||||||
|
|
||||||
# Optional, but at least one of email, matrix or githubId must be given
|
# Optional, but at least one of email or matrix must be given
|
||||||
email = "address@example.org";
|
email = "address@example.org";
|
||||||
matrix = "@user:example.org";
|
matrix = "@user:example.org";
|
||||||
github = "GithubUsername";
|
|
||||||
githubId = your-github-id;
|
|
||||||
|
|
||||||
keys = [{
|
keys = [{
|
||||||
fingerprint = "AAAA BBBB CCCC DDDD EEEE FFFF 0000 1111 2222 3333";
|
fingerprint = "AAAA BBBB CCCC DDDD EEEE FFFF 0000 1111 2222 3333";
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|
||||||
- `handle` is the handle you are going to use in nixpkgs expressions,
|
- `handle` is the handle you are going to use in nixpkgs expressions,
|
||||||
- `name` is a name that people would know and recognize you by,
|
- `name` is a name that people would know and recognize you by,
|
||||||
- `email` is your maintainer email address,
|
- `email` is your maintainer email address,
|
||||||
- `matrix` is your Matrix user ID,
|
- `matrix` is your Matrix user ID,
|
||||||
- `github` is your GitHub handle (as it appears in the URL of your profile page, `https://github.com/<userhandle>`),
|
- `forgejo` is your forgejo handle (as it appears in the URL of your profile page, `https://git.auxolotl.org/<userhandle>`),
|
||||||
- `githubId` is your GitHub user ID, which can be found at `https://api.github.com/users/<userhandle>`,
|
- `forgejoId` is your forgejo user ID, which can be found at `https://git.auxolotl.org/api/v1/users/<username>`,
|
||||||
- `keys` is a list of your PGP/GPG key fingerprints.
|
- `keys` is a list of your PGP/GPG key fingerprints.
|
||||||
|
|
||||||
Specifying a GitHub account ensures that you automatically:
|
`handle == forgejo` is strongly preferred whenever `forgejo` is an acceptable attribute name and is short and convenient.
|
||||||
- get invited to the @NixOS/nixpkgs-maintainers team ;
|
|
||||||
- once you are part of the @NixOS org, OfBorg will request you review
|
|
||||||
pull requests that modify a package for which you are a maintainer.
|
|
||||||
|
|
||||||
`handle == github` is strongly preferred whenever `github` is an acceptable attribute name and is short and convenient.
|
If `forgejo` begins with a numeral, `handle` should be prefixed with an underscore.
|
||||||
|
```nix
|
||||||
|
_1example = {
|
||||||
|
forgejo = "1example";
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
If `github` begins with a numeral, `handle` should be prefixed with an underscore.
|
Add PGP/GPG keys only if you actually use them to sign commits and/or mail.
|
||||||
```nix
|
|
||||||
_1example = {
|
|
||||||
github = "1example";
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
Add PGP/GPG keys only if you actually use them to sign commits and/or mail.
|
To get the required PGP/GPG values for a key run
|
||||||
|
```shell
|
||||||
|
gpg --fingerprint <email> | head -n 2
|
||||||
|
```
|
||||||
|
|
||||||
To get the required PGP/GPG values for a key run
|
!!! Note that PGP/GPG values stored here are for informational purposes only, don't use this file as a source of truth.
|
||||||
```shell
|
|
||||||
gpg --fingerprint <email> | head -n 2
|
|
||||||
```
|
|
||||||
|
|
||||||
!!! Note that PGP/GPG values stored here are for informational purposes only, don't use this file as a source of truth.
|
More fields may be added in the future, however, in order to comply with GDPR this file should stay as minimal as possible.
|
||||||
|
|
||||||
More fields may be added in the future, however, in order to comply with GDPR this file should stay as minimal as possible.
|
When editing this file, please ensure that you have added yourself in alphabetical order of your handle.
|
||||||
|
|
||||||
When editing this file:
|
|
||||||
* keep the list alphabetically sorted, check with:
|
|
||||||
nix-instantiate --eval maintainers/scripts/check-maintainers-sorted.nix
|
|
||||||
* test the validity of the format with:
|
|
||||||
nix-build lib/tests/maintainers.nix
|
|
||||||
|
|
||||||
See `./scripts/check-maintainer-github-handles.sh` for an example on how to work with this data.
|
|
||||||
|
|
||||||
When adding a new maintainer, be aware of the current commit conventions
|
|
||||||
documented at [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#commit-conventions)
|
|
||||||
file located in the root of the Nixpkgs repo.
|
|
||||||
*/
|
*/
|
||||||
{
|
{ }
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ lib.makeOverridable (
|
||||||
, # Impure env vars (https://nixos.org/nix/manual/#sec-advanced-attributes)
|
, # Impure env vars (https://nixos.org/nix/manual/#sec-advanced-attributes)
|
||||||
# needed for netrcPhase
|
# needed for netrcPhase
|
||||||
netrcImpureEnvVars ? []
|
netrcImpureEnvVars ? []
|
||||||
|
, passthru ? {}
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
, allowedRequisites ? null
|
, allowedRequisites ? null
|
||||||
}:
|
}:
|
||||||
|
@ -103,7 +104,7 @@ stdenvNoCC.mkDerivation {
|
||||||
|
|
||||||
inherit preferLocalBuild meta allowedRequisites;
|
inherit preferLocalBuild meta allowedRequisites;
|
||||||
|
|
||||||
passthru = {
|
passthru = passthru // {
|
||||||
gitRepoUrl = url;
|
gitRepoUrl = url;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,30 @@
|
||||||
{ lib, fetchgit, fetchzip }:
|
{ lib, fetchgit, fetchzip }:
|
||||||
|
|
||||||
lib.makeOverridable (
|
lib.makeOverridable (
|
||||||
{ owner, repo, rev, name ? "source"
|
{ owner, repo, rev
|
||||||
|
, name ? null # Override with null to use the default value
|
||||||
|
, pname ? "source-${githubBase}-${owner}-${repo}"
|
||||||
, fetchSubmodules ? false, leaveDotGit ? null
|
, fetchSubmodules ? false, leaveDotGit ? null
|
||||||
, deepClone ? false, private ? false, forceFetchGit ? false
|
, deepClone ? false, private ? false, forceFetchGit ? false
|
||||||
, sparseCheckout ? []
|
, sparseCheckout ? []
|
||||||
, githubBase ? "github.com", varPrefix ? null
|
, githubBase ? "github.com", varPrefix ? null
|
||||||
|
, passthru ? { }
|
||||||
, meta ? { }
|
, meta ? { }
|
||||||
, ... # For hash agility
|
, ... # For hash agility
|
||||||
}@args:
|
}@args:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
name = if args.name or null != null then args.name
|
||||||
|
else "${pname}-${rev}";
|
||||||
|
|
||||||
position = (if args.meta.description or null != null
|
position = (if args.meta.description or null != null
|
||||||
then builtins.unsafeGetAttrPos "description" args.meta
|
then builtins.unsafeGetAttrPos "description" args.meta
|
||||||
else builtins.unsafeGetAttrPos "rev" args
|
else builtins.unsafeGetAttrPos "rev" args
|
||||||
);
|
);
|
||||||
baseUrl = "https://${githubBase}/${owner}/${repo}";
|
baseUrl = "https://${githubBase}/${owner}/${repo}";
|
||||||
|
newPassthru = passthru // {
|
||||||
|
inherit rev owner repo;
|
||||||
|
};
|
||||||
newMeta = meta // {
|
newMeta = meta // {
|
||||||
homepage = meta.homepage or baseUrl;
|
homepage = meta.homepage or baseUrl;
|
||||||
} // lib.optionalAttrs (position != null) {
|
} // lib.optionalAttrs (position != null) {
|
||||||
|
@ -53,16 +61,19 @@ let
|
||||||
fetcherArgs = (if useFetchGit
|
fetcherArgs = (if useFetchGit
|
||||||
then {
|
then {
|
||||||
inherit rev deepClone fetchSubmodules sparseCheckout; url = gitRepoUrl;
|
inherit rev deepClone fetchSubmodules sparseCheckout; url = gitRepoUrl;
|
||||||
|
passthru = newPassthru;
|
||||||
} // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; }
|
} // lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; }
|
||||||
else {
|
else {
|
||||||
url = "${baseUrl}/archive/${rev}.tar.gz";
|
url = "${baseUrl}/archive/${rev}.tar.gz";
|
||||||
|
|
||||||
passthru = {
|
passthru = newPassthru // {
|
||||||
inherit gitRepoUrl;
|
inherit gitRepoUrl;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
) // privateAttrs // passthruAttrs // { inherit name; };
|
) // privateAttrs // passthruAttrs // { inherit name; };
|
||||||
in
|
in
|
||||||
|
|
||||||
fetcher fetcherArgs // { meta = newMeta; inherit rev owner repo; }
|
(fetcher fetcherArgs).overrideAttrs (finalAttrs: previousAttrs: {
|
||||||
|
meta = newMeta;
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
lib.makeOverridable (
|
lib.makeOverridable (
|
||||||
# gitlab example
|
# gitlab example
|
||||||
{ owner, repo, rev, protocol ? "https", domain ? "gitlab.com", name ? "source", group ? null
|
{ owner, repo, rev, protocol ? "https", domain ? "gitlab.com", group ? null
|
||||||
|
, pname ? lib.concatStringsSep "-" ([ "source" domain ] ++ (lib.optional (group != null) group) ++ [ owner repo ])
|
||||||
|
, name ? "${pname}-${rev}"
|
||||||
, fetchSubmodules ? false, leaveDotGit ? false
|
, fetchSubmodules ? false, leaveDotGit ? false
|
||||||
, deepClone ? false, forceFetchGit ? false
|
, deepClone ? false, forceFetchGit ? false
|
||||||
, sparseCheckout ? []
|
, sparseCheckout ? []
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
lib.makeOverridable (
|
lib.makeOverridable (
|
||||||
# cgit example, snapshot support is optional in cgit
|
# cgit example, snapshot support is optional in cgit
|
||||||
{ repo, rev, name ? "source"
|
{ repo, rev, name ? "source-savannah.gnu.org-${repo}-${rev}"
|
||||||
, ... # For hash agility
|
, ... # For hash agility
|
||||||
}@args: fetchzip ({
|
}@args: fetchzip ({
|
||||||
inherit name;
|
inherit name;
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
# Hackage database snapshot, used by maintainers/scripts/regenerate-hackage-packages.sh
|
|
||||||
# and callHackage
|
|
||||||
{ lib, fetchurl }:
|
|
||||||
let
|
|
||||||
pin = lib.importJSON ./pin.json;
|
|
||||||
in
|
|
||||||
fetchurl {
|
|
||||||
inherit (pin) url sha256;
|
|
||||||
name = "all-cabal-hashes-${lib.substring 0 7 pin.commit}.tar.gz";
|
|
||||||
passthru.updateScript = ../../../../maintainers/scripts/haskell/update-hackage.sh;
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"commit": "4eb9a5fde06b5d7343665582243debaf1d77e0a9",
|
|
||||||
"url": "https://github.com/commercialhaskell/all-cabal-hashes/archive/4eb9a5fde06b5d7343665582243debaf1d77e0a9.tar.gz",
|
|
||||||
"sha256": "0dzyfr1gv79riy2vh840b5hqly8rs10zhj01zi9nfn7jd9pzql28",
|
|
||||||
"msg": "Update from Hackage at 2024-04-16T17:36:35Z"
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
{ lib, stdenv, fetchFromGitHub, meson, ninja }:
|
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
pname = "argp-standalone";
|
|
||||||
version = "1.5.0";
|
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
|
||||||
owner = "argp-standalone";
|
|
||||||
repo = "argp-standalone";
|
|
||||||
rev = version;
|
|
||||||
sha256 = "jWnoWVnUVDQlsC9ru7oB9PdtZuyCCNqGnMqF/f2m0ZY=";
|
|
||||||
};
|
|
||||||
|
|
||||||
nativeBuildInputs = [ meson ninja ];
|
|
||||||
|
|
||||||
doCheck = true;
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
homepage = "https://github.com/argp-standalone/argp-standalone";
|
|
||||||
description = "Standalone version of arguments parsing functions from Glibc";
|
|
||||||
platforms = platforms.unix;
|
|
||||||
maintainers = with maintainers; [ amar1729 ];
|
|
||||||
license = licenses.lgpl21Plus;
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -24,7 +24,7 @@ with pkgs;
|
||||||
inherit (stdenv.targetPlatform) linker;
|
inherit (stdenv.targetPlatform) linker;
|
||||||
in
|
in
|
||||||
if linker == "lld" then llvmPackages.bintools-unwrapped
|
if linker == "lld" then llvmPackages.bintools-unwrapped
|
||||||
else if linker == "cctools" then darwin.binutils-unwrapped
|
# else if linker == "cctools" then darwin.binutils-unwrapped
|
||||||
else if linker == "bfd" then binutils-unwrapped
|
else if linker == "bfd" then binutils-unwrapped
|
||||||
else if linker == "gold" then binutils-unwrapped.override { enableGoldDefault = true; }
|
else if linker == "gold" then binutils-unwrapped.override { enableGoldDefault = true; }
|
||||||
else null;
|
else null;
|
||||||
|
|
|
@ -51,9 +51,8 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
"CFLAGS_EXTRA=-DNO_SOFT_VDB"
|
"CFLAGS_EXTRA=-DNO_SOFT_VDB"
|
||||||
];
|
];
|
||||||
|
|
||||||
# `gctest` fails under x86_64 emulation on aarch64-darwin
|
# `gctest` fails under emulation on aarch64-darwin
|
||||||
# and also on aarch64-linux (qemu-user)
|
doCheck = !(stdenv.isDarwin && stdenv.isx86_64);
|
||||||
doCheck = !((stdenv.isDarwin && stdenv.isx86_64) || (stdenv.isLinux && stdenv.isAarch64));
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
|
|
|
@ -199,6 +199,6 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
maintainers = with lib.maintainers; [ ttuegel lnl7 AndersonTorres ];
|
maintainers = with lib.maintainers; [ ttuegel lnl7 AndersonTorres ];
|
||||||
platforms = lib.platforms.all;
|
platforms = lib.platforms.all;
|
||||||
mainProgram = "cmake";
|
mainProgram = "cmake";
|
||||||
# broken = (qt5UI && stdenv.isDarwin);
|
broken = (/*qt5UI &&*/ stdenv.isDarwin);
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
{ fetchurl, fetchpatch, lib, stdenv, cmake }:
|
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
pname = "cmocka";
|
|
||||||
majorVersion = "1.1";
|
|
||||||
version = "${majorVersion}.7";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://cmocka.org/files/${majorVersion}/cmocka-${version}.tar.xz";
|
|
||||||
sha256 = "sha256-gQVw6wuNZIBDMfgrKf9Hx5DOnNaxY+mNR6SAcEfsrYI=";
|
|
||||||
};
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
./uintptr_t.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake ];
|
|
||||||
|
|
||||||
cmakeFlags = lib.optional doCheck "-DUNIT_TESTING=ON"
|
|
||||||
++ lib.optional stdenv.hostPlatform.isStatic "-DBUILD_SHARED_LIBS=OFF";
|
|
||||||
|
|
||||||
doCheck = true;
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
description = "Lightweight library to simplify and generalize unit tests for C";
|
|
||||||
longDescription = ''
|
|
||||||
There are a variety of C unit testing frameworks available however
|
|
||||||
many of them are fairly complex and require the latest compiler
|
|
||||||
technology. Some development requires the use of old compilers which
|
|
||||||
makes it difficult to use some unit testing frameworks. In addition
|
|
||||||
many unit testing frameworks assume the code being tested is an
|
|
||||||
application or module that is targeted to the same platform that will
|
|
||||||
ultimately execute the test. Because of this assumption many
|
|
||||||
frameworks require the inclusion of standard C library headers in the
|
|
||||||
code module being tested which may collide with the custom or
|
|
||||||
incomplete implementation of the C library utilized by the code under
|
|
||||||
test.
|
|
||||||
|
|
||||||
Cmocka only requires a test application is linked with the standard C
|
|
||||||
library which minimizes conflicts with standard C library headers.
|
|
||||||
Also, CMocka tries to avoid the use of some of the newer features of
|
|
||||||
C compilers.
|
|
||||||
|
|
||||||
This results in CMocka being a relatively small library that can be
|
|
||||||
used to test a variety of exotic code. If a developer wishes to
|
|
||||||
simply test an application with the latest compiler then other unit
|
|
||||||
testing frameworks may be preferable.
|
|
||||||
|
|
||||||
This is the successor of Google's Cmockery.
|
|
||||||
'';
|
|
||||||
homepage = "https://cmocka.org/";
|
|
||||||
license = licenses.asl20;
|
|
||||||
platforms = platforms.all;
|
|
||||||
maintainers = with maintainers; [ kragniz rasendubi ];
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
Resolve messy situation with uintptr_t and stdint.h
|
|
||||||
|
|
||||||
Platforms common in nixpkgs will have stdint.h - thereby we avoid problems
|
|
||||||
that seem complicated to avoid. References:
|
|
||||||
https://gitlab.com/cmocka/cmocka/-/issues/38#note_1286565655
|
|
||||||
https://git.alpinelinux.org/aports/plain/main/cmocka/musl_uintptr.patch?id=6a15dd0d0ba9cc354a621fb359ca5e315ff2eabd
|
|
||||||
|
|
||||||
It isn't easy, as 1.1.6 codebase is missing stdint.h includes on many places,
|
|
||||||
and HAVE_UINTPTR_T from cmake also wouldn't get on all places it needs to.
|
|
||||||
--- a/include/cmocka.h
|
|
||||||
+++ b/include/cmocka.h
|
|
||||||
@@ -18,2 +18,4 @@
|
|
||||||
#define CMOCKA_H_
|
|
||||||
+#include <stdint.h>
|
|
||||||
+#define HAVE_UINTPTR_T 1
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
{ lib, stdenv, fetchsvn, autoreconfHook }:
|
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
pname = "ctags";
|
|
||||||
version = "816";
|
|
||||||
|
|
||||||
src = fetchsvn {
|
|
||||||
url = "https://svn.code.sf.net/p/ctags/code/trunk";
|
|
||||||
rev = version;
|
|
||||||
sha256 = "0jmbkrmscbl64j71qffcc39x005jrmphx8kirs1g2ws44wil39hf";
|
|
||||||
};
|
|
||||||
|
|
||||||
nativeBuildInputs = [ autoreconfHook ];
|
|
||||||
|
|
||||||
# don't use $T(E)MP which is set to the build directory
|
|
||||||
configureFlags= [ "--enable-tmpdir=/tmp" ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# Library defines an `__unused__` which is a reserved name, and may
|
|
||||||
# conflict with the standard library definition. One such conflict is with
|
|
||||||
# macOS headers.
|
|
||||||
./unused-collision.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
description = "A tool for fast source code browsing (exuberant ctags)";
|
|
||||||
mainProgram = "ctags";
|
|
||||||
longDescription = ''
|
|
||||||
Ctags generates an index (or tag) file of language objects found
|
|
||||||
in source files that allows these items to be quickly and easily
|
|
||||||
located by a text editor or other utility. A tag signifies a
|
|
||||||
language object for which an index entry is available (or,
|
|
||||||
alternatively, the index entry created for that object). Many
|
|
||||||
programming languages are supported.
|
|
||||||
'';
|
|
||||||
homepage = "https://ctags.sourceforge.net/";
|
|
||||||
license = licenses.gpl2Plus;
|
|
||||||
platforms = platforms.unix;
|
|
||||||
|
|
||||||
# So that Exuberant ctags is preferred over emacs's ctags
|
|
||||||
priority = 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,246 +0,0 @@
|
||||||
--- a/c.c (revision 816)
|
|
||||||
+++ b/c.c (working copy)
|
|
||||||
@@ -619,7 +619,7 @@
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void __unused__ pt (tokenInfo *const token)
|
|
||||||
+static void UNUSED pt (tokenInfo *const token)
|
|
||||||
{
|
|
||||||
if (isType (token, TOKEN_NAME))
|
|
||||||
printf ("type: %-12s: %-13s line: %lu\n",
|
|
||||||
@@ -634,7 +634,7 @@
|
|
||||||
tokenString (token->type), token->lineNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void __unused__ ps (statementInfo *const st)
|
|
||||||
+static void UNUSED ps (statementInfo *const st)
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
printf ("scope: %s decl: %s gotName: %s gotParenName: %s\n",
|
|
||||||
--- a/eiffel.c (revision 816)
|
|
||||||
+++ b/eiffel.c (working copy)
|
|
||||||
@@ -807,7 +807,7 @@
|
|
||||||
|
|
||||||
static boolean parseType (tokenInfo *const token);
|
|
||||||
|
|
||||||
-static void parseGeneric (tokenInfo *const token, boolean declaration __unused__)
|
|
||||||
+static void parseGeneric (tokenInfo *const token, boolean declaration UNUSED)
|
|
||||||
{
|
|
||||||
unsigned int depth = 0;
|
|
||||||
#ifdef TYPE_REFERENCE_TOOL
|
|
||||||
--- a/general.h (revision 816)
|
|
||||||
+++ b/general.h (working copy)
|
|
||||||
@@ -57,10 +57,10 @@
|
|
||||||
* to prevent warnings about unused variables.
|
|
||||||
*/
|
|
||||||
#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) && !defined (__GNUG__)
|
|
||||||
-# define __unused__ __attribute__((unused))
|
|
||||||
+# define UNUSED __attribute__((unused))
|
|
||||||
# define __printf__(s,f) __attribute__((format (printf, s, f)))
|
|
||||||
#else
|
|
||||||
-# define __unused__
|
|
||||||
+# define UNUSED
|
|
||||||
# define __printf__(s,f)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
--- a/lregex.c (revision 816)
|
|
||||||
+++ b/lregex.c (working copy)
|
|
||||||
@@ -538,11 +538,11 @@
|
|
||||||
#endif /* HAVE_REGEX */
|
|
||||||
|
|
||||||
extern void addTagRegex (
|
|
||||||
- const langType language __unused__,
|
|
||||||
- const char* const regex __unused__,
|
|
||||||
- const char* const name __unused__,
|
|
||||||
- const char* const kinds __unused__,
|
|
||||||
- const char* const flags __unused__)
|
|
||||||
+ const langType language UNUSED,
|
|
||||||
+ const char* const regex UNUSED,
|
|
||||||
+ const char* const name UNUSED,
|
|
||||||
+ const char* const kinds UNUSED,
|
|
||||||
+ const char* const flags UNUSED)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_REGEX
|
|
||||||
Assert (regex != NULL);
|
|
||||||
@@ -564,10 +564,10 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
extern void addCallbackRegex (
|
|
||||||
- const langType language __unused__,
|
|
||||||
- const char* const regex __unused__,
|
|
||||||
- const char* const flags __unused__,
|
|
||||||
- const regexCallback callback __unused__)
|
|
||||||
+ const langType language UNUSED,
|
|
||||||
+ const char* const regex UNUSED,
|
|
||||||
+ const char* const flags UNUSED,
|
|
||||||
+ const regexCallback callback UNUSED)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_REGEX
|
|
||||||
Assert (regex != NULL);
|
|
||||||
@@ -581,7 +581,7 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
extern void addLanguageRegex (
|
|
||||||
- const langType language __unused__, const char* const regex __unused__)
|
|
||||||
+ const langType language UNUSED, const char* const regex UNUSED)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_REGEX
|
|
||||||
if (! regexBroken)
|
|
||||||
@@ -602,7 +602,7 @@
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern boolean processRegexOption (const char *const option,
|
|
||||||
- const char *const parameter __unused__)
|
|
||||||
+ const char *const parameter UNUSED)
|
|
||||||
{
|
|
||||||
boolean handled = FALSE;
|
|
||||||
const char* const dash = strchr (option, '-');
|
|
||||||
@@ -624,7 +624,7 @@
|
|
||||||
return handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
-extern void disableRegexKinds (const langType language __unused__)
|
|
||||||
+extern void disableRegexKinds (const langType language UNUSED)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_REGEX
|
|
||||||
if (language <= SetUpper && Sets [language].count > 0)
|
|
||||||
@@ -639,8 +639,8 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
extern boolean enableRegexKind (
|
|
||||||
- const langType language __unused__,
|
|
||||||
- const int kind __unused__, const boolean mode __unused__)
|
|
||||||
+ const langType language UNUSED,
|
|
||||||
+ const int kind UNUSED, const boolean mode UNUSED)
|
|
||||||
{
|
|
||||||
boolean result = FALSE;
|
|
||||||
#ifdef HAVE_REGEX
|
|
||||||
@@ -660,7 +660,7 @@
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
-extern void printRegexKinds (const langType language __unused__, boolean indent __unused__)
|
|
||||||
+extern void printRegexKinds (const langType language UNUSED, boolean indent UNUSED)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_REGEX
|
|
||||||
if (language <= SetUpper && Sets [language].count > 0)
|
|
||||||
--- a/lua.c (revision 816)
|
|
||||||
+++ b/lua.c (working copy)
|
|
||||||
@@ -37,7 +37,7 @@
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* for debugging purposes */
|
|
||||||
-static void __unused__ print_string (char *p, char *q)
|
|
||||||
+static void UNUSED print_string (char *p, char *q)
|
|
||||||
{
|
|
||||||
for ( ; p != q; p++)
|
|
||||||
fprintf (errout, "%c", *p);
|
|
||||||
--- a/main.c (revision 816)
|
|
||||||
+++ b/main.c (working copy)
|
|
||||||
@@ -522,7 +522,7 @@
|
|
||||||
* Start up code
|
|
||||||
*/
|
|
||||||
|
|
||||||
-extern int main (int __unused__ argc, char **argv)
|
|
||||||
+extern int main (int UNUSED argc, char **argv)
|
|
||||||
{
|
|
||||||
cookedArgs *args;
|
|
||||||
#ifdef VMS
|
|
||||||
--- a/options.c (revision 816)
|
|
||||||
+++ b/options.c (working copy)
|
|
||||||
@@ -730,7 +730,7 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
static void processExcludeOption (
|
|
||||||
- const char *const option __unused__, const char *const parameter)
|
|
||||||
+ const char *const option UNUSED, const char *const parameter)
|
|
||||||
{
|
|
||||||
const char *const fileName = parameter + 1;
|
|
||||||
if (parameter [0] == '\0')
|
|
||||||
@@ -867,7 +867,7 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
static void processFilterTerminatorOption (
|
|
||||||
- const char *const option __unused__, const char *const parameter)
|
|
||||||
+ const char *const option UNUSED, const char *const parameter)
|
|
||||||
{
|
|
||||||
freeString (&Option.filterTerminator);
|
|
||||||
Option.filterTerminator = stringCopy (parameter);
|
|
||||||
@@ -930,8 +930,8 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
static void processHelpOption (
|
|
||||||
- const char *const option __unused__,
|
|
||||||
- const char *const parameter __unused__)
|
|
||||||
+ const char *const option UNUSED,
|
|
||||||
+ const char *const parameter UNUSED)
|
|
||||||
{
|
|
||||||
printProgramIdentification ();
|
|
||||||
putchar ('\n');
|
|
||||||
@@ -1139,8 +1139,8 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
static void processLicenseOption (
|
|
||||||
- const char *const option __unused__,
|
|
||||||
- const char *const parameter __unused__)
|
|
||||||
+ const char *const option UNUSED,
|
|
||||||
+ const char *const parameter UNUSED)
|
|
||||||
{
|
|
||||||
printProgramIdentification ();
|
|
||||||
puts ("");
|
|
||||||
@@ -1166,8 +1166,8 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
static void processListMapsOption (
|
|
||||||
- const char *const __unused__ option,
|
|
||||||
- const char *const __unused__ parameter)
|
|
||||||
+ const char *const UNUSED option,
|
|
||||||
+ const char *const UNUSED parameter)
|
|
||||||
{
|
|
||||||
if (parameter [0] == '\0' || strcasecmp (parameter, "all") == 0)
|
|
||||||
printLanguageMaps (LANG_AUTO);
|
|
||||||
@@ -1183,8 +1183,8 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
static void processListLanguagesOption (
|
|
||||||
- const char *const option __unused__,
|
|
||||||
- const char *const parameter __unused__)
|
|
||||||
+ const char *const option UNUSED,
|
|
||||||
+ const char *const parameter UNUSED)
|
|
||||||
{
|
|
||||||
printLanguageList ();
|
|
||||||
exit (0);
|
|
||||||
@@ -1358,8 +1358,8 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
static void processVersionOption (
|
|
||||||
- const char *const option __unused__,
|
|
||||||
- const char *const parameter __unused__)
|
|
||||||
+ const char *const option UNUSED,
|
|
||||||
+ const char *const parameter UNUSED)
|
|
||||||
{
|
|
||||||
printProgramIdentification ();
|
|
||||||
exit (0);
|
|
||||||
--- a/parse.c (revision 816)
|
|
||||||
+++ b/parse.c (working copy)
|
|
||||||
@@ -376,7 +376,7 @@
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern void processLanguageDefineOption (
|
|
||||||
- const char *const option, const char *const parameter __unused__)
|
|
||||||
+ const char *const option, const char *const parameter UNUSED)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_REGEX
|
|
||||||
if (parameter [0] == '\0')
|
|
||||||
--- a/routines.c (revision 816)
|
|
||||||
+++ b/routines.c (working copy)
|
|
||||||
@@ -526,7 +526,7 @@
|
|
||||||
|
|
||||||
#if ! defined (HAVE_STAT_ST_INO)
|
|
||||||
|
|
||||||
-static void canonicalizePath (char *const path __unused__)
|
|
||||||
+static void canonicalizePath (char *const path UNUSED)
|
|
||||||
{
|
|
||||||
#if defined (MSDOS_STYLE_PATH)
|
|
||||||
char *p;
|
|
|
@ -1,78 +0,0 @@
|
||||||
{ pkgs, ctags }:
|
|
||||||
|
|
||||||
with pkgs.lib;
|
|
||||||
|
|
||||||
# define some ctags wrappers adding support for some not that common languages
|
|
||||||
# customization:
|
|
||||||
# a) add stuff here
|
|
||||||
# b) override asLang, phpLang, ... using packageOverrides
|
|
||||||
# c) use ctagsWrapped.override {args = [ your liste ];}
|
|
||||||
|
|
||||||
# install using -iA ctagsWrapped.ctagsWrapped
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
# the derivation. use language extensions specified by args
|
|
||||||
ctagsWrapped = makeOverridable ( {args, name} : pkgs.writeScriptBin name ''
|
|
||||||
#!${pkgs.runtimeShell}
|
|
||||||
exec ${pkgs.ctags}/bin/ctags ${concatStringsSep " " (map escapeShellArg args)} "$@"
|
|
||||||
'') {
|
|
||||||
args = let x = pkgs.ctagsWrapped; in concatLists [
|
|
||||||
x.defaultArgs x.phpLang x.jsLang x.nixLang x.asLang x.rubyLang
|
|
||||||
];
|
|
||||||
name = "${ctags.name}-wrapped";
|
|
||||||
};
|
|
||||||
|
|
||||||
### language arguments
|
|
||||||
|
|
||||||
# don't scan version control directories
|
|
||||||
defaultArgs = [
|
|
||||||
"--exclude=.svn"
|
|
||||||
"--exclude=.hg"
|
|
||||||
"--exclude=.git"
|
|
||||||
"--exclude=_darcs"
|
|
||||||
"--sort=yes"
|
|
||||||
];
|
|
||||||
|
|
||||||
# actionscript
|
|
||||||
asLang = [
|
|
||||||
"--langdef=ActionScript"
|
|
||||||
"--langmap=ActionScript:.as"
|
|
||||||
"--regex-ActionScript=/function[ \\t]+([A-Za-z0-9_]+)[ \\t]*\\(/\\1/f,function,functions/"
|
|
||||||
"--regex-ActionScript=/function[ \\t]+(set|get)[ \\t]+([A-Za-z0-9_]+)[ \\t]*\\(/\\2/p,property,properties/"
|
|
||||||
"--regex-ActionScript=/interface[ \\t]+[a-z0-9_.]*([A-Z][A-Za-z0-9_]+)/\\1/i,interface,interfaces/"
|
|
||||||
"--regex-ActionScript=/package[ \\t]+([^ \\t]*)/\\1/p/"
|
|
||||||
"--regex-ActionScript=/class[ \\t]+[a-z0-9_.]*([A-Z][A-Za-z0-9_]+)/\\1/c,class,classes/"
|
|
||||||
];
|
|
||||||
|
|
||||||
# PHP
|
|
||||||
phpLang = [
|
|
||||||
"--langmap=PHP:.php"
|
|
||||||
"--regex-PHP=/abstract class ([^ ]*)/\\1/c/"
|
|
||||||
"--regex-PHP=/interface ([^ ]*)/\\1/i/"
|
|
||||||
"--regex-PHP=/function[ \\t]+([^ (]*)/\\1/f/"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Javascript: also find unnamed functions and functions being passed within a dict.
|
|
||||||
# the dict properties is used to implement duck typing in frameworks
|
|
||||||
# var foo = function () { ... }
|
|
||||||
# {
|
|
||||||
# a : function () {}
|
|
||||||
# only recognize names up 100 characters. Else you'll be in trouble scanning compressed .js files.
|
|
||||||
jsLang = [
|
|
||||||
"--regex-JavaScript=/([^ \\t]{1,100})[ \\t]*:[ \\t]*function[ \\t]*\\(/\\1/f/"
|
|
||||||
];
|
|
||||||
|
|
||||||
# find foo in "foo =", don't think we can do a lot better
|
|
||||||
nixLang = [
|
|
||||||
"--langdef=NIX"
|
|
||||||
"--langmap=NIX:.nix"
|
|
||||||
"--regex-NIX=/([^ \\t*]*)[ \\t]*=/\\1/f/"
|
|
||||||
];
|
|
||||||
|
|
||||||
rubyLang = [
|
|
||||||
"--langmap=RUBY:.rb"
|
|
||||||
"--regex-RUBY=/class ([^ ]*)/\\1/c/"
|
|
||||||
"--regex-RUBY=/^[ ]*module[ ]*([^ ]*)/\\1/m/"
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ stdenvNoCC, fetchurl, newScope, lib, pkgs
|
{ stdenvNoCC, fetchurl, newScope, lib, pkgs
|
||||||
, stdenv, overrideCC
|
, stdenv, overrideCC
|
||||||
, xar, cpio, python3, pbzx, path }:
|
, xar, cpio, python3, pbzx }:
|
||||||
|
|
||||||
let
|
let
|
||||||
mkSusDerivation = args: stdenvNoCC.mkDerivation (args // {
|
mkSusDerivation = args: stdenvNoCC.mkDerivation (args // {
|
||||||
|
@ -120,7 +120,7 @@ let
|
||||||
inherit (pkgs.darwin.apple_sdk_11_0) stdenv;
|
inherit (pkgs.darwin.apple_sdk_11_0) stdenv;
|
||||||
inherit (pkgs) rustc cargo;
|
inherit (pkgs) rustc cargo;
|
||||||
} // {
|
} // {
|
||||||
inherit (pkgs.callPackage (path + "/pkgs/build-support/rust/hooks") {
|
inherit (pkgs.callPackage ../../../build-support/rust/hooks {
|
||||||
inherit (pkgs.darwin.apple_sdk_11_0) stdenv;
|
inherit (pkgs.darwin.apple_sdk_11_0) stdenv;
|
||||||
inherit (pkgs) cargo rustc;
|
inherit (pkgs) cargo rustc;
|
||||||
clang = mkCc pkgs.clang;
|
clang = mkCc pkgs.clang;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
runCommand,
|
runCommand,
|
||||||
writeText,
|
writeText,
|
||||||
sdkVersion,
|
sdkVersion,
|
||||||
path
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -40,7 +39,7 @@ runCommand "sdkroot-${sdkVersion}" { } ''
|
||||||
|
|
||||||
ln -s "$sdk" "$sdk/usr"
|
ln -s "$sdk" "$sdk/usr"
|
||||||
|
|
||||||
install -D '${path + "/pkgs/build-support/setup-hooks/role.bash"}' "$out/nix-support/setup-hook"
|
install -D '${../../../build-support/setup-hooks/role.bash}' "$out/nix-support/setup-hook"
|
||||||
cat >> "$out/nix-support/setup-hook" <<-hook
|
cat >> "$out/nix-support/setup-hook" <<-hook
|
||||||
#
|
#
|
||||||
# See comments in cc-wrapper's setup hook. This works exactly the same way.
|
# See comments in cc-wrapper's setup hook. This works exactly the same way.
|
||||||
|
@ -48,7 +47,7 @@ runCommand "sdkroot-${sdkVersion}" { } ''
|
||||||
[[ -z \''${strictDeps-} ]] || (( "\$hostOffset" < 0 )) || return 0
|
[[ -z \''${strictDeps-} ]] || (( "\$hostOffset" < 0 )) || return 0
|
||||||
|
|
||||||
sdkRootHook() {
|
sdkRootHook() {
|
||||||
# See pkgs/build-support/setup-hooks/role.bash
|
# See ../../../build-support/setup-hooks/role.bash
|
||||||
local role_post
|
local role_post
|
||||||
getHostRoleEnvHook
|
getHostRoleEnvHook
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ runCommand "sdkroot-${sdkVersion}" { } ''
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# See pkgs/build-support/setup-hooks/role.bash
|
# See ../../../build-support/setup-hooks/role.bash
|
||||||
getTargetRole
|
getTargetRole
|
||||||
|
|
||||||
addEnvHooks "\$targetOffset" sdkRootHook
|
addEnvHooks "\$targetOffset" sdkRootHook
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{ stdenv, appleDerivation, lib
|
{ stdenv, appleDerivation, lib
|
||||||
, enableStatic ? stdenv.hostPlatform.isStatic
|
, enableStatic ? stdenv.hostPlatform.isStatic
|
||||||
, enableShared ? !stdenv.hostPlatform.isStatic
|
, enableShared ? !stdenv.hostPlatform.isStatic
|
||||||
, path
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
appleDerivation {
|
appleDerivation {
|
||||||
|
@ -28,8 +27,8 @@ appleDerivation {
|
||||||
'';
|
'';
|
||||||
|
|
||||||
setupHooks = [
|
setupHooks = [
|
||||||
(path + "/pkgs/build-support/setup-hooks/role.bash")
|
../../../../build-support/setup-hooks/role.bash
|
||||||
(path + "/pkgs/by-name/li/libiconv/setup-hook.sh")
|
../../../../development/libraries/libiconv/setup-hook.sh
|
||||||
];
|
];
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
{ stdenv, lib, fetchurl }:
|
|
||||||
|
|
||||||
let
|
|
||||||
|
|
||||||
rootHints = fetchurl {
|
|
||||||
# Original source https://www.internic.net/domain/named.root
|
|
||||||
# occasionally suffers from pointless hash changes,
|
|
||||||
# and having stable sources for older versions has advantages, too.
|
|
||||||
urls = map (prefix: prefix + "d9c96ae96f066a85d7/etc/root.hints") [
|
|
||||||
"https://gitlab.nic.cz/knot/knot-resolver/raw/"
|
|
||||||
"https://raw.githubusercontent.com/CZ-NIC/knot-resolver/"
|
|
||||||
];
|
|
||||||
hash = "sha256-4lG/uPnNHBNIZ/XIeDM1w3iukrpeW0JIjTnGSwkJ8U4=";
|
|
||||||
};
|
|
||||||
|
|
||||||
rootKey = ./root.key;
|
|
||||||
rootDs = ./root.ds;
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
pname = "dns-root-data";
|
|
||||||
version = "2023-11-27";
|
|
||||||
|
|
||||||
buildCommand = ''
|
|
||||||
mkdir $out
|
|
||||||
cp ${rootHints} $out/root.hints
|
|
||||||
cp ${rootKey} $out/root.key
|
|
||||||
cp ${rootDs} $out/root.ds
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
description = "DNS root data including root zone and DNSSEC key";
|
|
||||||
maintainers = with maintainers; [ fpletz vcunat ];
|
|
||||||
license = licenses.gpl3Plus;
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
. IN DS 20326 8 2 E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D
|
|
|
@ -1 +0,0 @@
|
||||||
. 172800 IN DNSKEY 257 3 8 AwEAAaz/tAm8yTn4Mfeh5eyI96WSVexTBAvkMgJzkKTOiW1vkIbzxeF3+/4RgWOq7HrxRixHlFlExOLAJr5emLvN7SWXgnLh4+B5xQlNVz8Og8kvArMtNROxVQuCaSnIDdD5LKyWbRd2n9WGe2R8PzgCmr3EgVLrjyBxWezF0jLHwVN8efS3rCj/EWgvIWgb9tarpVUDK/b58Da+sqqls3eNbuv7pr+eoZG+SrDK6nWeL3c6H5Apxz7LjVc1uTIdsIXxuOLYA4/ilBmSVIzuDWfdRUfhHdY6+cn8HFRm+2hM8AnXGXws9555KrUB5qihylGa8subX2Nn6UwNR1AkUTV74bU= ;{id = 20326 (ksk), size = 2048b}
|
|
|
@ -1,10 +0,0 @@
|
||||||
#!/usr/bin/env nix-shell
|
|
||||||
#!nix-shell -i bash -p busybox unbound
|
|
||||||
|
|
||||||
TMP=`mktemp`
|
|
||||||
unbound-anchor -a "$TMP"
|
|
||||||
grep -Ev "^($$|;)" "$TMP" | sed -e 's/ ;;.*//' > root.key
|
|
||||||
|
|
||||||
unbound-anchor -F -a "$TMP"
|
|
||||||
sed '/^;/d' < "$TMP" > root.ds
|
|
||||||
rm $TMP
|
|
|
@ -2,8 +2,7 @@
|
||||||
, musl-obstack, m4, zlib, zstd, bzip2, bison, flex, gettext, xz, setupDebugInfoDirs
|
, musl-obstack, m4, zlib, zstd, bzip2, bison, flex, gettext, xz, setupDebugInfoDirs
|
||||||
, argp-standalone
|
, argp-standalone
|
||||||
, enableDebuginfod ? true, sqlite, curl, libmicrohttpd, libarchive
|
, enableDebuginfod ? true, sqlite, curl, libmicrohttpd, libarchive
|
||||||
# for passthru.tests
|
, gitUpdater
|
||||||
# , gitUpdater
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
# TODO: Look at the hardcoded paths to kernel, modules etc.
|
# TODO: Look at the hardcoded paths to kernel, modules etc.
|
||||||
|
@ -90,10 +89,10 @@ stdenv.mkDerivation rec {
|
||||||
doInstallCheck = !stdenv.hostPlatform.isMusl
|
doInstallCheck = !stdenv.hostPlatform.isMusl
|
||||||
&& (stdenv.hostPlatform == stdenv.buildPlatform);
|
&& (stdenv.hostPlatform == stdenv.buildPlatform);
|
||||||
|
|
||||||
# passthru.updateScript = gitUpdater {
|
passthru.updateScript = gitUpdater {
|
||||||
# url = "https://sourceware.org/git/elfutils.git";
|
url = "https://sourceware.org/git/elfutils.git";
|
||||||
# rev-prefix = "elfutils-";
|
rev-prefix = "elfutils-";
|
||||||
# };
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
homepage = "https://sourceware.org/elfutils/";
|
homepage = "https://sourceware.org/elfutils/";
|
||||||
|
|
|
@ -1,141 +0,0 @@
|
||||||
{ lib, stdenvNoLibs, buildPackages
|
|
||||||
, gcc, glibc
|
|
||||||
, libiberty
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
stdenv = stdenvNoLibs;
|
|
||||||
gccConfigureFlags = gcc.cc.configureFlags ++ [
|
|
||||||
"--disable-fixincludes"
|
|
||||||
"--disable-intl"
|
|
||||||
"--enable-threads=posix"
|
|
||||||
"--with-glibc-version=${glibc.version}"
|
|
||||||
"--disable-plugin"
|
|
||||||
|
|
||||||
# these are required in order to prevent inhibit_libc=true,
|
|
||||||
# which will cripple libgcc's unwinder; see:
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/213453#issuecomment-1616346163
|
|
||||||
"--with-headers=${lib.getDev glibc}/include"
|
|
||||||
"--with-native-system-header-dir=${lib.getDev glibc}${glibc.incdir or "/include"}"
|
|
||||||
"--with-build-sysroot=/"
|
|
||||||
];
|
|
||||||
|
|
||||||
in stdenv.mkDerivation (finalAttrs: {
|
|
||||||
pname = "libgcc";
|
|
||||||
inherit (gcc.cc) src version;
|
|
||||||
|
|
||||||
outputs = [ "out" "dev" ];
|
|
||||||
|
|
||||||
strictDeps = true;
|
|
||||||
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
|
||||||
nativeBuildInputs = [ libiberty ];
|
|
||||||
buildInputs = [ glibc ];
|
|
||||||
|
|
||||||
postUnpack = ''
|
|
||||||
mkdir -p ./build
|
|
||||||
buildRoot=$(readlink -e "./build")
|
|
||||||
'';
|
|
||||||
|
|
||||||
postPatch =
|
|
||||||
gcc.cc.passthru.forceLibgccToBuildCrtStuff
|
|
||||||
+ ''
|
|
||||||
sourceRoot=$(readlink -e "./libgcc")
|
|
||||||
'';
|
|
||||||
|
|
||||||
hardeningDisable = [ "pie" ];
|
|
||||||
|
|
||||||
preConfigure =
|
|
||||||
''
|
|
||||||
# Drop in libiberty, as external builds are not expected
|
|
||||||
cd "$buildRoot"
|
|
||||||
(
|
|
||||||
mkdir -p build-${stdenv.buildPlatform.config}/libiberty/
|
|
||||||
cd build-${stdenv.buildPlatform.config}/libiberty/
|
|
||||||
ln -s ${buildPackages.libiberty}/lib/libiberty.a ./
|
|
||||||
)
|
|
||||||
mkdir -p "$buildRoot/gcc"
|
|
||||||
cd "$buildRoot/gcc"
|
|
||||||
(
|
|
||||||
# We "shift" the tools over to fake platforms perspective from the previous stage.
|
|
||||||
export AS_FOR_BUILD=${buildPackages.stdenv.cc}/bin/$AS_FOR_BUILD
|
|
||||||
export CC_FOR_BUILD=${buildPackages.stdenv.cc}/bin/$CC_FOR_BUILD
|
|
||||||
export CPP_FOR_BUILD=${buildPackages.stdenv.cc}/bin/$CPP_FOR_BUILD
|
|
||||||
export CXX_FOR_BUILD=${buildPackages.stdenv.cc}/bin/$CXX_FOR_BUILD
|
|
||||||
export LD_FOR_BUILD=${buildPackages.stdenv.cc.bintools}/bin/$LD_FOR_BUILD
|
|
||||||
|
|
||||||
export AS=$AS_FOR_BUILD
|
|
||||||
export CC=$CC_FOR_BUILD
|
|
||||||
export CPP=$CPP_FOR_BUILD
|
|
||||||
export CXX=$CXX_FOR_BUILD
|
|
||||||
export LD=$LD_FOR_BUILD
|
|
||||||
|
|
||||||
export AS_FOR_TARGET=${stdenv.cc}/bin/$AS
|
|
||||||
export CC_FOR_TARGET=${stdenv.cc}/bin/$CC
|
|
||||||
export CPP_FOR_TARGET=${stdenv.cc}/bin/$CPP
|
|
||||||
export LD_FOR_TARGET=${stdenv.cc.bintools}/bin/$LD
|
|
||||||
|
|
||||||
# We define GENERATOR_FILE so nothing bothers looking for GNU GMP.
|
|
||||||
export NIX_CFLAGS_COMPILE_FOR_BUILD+=' -DGENERATOR_FILE=1'
|
|
||||||
|
|
||||||
"$sourceRoot/../gcc/configure" ${lib.concatStringsSep " " gccConfigureFlags}
|
|
||||||
|
|
||||||
# We remove the `libgcc.mvar` deps so that the bootstrap xgcc isn't built.
|
|
||||||
sed -e 's,libgcc.mvars:.*$,libgcc.mvars:,' -i Makefile
|
|
||||||
|
|
||||||
make \
|
|
||||||
config.h \
|
|
||||||
libgcc.mvars \
|
|
||||||
tconfig.h \
|
|
||||||
tm.h \
|
|
||||||
options.h \
|
|
||||||
insn-constants.h \
|
|
||||||
'' + lib.optionalString stdenv.targetPlatform.isM68k ''
|
|
||||||
sysroot-suffix.h \
|
|
||||||
'' + lib.optionalString stdenv.targetPlatform.isAarch32 ''
|
|
||||||
arm-isa.h \
|
|
||||||
arm-cpu.h \
|
|
||||||
'' + ''
|
|
||||||
insn-modes.h
|
|
||||||
)
|
|
||||||
mkdir -p "$buildRoot/gcc/include"
|
|
||||||
|
|
||||||
# Preparing to configure + build libgcc itself
|
|
||||||
mkdir -p "$buildRoot/gcc/${stdenv.hostPlatform.config}/libgcc"
|
|
||||||
cd "$buildRoot/gcc/${stdenv.hostPlatform.config}/libgcc"
|
|
||||||
configureScript=$sourceRoot/configure
|
|
||||||
chmod +x "$configureScript"
|
|
||||||
|
|
||||||
export AS_FOR_BUILD=${buildPackages.stdenv.cc}/bin/$AS_FOR_BUILD
|
|
||||||
export CC_FOR_BUILD=${buildPackages.stdenv.cc}/bin/$CC_FOR_BUILD
|
|
||||||
export CPP_FOR_BUILD=${buildPackages.stdenv.cc}/bin/$CPP_FOR_BUILD
|
|
||||||
export CXX_FOR_BUILD=${buildPackages.stdenv.cc}/bin/$CXX_FOR_BUILD
|
|
||||||
export LD_FOR_BUILD=${buildPackages.stdenv.cc.bintools}/bin/$LD_FOR_BUILD
|
|
||||||
|
|
||||||
export AS=${stdenv.cc}/bin/$AS
|
|
||||||
export CC=${stdenv.cc}/bin/$CC
|
|
||||||
export CPP=${stdenv.cc}/bin/$CPP
|
|
||||||
export CXX=${stdenv.cc}/bin/$CXX
|
|
||||||
export LD=${stdenv.cc.bintools}/bin/$LD
|
|
||||||
|
|
||||||
export AS_FOR_TARGET=${stdenv.cc}/bin/$AS_FOR_TARGET
|
|
||||||
export CC_FOR_TARGET=${stdenv.cc}/bin/$CC_FOR_TARGET
|
|
||||||
export CPP_FOR_TARGET=${stdenv.cc}/bin/$CPP_FOR_TARGET
|
|
||||||
export LD_FOR_TARGET=${stdenv.cc.bintools}/bin/$LD_FOR_TARGET
|
|
||||||
'';
|
|
||||||
|
|
||||||
configurePlatforms = [ "build" "host" ];
|
|
||||||
configureFlags = [
|
|
||||||
"cross_compiling=true"
|
|
||||||
"--disable-gcov"
|
|
||||||
"--with-glibc-version=${glibc.version}"
|
|
||||||
];
|
|
||||||
|
|
||||||
makeFlags = [ "MULTIBUILDTOP:=../" ];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
moveToOutput "lib/gcc/${stdenv.hostPlatform.config}/${finalAttrs.version}/include" "$dev"
|
|
||||||
mkdir -p "$out/lib" "$dev/include"
|
|
||||||
ln -s "$out/lib/gcc/${stdenv.hostPlatform.config}/${finalAttrs.version}"/* "$out/lib"
|
|
||||||
ln -s "$dev/lib/gcc/${stdenv.hostPlatform.config}/${finalAttrs.version}/include"/* "$dev/include/"
|
|
||||||
'';
|
|
||||||
})
|
|
|
@ -16,11 +16,12 @@ with pkgs;
|
||||||
# Being redundant to avoid cycles on boot. TODO: find a better way
|
# Being redundant to avoid cycles on boot. TODO: find a better way
|
||||||
glibcCross = callPackage ./. {
|
glibcCross = callPackage ./. {
|
||||||
stdenv = gccCrossLibcStdenv; # doesn't compile without gcc
|
stdenv = gccCrossLibcStdenv; # doesn't compile without gcc
|
||||||
libgcc = callPackage ./libgcc {
|
# TODO: Fix broken reference to libgcc
|
||||||
gcc = gccCrossLibcStdenv.cc;
|
# libgcc = callPackage ../core/gcc/libgcc {
|
||||||
glibc = glibcCross.override { libgcc = null; };
|
# gcc = gccCrossLibcStdenv.cc;
|
||||||
stdenvNoLibs = gccCrossLibcStdenv;
|
# glibc = glibcCross.override { libgcc = null; };
|
||||||
};
|
# stdenvNoLibs = gccCrossLibcStdenv;
|
||||||
|
# };
|
||||||
};
|
};
|
||||||
|
|
||||||
# Only supported on Linux and only on glibc
|
# Only supported on Linux and only on glibc
|
||||||
|
|
|
@ -1,451 +0,0 @@
|
||||||
{ lib, stdenv
|
|
||||||
, fetchurl, perl, gcc
|
|
||||||
, ncurses5
|
|
||||||
, ncurses6, gmp, libiconv, numactl
|
|
||||||
, llvmPackages
|
|
||||||
, coreutils
|
|
||||||
, targetPackages
|
|
||||||
|
|
||||||
# minimal = true; will remove files that aren't strictly necessary for
|
|
||||||
# regular builds and GHC bootstrapping.
|
|
||||||
# This is "useful" for staying within hydra's output limits for at least the
|
|
||||||
# aarch64-linux architecture.
|
|
||||||
, minimal ? false
|
|
||||||
}:
|
|
||||||
|
|
||||||
# Prebuilt only does native
|
|
||||||
assert stdenv.targetPlatform == stdenv.hostPlatform;
|
|
||||||
|
|
||||||
let
|
|
||||||
downloadsUrl = "https://downloads.haskell.org/ghc";
|
|
||||||
|
|
||||||
# Copy sha256 from https://downloads.haskell.org/~ghc/8.10.7/SHA256SUMS
|
|
||||||
version = "8.10.7";
|
|
||||||
|
|
||||||
# Information about available bindists that we use in the build.
|
|
||||||
#
|
|
||||||
# # Bindist library checking
|
|
||||||
#
|
|
||||||
# The field `archSpecificLibraries` also provides a way for us get notified
|
|
||||||
# early when the upstream bindist changes its dependencies (e.g. because a
|
|
||||||
# newer Debian version is used that uses a new `ncurses` version).
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# * You can find the `fileToCheckFor` of libraries by running `readelf -d`
|
|
||||||
# on the compiler binary (`exePathForLibraryCheck`).
|
|
||||||
# * To skip library checking for an architecture,
|
|
||||||
# set `exePathForLibraryCheck = null`.
|
|
||||||
# * To skip file checking for a specific arch specfic library,
|
|
||||||
# set `fileToCheckFor = null`.
|
|
||||||
ghcBinDists = {
|
|
||||||
# Binary distributions for the default libc (e.g. glibc, or libSystem on Darwin)
|
|
||||||
# nixpkgs uses for the respective system.
|
|
||||||
defaultLibc = {
|
|
||||||
i686-linux = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
|
|
||||||
sha256 = "fbfc1ef194f4e7a4c0da8c11cc69b17458a4b928b609b3622c97acc4acd5c5ab";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
# The i686-linux bindist provided by GHC HQ is currently built on Debian 9,
|
|
||||||
# which link it against `libtinfo.so.5` (ncurses 5).
|
|
||||||
# Other bindists are linked `libtinfo.so.6` (ncurses 6).
|
|
||||||
{ nixPackage = ncurses5; fileToCheckFor = "libtinfo.so.5"; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
x86_64-linux = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz";
|
|
||||||
sha256 = "a13719bca87a0d3ac0c7d4157a4e60887009a7f1a8dbe95c4759ec413e086d30";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
armv7l-linux = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-armv7-deb10-linux.tar.xz";
|
|
||||||
sha256 = "3949c31bdf7d3b4afb765ea8246bca4ca9707c5d988d9961a244f0da100956a2";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
aarch64-linux = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
|
|
||||||
sha256 = "fad2417f9b295233bf8ade79c0e6140896359e87be46cb61cd1d35863d9d0e55";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
|
||||||
{ nixPackage = numactl; fileToCheckFor = null; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
x86_64-darwin = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
|
|
||||||
sha256 = "287db0f9c338c9f53123bfa8731b0996803ee50f6ee847fe388092e5e5132047";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = null; # we don't have a library check for darwin yet
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = libiconv; fileToCheckFor = null; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
aarch64-darwin = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz";
|
|
||||||
sha256 = "dc469fc3c35fd2a33a5a575ffce87f13de7b98c2d349a41002e200a56d9bba1c";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = null; # we don't have a library check for darwin yet
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = libiconv; fileToCheckFor = null; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
# Binary distributions for the musl libc for the respective system.
|
|
||||||
musl = {
|
|
||||||
x86_64-linux = {
|
|
||||||
variantSuffix = "-musl-integer-simple";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3.10-linux-integer-simple.tar.xz";
|
|
||||||
sha256 = "16903df850ef73d5246f2ff169cbf57ecab76c2ac5acfa9928934282cfad575c";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = "bin/ghc";
|
|
||||||
archSpecificLibraries = [
|
|
||||||
# No `gmp` here, since this is an `integer-simple` bindist.
|
|
||||||
|
|
||||||
# In contrast to glibc builds, the musl-bindist uses `libncursesw.so.*`
|
|
||||||
# instead of `libtinfo.so.*.`
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; }
|
|
||||||
];
|
|
||||||
isHadrian = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
distSetName = if stdenv.hostPlatform.isMusl then "musl" else "defaultLibc";
|
|
||||||
|
|
||||||
binDistUsed = ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}
|
|
||||||
or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')");
|
|
||||||
|
|
||||||
useLLVM = !stdenv.targetPlatform.isx86;
|
|
||||||
|
|
||||||
libPath =
|
|
||||||
lib.makeLibraryPath (
|
|
||||||
# Add arch-specific libraries.
|
|
||||||
map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries
|
|
||||||
);
|
|
||||||
|
|
||||||
libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
|
|
||||||
+ "LD_LIBRARY_PATH";
|
|
||||||
|
|
||||||
runtimeDeps = [
|
|
||||||
targetPackages.stdenv.cc
|
|
||||||
targetPackages.stdenv.cc.bintools
|
|
||||||
coreutils # for cat
|
|
||||||
]
|
|
||||||
++ lib.optionals useLLVM [
|
|
||||||
(lib.getBin llvmPackages.llvm)
|
|
||||||
]
|
|
||||||
# On darwin, we need unwrapped bintools as well (for otool)
|
|
||||||
++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
|
|
||||||
targetPackages.stdenv.cc.bintools.bintools
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
inherit version;
|
|
||||||
pname = "ghc-binary${binDistUsed.variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl binDistUsed.src;
|
|
||||||
|
|
||||||
# Note that for GHC 8.10 versions >= 8.10.6, the GHC HQ musl bindist
|
|
||||||
# uses `integer-simple` and has no `gmp` dependency:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/commit/8306501020cd66f683ad9c215fa8e16c2d62357d
|
|
||||||
# Related nixpkgs issues:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/pull/130441#issuecomment-922452843
|
|
||||||
# TODO: When this file is copied to `ghc-9.*-binary.nix`, determine whether
|
|
||||||
# the GHC 9 branch also switched from `gmp` to `integer-simple` via the
|
|
||||||
# currently-open issue:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20059
|
|
||||||
# and update this comment accordingly.
|
|
||||||
|
|
||||||
nativeBuildInputs = [ perl ];
|
|
||||||
|
|
||||||
# Set LD_LIBRARY_PATH or equivalent so that the programs running as part
|
|
||||||
# of the bindist installer can find the libraries they expect.
|
|
||||||
# Cannot patchelf beforehand due to relative RPATHs that anticipate
|
|
||||||
# the final install location.
|
|
||||||
${libEnvVar} = libPath;
|
|
||||||
|
|
||||||
postUnpack =
|
|
||||||
# Verify our assumptions of which `libtinfo.so` (ncurses) version is used,
|
|
||||||
# so that we know when ghc bindists upgrade that and we need to update the
|
|
||||||
# version used in `libPath`.
|
|
||||||
lib.optionalString
|
|
||||||
(binDistUsed.exePathForLibraryCheck != null)
|
|
||||||
# Note the `*` glob because some GHCs have a suffix when unpacked, e.g.
|
|
||||||
# the musl bindist has dir `ghc-VERSION-x86_64-unknown-linux/`.
|
|
||||||
# As a result, don't shell-quote this glob when splicing the string.
|
|
||||||
(let buildExeGlob = ''ghc-${version}*/"${binDistUsed.exePathForLibraryCheck}"''; in
|
|
||||||
lib.concatStringsSep "\n" [
|
|
||||||
(''
|
|
||||||
shopt -u nullglob
|
|
||||||
echo "Checking that ghc binary exists in bindist at ${buildExeGlob}"
|
|
||||||
if ! test -e ${buildExeGlob}; then
|
|
||||||
echo >&2 "GHC binary ${binDistUsed.exePathForLibraryCheck} could not be found in the bindist build directory (at ${buildExeGlob}) for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
|
||||||
fi
|
|
||||||
'')
|
|
||||||
(lib.concatMapStringsSep
|
|
||||||
"\n"
|
|
||||||
({ fileToCheckFor, nixPackage }:
|
|
||||||
lib.optionalString (fileToCheckFor != null) ''
|
|
||||||
echo "Checking bindist for ${fileToCheckFor} to ensure that is still used"
|
|
||||||
if ! readelf -d ${buildExeGlob} | grep "${fileToCheckFor}"; then
|
|
||||||
echo >&2 "File ${fileToCheckFor} could not be found in ${binDistUsed.exePathForLibraryCheck} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Checking that the nix package ${nixPackage} contains ${fileToCheckFor}"
|
|
||||||
if ! test -e "${lib.getLib nixPackage}/lib/${fileToCheckFor}"; then
|
|
||||||
echo >&2 "Nix package ${nixPackage} did not contain ${fileToCheckFor} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
|
||||||
fi
|
|
||||||
''
|
|
||||||
)
|
|
||||||
binDistUsed.archSpecificLibraries
|
|
||||||
)
|
|
||||||
])
|
|
||||||
# GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
|
|
||||||
# during linking
|
|
||||||
+ lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
# not enough room in the object files for the full path to libiconv :(
|
|
||||||
for exe in $(find . -type f -executable); do
|
|
||||||
isScript $exe && continue
|
|
||||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
|
||||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
|
||||||
done
|
|
||||||
'' +
|
|
||||||
|
|
||||||
# Some scripts used during the build need to have their shebangs patched
|
|
||||||
''
|
|
||||||
patchShebangs ghc-${version}/utils/
|
|
||||||
patchShebangs ghc-${version}/configure
|
|
||||||
test -d ghc-${version}/inplace/bin && \
|
|
||||||
patchShebangs ghc-${version}/inplace/bin
|
|
||||||
'' +
|
|
||||||
# We have to patch the GMP paths for the integer-gmp package.
|
|
||||||
# Note that musl bindists do not contain them,
|
|
||||||
# see: https://gitlab.haskell.org/ghc/ghc/-/issues/20073#note_363231
|
|
||||||
# However, musl bindists >= 8.10.6 use `integer-simple`, not `gmp`.
|
|
||||||
''
|
|
||||||
find . -name integer-gmp.buildinfo \
|
|
||||||
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
find . -name base.buildinfo \
|
|
||||||
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
|
|
||||||
'' +
|
|
||||||
# aarch64 does HAVE_NUMA so -lnuma requires it in library-dirs in rts/package.conf.in
|
|
||||||
# FFI_LIB_DIR is a good indication of places it must be needed.
|
|
||||||
lib.optionalString (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) ''
|
|
||||||
find . -name package.conf.in \
|
|
||||||
-exec sed -i "s@FFI_LIB_DIR@FFI_LIB_DIR ${numactl.out}/lib@g" {} \;
|
|
||||||
'' +
|
|
||||||
# Rename needed libraries and binaries, fix interpreter
|
|
||||||
lib.optionalString stdenv.isLinux ''
|
|
||||||
find . -type f -executable -exec patchelf \
|
|
||||||
--interpreter ${stdenv.cc.bintools.dynamicLinker} {} \;
|
|
||||||
'' +
|
|
||||||
# The hadrian install Makefile uses 'xxx' as a temporary placeholder in path
|
|
||||||
# substitution. Which can break the build if the store path / prefix happens
|
|
||||||
# to contain this string. This will be fixed with 9.4 bindists.
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/21402
|
|
||||||
''
|
|
||||||
# Detect hadrian Makefile by checking for the target that has the problem
|
|
||||||
if grep '^update_package_db' ghc-${version}*/Makefile > /dev/null; then
|
|
||||||
echo Hadrian bindist, applying workaround for xxx path substitution.
|
|
||||||
# based on https://gitlab.haskell.org/ghc/ghc/-/commit/dd5fecb0e2990b192d92f4dfd7519ecb33164fad.patch
|
|
||||||
substituteInPlace ghc-${version}*/Makefile --replace 'xxx' '\0xxx\0'
|
|
||||||
else
|
|
||||||
echo Not a hadrian bindist, not applying xxx path workaround.
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
# fix for `configure: error: Your linker is affected by binutils #16177`
|
|
||||||
preConfigure = lib.optionalString
|
|
||||||
stdenv.targetPlatform.isAarch32
|
|
||||||
"LD=ld.gold";
|
|
||||||
|
|
||||||
configurePlatforms = [ ];
|
|
||||||
configureFlags = [
|
|
||||||
"--with-gmp-includes=${lib.getDev gmp}/include"
|
|
||||||
# Note `--with-gmp-libraries` does nothing for GHC bindists:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124
|
|
||||||
] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
|
|
||||||
# From: https://github.com/NixOS/nixpkgs/pull/43369/commits
|
|
||||||
++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
|
|
||||||
|
|
||||||
# No building is necessary, but calling make without flags ironically
|
|
||||||
# calls install-strip ...
|
|
||||||
dontBuild = true;
|
|
||||||
|
|
||||||
# Patch scripts to include runtime dependencies in $PATH.
|
|
||||||
postInstall = ''
|
|
||||||
for i in "$out/bin/"*; do
|
|
||||||
test ! -h "$i" || continue
|
|
||||||
isScript "$i" || continue
|
|
||||||
sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Apparently necessary for the ghc Alpine (musl) bindist:
|
|
||||||
# When we strip, and then run the
|
|
||||||
# patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
|
|
||||||
# below, running ghc (e.g. during `installCheckPhase)` gives some apparently
|
|
||||||
# corrupted rpath or whatever makes the loader work on nonsensical strings:
|
|
||||||
# running install tests
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: : symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: ir6zf6c9f86pfx8sr30n2vjy-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: y/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: <20>: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: <20>?: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
|
|
||||||
# This is extremely bogus and should be investigated.
|
|
||||||
dontStrip = if stdenv.hostPlatform.isMusl then true else false; # `if` for explicitness
|
|
||||||
|
|
||||||
# On Linux, use patchelf to modify the executables so that they can
|
|
||||||
# find editline/gmp.
|
|
||||||
postFixup = lib.optionalString stdenv.isLinux
|
|
||||||
(if stdenv.hostPlatform.isAarch64 then
|
|
||||||
# Keep rpath as small as possible on aarch64 for patchelf#244. All Elfs
|
|
||||||
# are 2 directories deep from $out/lib, so pooling symlinks there makes
|
|
||||||
# a short rpath.
|
|
||||||
''
|
|
||||||
(cd $out/lib; ln -s ${ncurses6.out}/lib/libtinfo.so.6)
|
|
||||||
(cd $out/lib; ln -s ${gmp.out}/lib/libgmp.so.10)
|
|
||||||
(cd $out/lib; ln -s ${numactl.out}/lib/libnuma.so.1)
|
|
||||||
for p in $(find "$out/lib" -type f -name "*\.so*"); do
|
|
||||||
(cd $out/lib; ln -s $p)
|
|
||||||
done
|
|
||||||
|
|
||||||
for p in $(find "$out/lib" -type f -executable); do
|
|
||||||
if isELF "$p"; then
|
|
||||||
echo "Patchelfing $p"
|
|
||||||
patchelf --set-rpath "\$ORIGIN:\$ORIGIN/../.." $p
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
''
|
|
||||||
else
|
|
||||||
''
|
|
||||||
for p in $(find "$out" -type f -executable); do
|
|
||||||
if isELF "$p"; then
|
|
||||||
echo "Patchelfing $p"
|
|
||||||
patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
'') + lib.optionalString stdenv.isDarwin ''
|
|
||||||
# not enough room in the object files for the full path to libiconv :(
|
|
||||||
for exe in $(find "$out" -type f -executable); do
|
|
||||||
isScript $exe && continue
|
|
||||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
|
||||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
|
||||||
done
|
|
||||||
|
|
||||||
for file in $(find "$out" -name setup-config); do
|
|
||||||
substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
|
|
||||||
done
|
|
||||||
'' +
|
|
||||||
lib.optionalString minimal ''
|
|
||||||
# Remove profiling files
|
|
||||||
find $out -type f -name '*.p_o' -delete
|
|
||||||
find $out -type f -name '*.p_hi' -delete
|
|
||||||
find $out -type f -name '*_p.a' -delete
|
|
||||||
# `-f` because e.g. musl bindist does not have this file.
|
|
||||||
rm -f $out/lib/ghc-*/bin/ghc-iserv-prof
|
|
||||||
# Hydra will redistribute this derivation, so we have to keep the docs for
|
|
||||||
# legal reasons (retaining the legal notices etc)
|
|
||||||
# As a last resort we could unpack the docs separately and symlink them in.
|
|
||||||
# They're in $out/share/{doc,man}.
|
|
||||||
'';
|
|
||||||
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
doInstallCheck = true;
|
|
||||||
installCheckPhase = ''
|
|
||||||
# Sanity check, can ghc create executables?
|
|
||||||
cd $TMP
|
|
||||||
mkdir test-ghc; cd test-ghc
|
|
||||||
cat > main.hs << EOF
|
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
|
||||||
module Main where
|
|
||||||
main = putStrLn \$([|"yes"|])
|
|
||||||
EOF
|
|
||||||
env -i $out/bin/ghc --make main.hs || exit 1
|
|
||||||
echo compilation ok
|
|
||||||
[ $(./main) == "yes" ]
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
targetPrefix = "";
|
|
||||||
enableShared = true;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
}
|
|
||||||
# We duplicate binDistUsed here since we have a sensible default even if no bindist is avaible,
|
|
||||||
# this makes sure that getting the `meta` attribute doesn't throw even on unsupported platforms.
|
|
||||||
// lib.optionalAttrs (ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}.isHadrian or false) {
|
|
||||||
# Normal GHC derivations expose the hadrian derivation used to build them
|
|
||||||
# here. In the case of bindists we just make sure that the attribute exists,
|
|
||||||
# as it is used for checking if a GHC derivation has been built with hadrian.
|
|
||||||
# The isHadrian mechanism will become obsolete with GHCs that use hadrian
|
|
||||||
# exclusively, i.e. 9.6 (and 9.4?).
|
|
||||||
hadrian = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = rec {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
license = lib.licenses.bsd3;
|
|
||||||
# HACK: since we can't encode the libc / abi in platforms, we need
|
|
||||||
# to make the platform list dependent on the evaluation platform
|
|
||||||
# in order to avoid eval errors with musl which supports less
|
|
||||||
# platforms than the default libcs (i. e. glibc / libSystem).
|
|
||||||
# This is done for the benefit of Hydra, so `packagePlatforms`
|
|
||||||
# won't return any platforms that would cause an evaluation
|
|
||||||
# failure for `pkgsMusl.haskell.compiler.ghc8107Binary`, as
|
|
||||||
# long as the evaluator runs on a platform that supports
|
|
||||||
# `pkgsMusl`.
|
|
||||||
platforms = builtins.attrNames ghcBinDists.${distSetName};
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,411 +0,0 @@
|
||||||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
|
||||||
|
|
||||||
# build-tools
|
|
||||||
, bootPkgs
|
|
||||||
, autoreconfHook, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
|
|
||||||
, xattr, autoSignDarwinBinariesHook
|
|
||||||
, bash
|
|
||||||
|
|
||||||
, libiconv ? null, ncurses
|
|
||||||
|
|
||||||
, # GHC can be built with system libffi or a bundled one.
|
|
||||||
libffi ? null
|
|
||||||
|
|
||||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
|
||||||
|| stdenv.targetPlatform.isPower
|
|
||||||
|| stdenv.targetPlatform.isSparc)
|
|
||||||
, # LLVM is conceptually a run-time-only dependency, but for
|
|
||||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
|
||||||
# build-time dependency too.
|
|
||||||
buildTargetLlvmPackages, llvmPackages
|
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
|
|
||||||
# library instead of the faster but GPLed integer-gmp library.
|
|
||||||
enableIntegerSimple ? !(lib.meta.availableOn stdenv.hostPlatform gmp
|
|
||||||
&& lib.meta.availableOn stdenv.targetPlatform gmp)
|
|
||||||
, gmp
|
|
||||||
|
|
||||||
, # If enabled, use -fPIC when compiling static libs.
|
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
|
||||||
|
|
||||||
, enableProfiledLibs ? true
|
|
||||||
|
|
||||||
, # Whether to build dynamic libs for the standard library (on the target
|
|
||||||
# platform). Static libs are always built.
|
|
||||||
enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
|
|
||||||
|
|
||||||
, # Whether to build terminfo.
|
|
||||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
|
||||||
|
|
||||||
, # What flavour to build. An empty string indicates no
|
|
||||||
# specific flavour and falls back to ghc default values.
|
|
||||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
|
||||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
|
||||||
|
|
||||||
, # Whether to build sphinx documentation.
|
|
||||||
enableDocs ? (
|
|
||||||
# Docs disabled if we are building on musl because it's a large task to keep
|
|
||||||
# all `sphinx` dependencies building in this environment.
|
|
||||||
!stdenv.buildPlatform.isMusl
|
|
||||||
)
|
|
||||||
|
|
||||||
, enableHaddockProgram ?
|
|
||||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
|
||||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
|
||||||
|
|
||||||
, # Whether to disable the large address space allocator
|
|
||||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
|
||||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
|
||||||
}:
|
|
||||||
|
|
||||||
assert !enableIntegerSimple -> gmp != null;
|
|
||||||
|
|
||||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
|
||||||
# see note [HADDOCK_DOCS].
|
|
||||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
|
||||||
|
|
||||||
inherit (bootPkgs) ghc;
|
|
||||||
|
|
||||||
# TODO(@Ericson2314) Make unconditional
|
|
||||||
targetPrefix = lib.optionalString
|
|
||||||
(targetPlatform != hostPlatform)
|
|
||||||
"${targetPlatform.config}-";
|
|
||||||
|
|
||||||
buildMK = ''
|
|
||||||
BuildFlavour = ${ghcFlavour}
|
|
||||||
ifneq \"\$(BuildFlavour)\" \"\"
|
|
||||||
include mk/flavours/\$(BuildFlavour).mk
|
|
||||||
endif
|
|
||||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
|
||||||
BUILD_SPHINX_PDF = NO
|
|
||||||
'' +
|
|
||||||
# Note [HADDOCK_DOCS]:
|
|
||||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
|
||||||
# program is built (which we generally always want to have a complete GHC install)
|
|
||||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
|
||||||
# (which is impossible for cross-compilation); see:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
|
||||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
|
||||||
# program, so it can never generate haddocks for any packages.
|
|
||||||
# If this is solved in the future, we'd like to unconditionally
|
|
||||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
|
||||||
''
|
|
||||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
|
||||||
# Build haddocks for boot packages with hyperlinking
|
|
||||||
EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
|
|
||||||
|
|
||||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
|
||||||
INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
|
|
||||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
|
||||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
|
||||||
CrossCompilePrefix = ${targetPrefix}
|
|
||||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
|
||||||
BUILD_PROF_LIBS = NO
|
|
||||||
'' + lib.optionalString enableRelocatedStaticLibs ''
|
|
||||||
GhcLibHcOpts += -fPIC
|
|
||||||
GhcRtsHcOpts += -fPIC
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
EXTRA_CC_OPTS += -std=gnu99
|
|
||||||
''
|
|
||||||
# While split sections are now enabled by default in ghc 8.8 for windows,
|
|
||||||
# they seem to lead to `too many sections` errors when building base for
|
|
||||||
# profiling.
|
|
||||||
+ lib.optionalString targetPlatform.isWindows ''
|
|
||||||
SplitSections = NO
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Splicer will pull out correct variations
|
|
||||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
|
||||||
++ [libffi]
|
|
||||||
++ lib.optional (!enableIntegerSimple) gmp
|
|
||||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
|
||||||
|
|
||||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
|
||||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
|
||||||
toolsForTarget = [
|
|
||||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
|
||||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
|
||||||
|
|
||||||
targetCC = builtins.head toolsForTarget;
|
|
||||||
|
|
||||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
|
||||||
# derivation for certain tools depending on the platform.
|
|
||||||
bintoolsFor = {
|
|
||||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
|
||||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
|
||||||
# x86_64-darwin.
|
|
||||||
install_name_tool =
|
|
||||||
if stdenv.targetPlatform.isAarch64
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
# Same goes for strip.
|
|
||||||
strip =
|
|
||||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
|
||||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
|
||||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
|
||||||
# see #84670 and #49071 for more background.
|
|
||||||
useLdGold = targetPlatform.linker == "gold" ||
|
|
||||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
|
||||||
|
|
||||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
|
||||||
variantSuffix = lib.concatStrings [
|
|
||||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
|
||||||
(lib.optionalString enableIntegerSimple "-integer-simple")
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
|
||||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
|
||||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
|
||||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
|
||||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
|
||||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
|
||||||
version = "8.10.7";
|
|
||||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
|
||||||
sha256 = "e3eef6229ce9908dfe1ea41436befb0455fefb1932559e860ad4c606b0d03c9d";
|
|
||||||
};
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
outputs = [ "out" "doc" ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# Fix docs build with sphinx >= 6.0
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/22766
|
|
||||||
(fetchpatch {
|
|
||||||
name = "ghc-docs-sphinx-6.0.patch";
|
|
||||||
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch";
|
|
||||||
sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv";
|
|
||||||
})
|
|
||||||
|
|
||||||
# See upstream patch at
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4885. Since we build
|
|
||||||
# from source distributions, the auto-generated configure script needs to be
|
|
||||||
# patched as well, therefore we use an in-tree patch instead of pulling the
|
|
||||||
# upstream patch. Don't forget to check backport status of the upstream patch
|
|
||||||
# when adding new GHC releases in nixpkgs.
|
|
||||||
./respect-ar-path.patch
|
|
||||||
|
|
||||||
# fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch";
|
|
||||||
sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk=";
|
|
||||||
extraPrefix = "utils/haddock/";
|
|
||||||
stripLen = 1;
|
|
||||||
})
|
|
||||||
|
|
||||||
# cabal passes incorrect --host= when cross-compiling
|
|
||||||
# https://github.com/haskell/cabal/issues/5887
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/122bd81150386867da07fdc9ad5096db6719545a/overlays/patches/ghc/cabal-host.patch";
|
|
||||||
sha256 = "sha256:0yd0sajgi24sc1w5m55lkg2lp6kfkgpp3lgija2c8y3cmkwfpdc1";
|
|
||||||
})
|
|
||||||
|
|
||||||
# In order to build ghcjs packages, the Cabal of the ghc used for the ghcjs
|
|
||||||
# needs to be patched. Ref https://github.com/haskell/cabal/pull/7575
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://github.com/haskell/cabal/commit/369c4a0a54ad08a9e6b0d3bd303fedd7b5e5a336.patch";
|
|
||||||
sha256 = "120f11hwyaqa0pq9g5l1300crqij49jg0rh83hnp9sa49zfdwx1n";
|
|
||||||
stripLen = 3;
|
|
||||||
extraPrefix = "libraries/Cabal/Cabal/";
|
|
||||||
})
|
|
||||||
|
|
||||||
# We need to be able to set AR_STAGE0 and LD_STAGE0 when cross-compiling
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/8f7dd5710b80906ea7a3e15b7bb56a883a49fed8.patch";
|
|
||||||
hash = "sha256-C636Nq2U8YOG/av7XQmG3L1rU0bmC9/7m7Hty5pm5+s=";
|
|
||||||
})
|
|
||||||
] ++ lib.optionals stdenv.isDarwin [
|
|
||||||
# Make Block.h compile with c++ compilers. Remove with the next release
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/97d0b0a367e4c6a52a17c3299439ac7de129da24.patch";
|
|
||||||
sha256 = "0r4zjj0bv1x1m2dgxp3adsf2xkr94fjnyj1igsivd9ilbs5ja0b5";
|
|
||||||
})
|
|
||||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
|
||||||
# Prevent the paths module from emitting symbols that we don't use
|
|
||||||
# when building with separate outputs.
|
|
||||||
#
|
|
||||||
# These cause problems as they're not eliminated by GHC's dead code
|
|
||||||
# elimination on aarch64-darwin. (see
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
|
||||||
./Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = "patchShebangs .";
|
|
||||||
|
|
||||||
# GHC is a bit confused on its cross terminology.
|
|
||||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
|
||||||
preConfigure = ''
|
|
||||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
|
||||||
export "''${env#TARGET_}=''${!env}"
|
|
||||||
done
|
|
||||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
|
||||||
# the *host* tools.
|
|
||||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
|
||||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
|
||||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
|
||||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
|
||||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
|
||||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
|
||||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
|
||||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
|
||||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
|
||||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
|
||||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
|
||||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
|
||||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
|
||||||
'' + lib.optionalString useLLVM ''
|
|
||||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
|
||||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
|
||||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
|
||||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
|
||||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
|
||||||
'' + ''
|
|
||||||
|
|
||||||
echo -n "${buildMK}" > mk/build.mk
|
|
||||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
|
||||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
||||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
|
|
||||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
|
||||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
|
||||||
'' + lib.optionalString targetPlatform.isMusl ''
|
|
||||||
echo "patching llvm-targets for musl targets..."
|
|
||||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
|
||||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
|
||||||
echo "(go go gadget sed)"
|
|
||||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
|
||||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
|
||||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
|
||||||
|
|
||||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
|
||||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
|
||||||
for x in configure aclocal.m4; do
|
|
||||||
substituteInPlace $x \
|
|
||||||
--replace '*-android*|*-gnueabi*)' \
|
|
||||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
|
||||||
configurePlatforms = [ "build" "host" ]
|
|
||||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
|
||||||
|
|
||||||
# `--with` flags for libraries needed for RTS linker
|
|
||||||
configureFlags = [
|
|
||||||
"--datadir=$doc/share/doc/ghc"
|
|
||||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
|
||||||
] ++ lib.optionals (libffi != null) [
|
|
||||||
"--with-system-libffi"
|
|
||||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
|
||||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
|
|
||||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
|
||||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
|
||||||
"--with-iconv-includes=${libiconv}/include"
|
|
||||||
"--with-iconv-libraries=${libiconv}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
|
||||||
"--enable-bootstrap-with-devel-snapshot"
|
|
||||||
] ++ lib.optionals useLdGold [
|
|
||||||
"CFLAGS=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
|
||||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
|
||||||
"--disable-large-address-space"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
|
||||||
dontAddExtraLibs = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
perl autoreconfHook autoconf automake m4 python3
|
|
||||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
|
||||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
||||||
autoSignDarwinBinariesHook
|
|
||||||
] ++ lib.optionals enableDocs [
|
|
||||||
sphinx
|
|
||||||
];
|
|
||||||
|
|
||||||
# For building runtime libs
|
|
||||||
depsBuildTarget = toolsForTarget;
|
|
||||||
|
|
||||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
|
||||||
|
|
||||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
|
||||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
|
||||||
|
|
||||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
||||||
# that in turn causes GHCi to abort
|
|
||||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
|
||||||
|
|
||||||
checkTarget = "test";
|
|
||||||
|
|
||||||
hardeningDisable =
|
|
||||||
[ "format" ]
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
# big-parallel allows us to build with more than 2 cores on
|
|
||||||
# Hydra which already warrants a significant speedup
|
|
||||||
requiredSystemFeatures = [ "big-parallel" ];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
# Install the bash completion file.
|
|
||||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit bootPkgs targetPrefix;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
inherit enableShared;
|
|
||||||
|
|
||||||
# This is used by the haskell builder to query
|
|
||||||
# the presence of the haddock program.
|
|
||||||
hasHaddock = enableHaddockProgram;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
timeout = 24 * 3600;
|
|
||||||
inherit (ghc.meta) license platforms;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
|
||||||
dontStrip = true;
|
|
||||||
dontPatchELF = true;
|
|
||||||
noAuditTmpdir = true;
|
|
||||||
})
|
|
|
@ -1,229 +0,0 @@
|
||||||
{ lib, stdenv
|
|
||||||
, fetchurl, perl, gcc
|
|
||||||
, ncurses5, ncurses6, gmp, glibc, libiconv
|
|
||||||
, llvmPackages
|
|
||||||
, coreutils
|
|
||||||
, targetPackages
|
|
||||||
}:
|
|
||||||
|
|
||||||
# Prebuilt only does native
|
|
||||||
assert stdenv.targetPlatform == stdenv.hostPlatform;
|
|
||||||
|
|
||||||
let
|
|
||||||
useLLVM = !(stdenv.targetPlatform.isx86
|
|
||||||
|| stdenv.targetPlatform.isPower
|
|
||||||
|| stdenv.targetPlatform.isSparc);
|
|
||||||
|
|
||||||
useNcurses6 = stdenv.hostPlatform.system == "x86_64-linux"
|
|
||||||
|| (with stdenv.hostPlatform; isPower64 && isLittleEndian);
|
|
||||||
|
|
||||||
ourNcurses = if useNcurses6 then ncurses6 else ncurses5;
|
|
||||||
|
|
||||||
libPath = lib.makeLibraryPath ([
|
|
||||||
ourNcurses gmp
|
|
||||||
] ++ lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
|
|
||||||
|
|
||||||
libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
|
|
||||||
+ "LD_LIBRARY_PATH";
|
|
||||||
|
|
||||||
glibcDynLinker = assert stdenv.isLinux;
|
|
||||||
if stdenv.hostPlatform.libc == "glibc" then
|
|
||||||
# Could be stdenv.cc.bintools.dynamicLinker, keeping as-is to avoid rebuild.
|
|
||||||
''"$(cat $NIX_CC/nix-support/dynamic-linker)"''
|
|
||||||
else
|
|
||||||
"${lib.getLib glibc}/lib/ld-linux*";
|
|
||||||
|
|
||||||
downloadsUrl = "https://downloads.haskell.org/ghc";
|
|
||||||
|
|
||||||
runtimeDeps = [
|
|
||||||
targetPackages.stdenv.cc
|
|
||||||
targetPackages.stdenv.cc.bintools
|
|
||||||
coreutils # for cat
|
|
||||||
]
|
|
||||||
++ lib.optionals (assert useLLVM -> !(llvmPackages == null); useLLVM) [
|
|
||||||
(lib.getBin llvmPackages.llvm)
|
|
||||||
]
|
|
||||||
# On darwin, we need unwrapped bintools as well (for otool)
|
|
||||||
++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
|
|
||||||
targetPackages.stdenv.cc.bintools.bintools
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
version = "8.6.5";
|
|
||||||
pname = "ghc-binary";
|
|
||||||
|
|
||||||
# https://downloads.haskell.org/~ghc/8.6.5/
|
|
||||||
src = fetchurl ({
|
|
||||||
i686-linux = {
|
|
||||||
# Don't use the Fedora27 build (as below) because there isn't one!
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
|
|
||||||
sha256 = "1p2h29qghql19ajk755xa0yxkn85slbds8m9n5196ris743vkp8w";
|
|
||||||
};
|
|
||||||
x86_64-linux = {
|
|
||||||
# This is the Fedora build because it links against ncurses6 where the
|
|
||||||
# deb9 one links against ncurses5, see here
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/85924 for a discussion
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-fedora27-linux.tar.xz";
|
|
||||||
sha256 = "18dlqm5d028fqh6ghzn7pgjspr5smw030jjzl3kq6q1kmwzbay6g";
|
|
||||||
};
|
|
||||||
x86_64-darwin = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
|
|
||||||
sha256 = "0s9188vhhgf23q3rjarwhbr524z6h2qga5xaaa2pma03sfqvvhfz";
|
|
||||||
};
|
|
||||||
powerpc64le-linux = {
|
|
||||||
url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-powerpc64le-fedora29-linux.tar.xz";
|
|
||||||
sha256 = "sha256-tWSsJdPVrCiqDyIKzpBt5DaXb3b6j951tCya584kWs4=";
|
|
||||||
};
|
|
||||||
}.${stdenv.hostPlatform.system}
|
|
||||||
or (throw "cannot bootstrap GHC on this platform"));
|
|
||||||
|
|
||||||
nativeBuildInputs = [ perl ];
|
|
||||||
|
|
||||||
# Cannot patchelf beforehand due to relative RPATHs that anticipate
|
|
||||||
# the final install location/
|
|
||||||
${libEnvVar} = libPath;
|
|
||||||
|
|
||||||
postUnpack =
|
|
||||||
# GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
|
|
||||||
# during linking
|
|
||||||
lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
# not enough room in the object files for the full path to libiconv :(
|
|
||||||
for exe in $(find . -type f -executable); do
|
|
||||||
isScript $exe && continue
|
|
||||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
|
||||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
|
||||||
done
|
|
||||||
'' +
|
|
||||||
|
|
||||||
# Some scripts used during the build need to have their shebangs patched
|
|
||||||
''
|
|
||||||
patchShebangs ghc-${version}/utils/
|
|
||||||
patchShebangs ghc-${version}/configure
|
|
||||||
test -d ghc-${version}/inplace/bin && \
|
|
||||||
patchShebangs ghc-${version}/inplace/bin
|
|
||||||
'' +
|
|
||||||
|
|
||||||
# We have to patch the GMP paths for the integer-gmp package.
|
|
||||||
''
|
|
||||||
find . -name integer-gmp.buildinfo \
|
|
||||||
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
find . -name base.buildinfo \
|
|
||||||
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
|
|
||||||
'' +
|
|
||||||
# Rename needed libraries and binaries, fix interpreter
|
|
||||||
lib.optionalString stdenv.isLinux ''
|
|
||||||
find . -type f -perm -0100 \
|
|
||||||
-exec patchelf \
|
|
||||||
--replace-needed libncurses${lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
|
|
||||||
${ # This isn't required for x86_64-linux where we use ncurses6
|
|
||||||
lib.optionalString (!useNcurses6) "--replace-needed libtinfo.so libtinfo.so.5"
|
|
||||||
} \
|
|
||||||
--interpreter ${glibcDynLinker} {} \;
|
|
||||||
|
|
||||||
sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
|
|
||||||
sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
|
|
||||||
'' +
|
|
||||||
# We're kludging a glibc bindist into working with non-glibc...
|
|
||||||
# Here we patch up the use of `__strdup` (part of glibc binary ABI)
|
|
||||||
# to instead use `strdup` since musl doesn't provide __strdup
|
|
||||||
# (`__strdup` is defined to be an alias of `strdup` anyway[1]).
|
|
||||||
# [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html
|
|
||||||
# Use objcopy magic to make the change:
|
|
||||||
lib.optionalString stdenv.hostPlatform.isMusl ''
|
|
||||||
find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \;
|
|
||||||
'';
|
|
||||||
|
|
||||||
configurePlatforms = [ ];
|
|
||||||
configureFlags = [
|
|
||||||
"--with-gmp-includes=${lib.getDev gmp}/include"
|
|
||||||
# Note `--with-gmp-libraries` does nothing for GHC bindists:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124
|
|
||||||
] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
|
|
||||||
++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
|
|
||||||
|
|
||||||
# No building is necessary, but calling make without flags ironically
|
|
||||||
# calls install-strip ...
|
|
||||||
dontBuild = true;
|
|
||||||
|
|
||||||
# Patch scripts to include runtime dependencies in $PATH.
|
|
||||||
postInstall = ''
|
|
||||||
for i in "$out/bin/"*; do
|
|
||||||
test ! -h "$i" || continue
|
|
||||||
isScript "$i" || continue
|
|
||||||
sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
# On Linux, use patchelf to modify the executables so that they can
|
|
||||||
# find editline/gmp.
|
|
||||||
postFixup = lib.optionalString stdenv.isLinux ''
|
|
||||||
for p in $(find "$out" -type f -executable); do
|
|
||||||
if isELF "$p"; then
|
|
||||||
echo "Patchelfing $p"
|
|
||||||
patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
# not enough room in the object files for the full path to libiconv :(
|
|
||||||
for exe in $(find "$out" -type f -executable); do
|
|
||||||
isScript $exe && continue
|
|
||||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
|
||||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
|
||||||
done
|
|
||||||
|
|
||||||
for file in $(find "$out" -name setup-config); do
|
|
||||||
substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
doInstallCheck = true;
|
|
||||||
installCheckPhase = ''
|
|
||||||
# Sanity check, can ghc create executables?
|
|
||||||
cd $TMP
|
|
||||||
mkdir test-ghc; cd test-ghc
|
|
||||||
cat > main.hs << EOF
|
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
|
||||||
module Main where
|
|
||||||
main = putStrLn \$([|"yes"|])
|
|
||||||
EOF
|
|
||||||
env -i $out/bin/ghc --make main.hs || exit 1
|
|
||||||
echo compilation ok
|
|
||||||
[ $(./main) == "yes" ]
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
targetPrefix = "";
|
|
||||||
enableShared = true;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = rec {
|
|
||||||
license = lib.licenses.bsd3;
|
|
||||||
platforms = [
|
|
||||||
"x86_64-linux"
|
|
||||||
"i686-linux"
|
|
||||||
"x86_64-darwin"
|
|
||||||
"powerpc64le-linux"
|
|
||||||
];
|
|
||||||
# build segfaults, use ghc8107Binary which has proper musl support instead
|
|
||||||
broken = stdenv.hostPlatform.isMusl;
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,391 +0,0 @@
|
||||||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
|
||||||
|
|
||||||
# build-tools
|
|
||||||
, bootPkgs
|
|
||||||
, autoconf, automake, coreutils, fetchurl, perl, python3, m4, sphinx, xattr
|
|
||||||
, autoSignDarwinBinariesHook
|
|
||||||
, bash
|
|
||||||
, fetchpatch
|
|
||||||
|
|
||||||
, libiconv ? null, ncurses
|
|
||||||
, glibcLocales ? null
|
|
||||||
|
|
||||||
, # GHC can be built with system libffi or a bundled one.
|
|
||||||
libffi ? null
|
|
||||||
|
|
||||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
|
||||||
|| stdenv.targetPlatform.isPower
|
|
||||||
|| stdenv.targetPlatform.isSparc)
|
|
||||||
, # LLVM is conceptually a run-time-only dependency, but for
|
|
||||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
|
||||||
# build-time dependency too.
|
|
||||||
buildTargetLlvmPackages, llvmPackages
|
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
|
||||||
# bignum backend instead of the faster but GPLed gmp backend.
|
|
||||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
|
|
||||||
&& lib.meta.availableOn stdenv.targetPlatform gmp)
|
|
||||||
, gmp
|
|
||||||
|
|
||||||
, # If enabled, use -fPIC when compiling static libs.
|
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
|
||||||
|
|
||||||
, enableProfiledLibs ? true
|
|
||||||
|
|
||||||
, # Whether to build dynamic libs for the standard library (on the target
|
|
||||||
# platform). Static libs are always built.
|
|
||||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
|
||||||
|
|
||||||
, # Whether to build terminfo.
|
|
||||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
|
||||||
|
|
||||||
, # What flavour to build. An empty string indicates no
|
|
||||||
# specific flavour and falls back to ghc default values.
|
|
||||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
|
||||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
|
||||||
|
|
||||||
, # Whether to build sphinx documentation.
|
|
||||||
enableDocs ? (
|
|
||||||
# Docs disabled if we are building on musl because it's a large task to keep
|
|
||||||
# all `sphinx` dependencies building in this environment.
|
|
||||||
!stdenv.buildPlatform.isMusl
|
|
||||||
)
|
|
||||||
|
|
||||||
, enableHaddockProgram ?
|
|
||||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
|
||||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
|
||||||
|
|
||||||
, # Whether to disable the large address space allocator
|
|
||||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
|
||||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
|
||||||
}:
|
|
||||||
|
|
||||||
assert !enableNativeBignum -> gmp != null;
|
|
||||||
|
|
||||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
|
||||||
# see note [HADDOCK_DOCS].
|
|
||||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
|
||||||
|
|
||||||
inherit (bootPkgs) ghc;
|
|
||||||
|
|
||||||
# TODO(@Ericson2314) Make unconditional
|
|
||||||
targetPrefix = lib.optionalString
|
|
||||||
(targetPlatform != hostPlatform)
|
|
||||||
"${targetPlatform.config}-";
|
|
||||||
|
|
||||||
buildMK = ''
|
|
||||||
BuildFlavour = ${ghcFlavour}
|
|
||||||
ifneq \"\$(BuildFlavour)\" \"\"
|
|
||||||
include mk/flavours/\$(BuildFlavour).mk
|
|
||||||
endif
|
|
||||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
|
||||||
BUILD_SPHINX_PDF = NO
|
|
||||||
'' +
|
|
||||||
# Note [HADDOCK_DOCS]:
|
|
||||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
|
||||||
# program is built (which we generally always want to have a complete GHC install)
|
|
||||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
|
||||||
# (which is impossible for cross-compilation); see:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
|
||||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
|
||||||
# program, so it can never generate haddocks for any packages.
|
|
||||||
# If this is solved in the future, we'd like to unconditionally
|
|
||||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
|
||||||
''
|
|
||||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
|
||||||
# Build haddocks for boot packages with hyperlinking
|
|
||||||
EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
|
|
||||||
|
|
||||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
|
||||||
BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
|
|
||||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
|
||||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
|
||||||
CrossCompilePrefix = ${targetPrefix}
|
|
||||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
|
||||||
BUILD_PROF_LIBS = NO
|
|
||||||
'' +
|
|
||||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
|
||||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
|
||||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
|
||||||
lib.optionalString enableRelocatedStaticLibs ''
|
|
||||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
EXTRA_CC_OPTS += -std=gnu99
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Splicer will pull out correct variations
|
|
||||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
|
||||||
++ [libffi]
|
|
||||||
++ lib.optional (!enableNativeBignum) gmp
|
|
||||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
|
||||||
|
|
||||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
|
||||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
|
||||||
toolsForTarget = [
|
|
||||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
|
||||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
|
||||||
|
|
||||||
targetCC = builtins.head toolsForTarget;
|
|
||||||
|
|
||||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
|
||||||
# derivation for certain tools depending on the platform.
|
|
||||||
bintoolsFor = {
|
|
||||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
|
||||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
|
||||||
# x86_64-darwin.
|
|
||||||
install_name_tool =
|
|
||||||
if stdenv.targetPlatform.isAarch64
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
# Same goes for strip.
|
|
||||||
strip =
|
|
||||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
|
||||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
|
||||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
|
||||||
# see #84670 and #49071 for more background.
|
|
||||||
useLdGold = targetPlatform.linker == "gold" ||
|
|
||||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
|
||||||
|
|
||||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
|
||||||
variantSuffix = lib.concatStrings [
|
|
||||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
|
||||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
|
||||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
|
||||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
|
||||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
|
||||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
|
||||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
|
||||||
version = "9.0.2";
|
|
||||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
|
||||||
sha256 = "140e42b96346322d1a39eb17602bcdc76e292028ad4a69286b230bab188a9197";
|
|
||||||
};
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
outputs = [ "out" "doc" ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# Fix docs build with sphinx >= 6.0
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/22766
|
|
||||||
(fetchpatch {
|
|
||||||
name = "ghc-docs-sphinx-6.0.patch";
|
|
||||||
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch";
|
|
||||||
sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv";
|
|
||||||
})
|
|
||||||
# Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129
|
|
||||||
./docs-sphinx-7.patch
|
|
||||||
# fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch";
|
|
||||||
sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk=";
|
|
||||||
extraPrefix = "utils/haddock/";
|
|
||||||
stripLen = 1;
|
|
||||||
})
|
|
||||||
|
|
||||||
# Add flag that fixes C++ exception handling; opt-in. Merged in 9.4 and 9.2.2.
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7423
|
|
||||||
(fetchpatch {
|
|
||||||
name = "ghc-9.0.2-fcompact-unwind.patch";
|
|
||||||
# Note that the test suite is not packaged.
|
|
||||||
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/c6132c782d974a7701e7f6447bdcd2bf6db4299a.patch?merge_request_iid=7423";
|
|
||||||
sha256 = "sha256-b4feGZIaKDj/UKjWTNY6/jH4s2iate0wAgMxG3rAbZI=";
|
|
||||||
})
|
|
||||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
|
||||||
# Prevent the paths module from emitting symbols that we don't use
|
|
||||||
# when building with separate outputs.
|
|
||||||
#
|
|
||||||
# These cause problems as they're not eliminated by GHC's dead code
|
|
||||||
# elimination on aarch64-darwin. (see
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
|
||||||
./Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = "patchShebangs .";
|
|
||||||
|
|
||||||
# GHC needs the locale configured during the Haddock phase.
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
|
|
||||||
# GHC is a bit confused on its cross terminology.
|
|
||||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
|
||||||
preConfigure = ''
|
|
||||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
|
||||||
export "''${env#TARGET_}=''${!env}"
|
|
||||||
done
|
|
||||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
|
||||||
# the *host* tools.
|
|
||||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
|
||||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
|
||||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
|
||||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
|
||||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
|
||||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
|
||||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
|
||||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
|
||||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
|
||||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
|
||||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
|
||||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
|
||||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
|
||||||
'' + lib.optionalString useLLVM ''
|
|
||||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
|
||||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
|
||||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
|
||||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
|
||||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
|
||||||
'' + ''
|
|
||||||
|
|
||||||
echo -n "${buildMK}" > mk/build.mk
|
|
||||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
|
||||||
'' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
|
|
||||||
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
|
|
||||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
||||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
|
||||||
'' + lib.optionalString targetPlatform.isMusl ''
|
|
||||||
echo "patching llvm-targets for musl targets..."
|
|
||||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
|
||||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
|
||||||
echo "(go go gadget sed)"
|
|
||||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
|
||||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
|
||||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
|
||||||
|
|
||||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
|
||||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
|
||||||
for x in configure aclocal.m4; do
|
|
||||||
substituteInPlace $x \
|
|
||||||
--replace '*-android*|*-gnueabi*)' \
|
|
||||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
|
||||||
configurePlatforms = [ "build" "host" ]
|
|
||||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
|
||||||
|
|
||||||
# `--with` flags for libraries needed for RTS linker
|
|
||||||
configureFlags = [
|
|
||||||
"--datadir=$doc/share/doc/ghc"
|
|
||||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
|
||||||
] ++ lib.optionals (libffi != null) [
|
|
||||||
"--with-system-libffi"
|
|
||||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
|
||||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
|
||||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
|
||||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
|
||||||
"--with-iconv-includes=${libiconv}/include"
|
|
||||||
"--with-iconv-libraries=${libiconv}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
|
||||||
"--enable-bootstrap-with-devel-snapshot"
|
|
||||||
] ++ lib.optionals useLdGold [
|
|
||||||
"CFLAGS=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
|
||||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
|
||||||
"--disable-large-address-space"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
|
||||||
dontAddExtraLibs = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
perl autoconf automake m4 python3
|
|
||||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
|
||||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
||||||
autoSignDarwinBinariesHook
|
|
||||||
] ++ lib.optionals enableDocs [
|
|
||||||
sphinx
|
|
||||||
] ++ lib.optionals stdenv.isDarwin [
|
|
||||||
# TODO(@sternenseemann): backport addition of XATTR env var like
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6447
|
|
||||||
xattr
|
|
||||||
];
|
|
||||||
|
|
||||||
# For building runtime libs
|
|
||||||
depsBuildTarget = toolsForTarget;
|
|
||||||
|
|
||||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
|
||||||
|
|
||||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
|
||||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
|
||||||
|
|
||||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
||||||
# that in turn causes GHCi to abort
|
|
||||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
|
||||||
|
|
||||||
checkTarget = "test";
|
|
||||||
|
|
||||||
hardeningDisable =
|
|
||||||
[ "format" ]
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
# big-parallel allows us to build with more than 2 cores on
|
|
||||||
# Hydra which already warrants a significant speedup
|
|
||||||
requiredSystemFeatures = [ "big-parallel" ];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
# Install the bash completion file.
|
|
||||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit bootPkgs targetPrefix;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
inherit enableShared;
|
|
||||||
|
|
||||||
# This is used by the haskell builder to query
|
|
||||||
# the presence of the haddock program.
|
|
||||||
hasHaddock = enableHaddockProgram;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
timeout = 24 * 3600;
|
|
||||||
inherit (ghc.meta) license platforms;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
|
||||||
dontStrip = true;
|
|
||||||
dontPatchELF = true;
|
|
||||||
noAuditTmpdir = true;
|
|
||||||
})
|
|
|
@ -1,439 +0,0 @@
|
||||||
{ lib, stdenv
|
|
||||||
, fetchurl, perl, gcc
|
|
||||||
, ncurses5
|
|
||||||
, ncurses6, gmp, libiconv, numactl, libffi
|
|
||||||
, llvmPackages
|
|
||||||
, coreutils
|
|
||||||
, targetPackages
|
|
||||||
|
|
||||||
# minimal = true; will remove files that aren't strictly necessary for
|
|
||||||
# regular builds and GHC bootstrapping.
|
|
||||||
# This is "useful" for staying within hydra's output limits for at least the
|
|
||||||
# aarch64-linux architecture.
|
|
||||||
, minimal ? false
|
|
||||||
}:
|
|
||||||
|
|
||||||
# Prebuilt only does native
|
|
||||||
assert stdenv.targetPlatform == stdenv.hostPlatform;
|
|
||||||
|
|
||||||
let
|
|
||||||
downloadsUrl = "https://downloads.haskell.org/ghc";
|
|
||||||
|
|
||||||
# Copy sha256 from https://downloads.haskell.org/~ghc/9.2.4/SHA256SUMS
|
|
||||||
version = "9.2.4";
|
|
||||||
|
|
||||||
# Information about available bindists that we use in the build.
|
|
||||||
#
|
|
||||||
# # Bindist library checking
|
|
||||||
#
|
|
||||||
# The field `archSpecificLibraries` also provides a way for us get notified
|
|
||||||
# early when the upstream bindist changes its dependencies (e.g. because a
|
|
||||||
# newer Debian version is used that uses a new `ncurses` version).
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# * You can find the `fileToCheckFor` of libraries by running `readelf -d`
|
|
||||||
# on the compiler binary (`exePathForLibraryCheck`).
|
|
||||||
# * To skip library checking for an architecture,
|
|
||||||
# set `exePathForLibraryCheck = null`.
|
|
||||||
# * To skip file checking for a specific arch specfic library,
|
|
||||||
# set `fileToCheckFor = null`.
|
|
||||||
ghcBinDists = {
|
|
||||||
# Binary distributions for the default libc (e.g. glibc, or libSystem on Darwin)
|
|
||||||
# nixpkgs uses for the respective system.
|
|
||||||
defaultLibc = {
|
|
||||||
i686-linux = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
|
|
||||||
sha256 = "5dc1eb9c65f01b1e5c5693af72af07a4e9e75c6920e620fd598daeefa804487a";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
# The i686-linux bindist provided by GHC HQ is currently built on Debian 9,
|
|
||||||
# which link it against `libtinfo.so.5` (ncurses 5).
|
|
||||||
# Other bindists are linked `libtinfo.so.6` (ncurses 6).
|
|
||||||
{ nixPackage = ncurses5; fileToCheckFor = "libtinfo.so.5"; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
x86_64-linux = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz";
|
|
||||||
sha256 = "a77a91a39d9b0167124b7e97648b2b52973ae0978cb259e0d44f0752a75037cb";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
aarch64-linux = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
|
|
||||||
sha256 = "fc7dbc6bae36ea5ac30b7e9a263b7e5be3b45b0eb3e893ad0bc2c950a61f14ec";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
|
||||||
{ nixPackage = numactl; fileToCheckFor = null; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
x86_64-darwin = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
|
|
||||||
sha256 = "f2e8366fd3754dd9388510792aba2d2abecb1c2f7f1e5555f6065c3c5e2ffec4";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = null; # we don't have a library check for darwin yet
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = libiconv; fileToCheckFor = null; }
|
|
||||||
];
|
|
||||||
isHadrian = true;
|
|
||||||
};
|
|
||||||
aarch64-darwin = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz";
|
|
||||||
sha256 = "8cf8408544a1a43adf1bbbb0dd6b074efadffc68bfa1a792947c52e825171224";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = null; # we don't have a library check for darwin yet
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = libiconv; fileToCheckFor = null; }
|
|
||||||
];
|
|
||||||
isHadrian = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
# Binary distributions for the musl libc for the respective system.
|
|
||||||
musl = {
|
|
||||||
x86_64-linux = {
|
|
||||||
variantSuffix = "-musl";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3.12-linux-gmp.tar.xz";
|
|
||||||
sha256 = "026348947d30a156b84de5d6afeaa48fdcb2795b47954cd8341db00d3263a481";
|
|
||||||
};
|
|
||||||
isStatic = true;
|
|
||||||
isHadrian = true;
|
|
||||||
# We can't check the RPATH for statically linked executable
|
|
||||||
exePathForLibraryCheck = null;
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp.override { withStatic = true; }; fileToCheckFor = null; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
distSetName = if stdenv.hostPlatform.isMusl then "musl" else "defaultLibc";
|
|
||||||
|
|
||||||
binDistUsed = ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}
|
|
||||||
or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')");
|
|
||||||
|
|
||||||
gmpUsed = (builtins.head (
|
|
||||||
builtins.filter (
|
|
||||||
drv: lib.hasPrefix "gmp" (drv.nixPackage.name or "")
|
|
||||||
) binDistUsed.archSpecificLibraries
|
|
||||||
)).nixPackage;
|
|
||||||
|
|
||||||
# GHC has other native backends (like PowerPC), but here only the ones
|
|
||||||
# we ship bindists for matter.
|
|
||||||
useLLVM = !(stdenv.targetPlatform.isx86
|
|
||||||
|| (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin));
|
|
||||||
|
|
||||||
libPath =
|
|
||||||
lib.makeLibraryPath (
|
|
||||||
# Add arch-specific libraries.
|
|
||||||
map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries
|
|
||||||
);
|
|
||||||
|
|
||||||
libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
|
|
||||||
+ "LD_LIBRARY_PATH";
|
|
||||||
|
|
||||||
runtimeDeps = [
|
|
||||||
targetPackages.stdenv.cc
|
|
||||||
targetPackages.stdenv.cc.bintools
|
|
||||||
coreutils # for cat
|
|
||||||
]
|
|
||||||
++ lib.optionals useLLVM [
|
|
||||||
(lib.getBin llvmPackages.llvm)
|
|
||||||
]
|
|
||||||
# On darwin, we need unwrapped bintools as well (for otool)
|
|
||||||
++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
|
|
||||||
targetPackages.stdenv.cc.bintools.bintools
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
inherit version;
|
|
||||||
pname = "ghc-binary${binDistUsed.variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl binDistUsed.src;
|
|
||||||
|
|
||||||
nativeBuildInputs = [ perl ];
|
|
||||||
|
|
||||||
# Set LD_LIBRARY_PATH or equivalent so that the programs running as part
|
|
||||||
# of the bindist installer can find the libraries they expect.
|
|
||||||
# Cannot patchelf beforehand due to relative RPATHs that anticipate
|
|
||||||
# the final install location.
|
|
||||||
${libEnvVar} = libPath;
|
|
||||||
|
|
||||||
postUnpack =
|
|
||||||
# Verify our assumptions of which `libtinfo.so` (ncurses) version is used,
|
|
||||||
# so that we know when ghc bindists upgrade that and we need to update the
|
|
||||||
# version used in `libPath`.
|
|
||||||
lib.optionalString
|
|
||||||
(binDistUsed.exePathForLibraryCheck != null)
|
|
||||||
# Note the `*` glob because some GHCs have a suffix when unpacked, e.g.
|
|
||||||
# the musl bindist has dir `ghc-VERSION-x86_64-unknown-linux/`.
|
|
||||||
# As a result, don't shell-quote this glob when splicing the string.
|
|
||||||
(let buildExeGlob = ''ghc-${version}*/"${binDistUsed.exePathForLibraryCheck}"''; in
|
|
||||||
lib.concatStringsSep "\n" [
|
|
||||||
(''
|
|
||||||
shopt -u nullglob
|
|
||||||
echo "Checking that ghc binary exists in bindist at ${buildExeGlob}"
|
|
||||||
if ! test -e ${buildExeGlob}; then
|
|
||||||
echo >&2 "GHC binary ${binDistUsed.exePathForLibraryCheck} could not be found in the bindist build directory (at ${buildExeGlob}) for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
|
||||||
fi
|
|
||||||
'')
|
|
||||||
(lib.concatMapStringsSep
|
|
||||||
"\n"
|
|
||||||
({ fileToCheckFor, nixPackage }:
|
|
||||||
lib.optionalString (fileToCheckFor != null) ''
|
|
||||||
echo "Checking bindist for ${fileToCheckFor} to ensure that is still used"
|
|
||||||
if ! readelf -d ${buildExeGlob} | grep "${fileToCheckFor}"; then
|
|
||||||
echo >&2 "File ${fileToCheckFor} could not be found in ${binDistUsed.exePathForLibraryCheck} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Checking that the nix package ${nixPackage} contains ${fileToCheckFor}"
|
|
||||||
if ! test -e "${lib.getLib nixPackage}/lib/${fileToCheckFor}"; then
|
|
||||||
echo >&2 "Nix package ${nixPackage} did not contain ${fileToCheckFor} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
|
||||||
fi
|
|
||||||
''
|
|
||||||
)
|
|
||||||
binDistUsed.archSpecificLibraries
|
|
||||||
)
|
|
||||||
])
|
|
||||||
# GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
|
|
||||||
# during linking
|
|
||||||
+ lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
# not enough room in the object files for the full path to libiconv :(
|
|
||||||
for exe in $(find . -type f -executable); do
|
|
||||||
isScript $exe && continue
|
|
||||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
|
||||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
|
||||||
done
|
|
||||||
'' +
|
|
||||||
|
|
||||||
# Some scripts used during the build need to have their shebangs patched
|
|
||||||
''
|
|
||||||
patchShebangs ghc-${version}/utils/
|
|
||||||
patchShebangs ghc-${version}/configure
|
|
||||||
test -d ghc-${version}/inplace/bin && \
|
|
||||||
patchShebangs ghc-${version}/inplace/bin
|
|
||||||
'' +
|
|
||||||
# We have to patch the GMP paths for the integer-gmp package.
|
|
||||||
''
|
|
||||||
find . -name ghc-bignum.buildinfo \
|
|
||||||
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${lib.getLib gmpUsed}/lib@" {} \;
|
|
||||||
|
|
||||||
# we need to modify the package db directly for hadrian bindists
|
|
||||||
find . -name 'ghc-bignum*.conf' \
|
|
||||||
-exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib gmpUsed}/lib' -i {} \;
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
# we need to modify the package db directly for hadrian bindists
|
|
||||||
# (all darwin bindists are hadrian-based for 9.2.2)
|
|
||||||
find . -name 'base*.conf' \
|
|
||||||
-exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib libiconv}/lib' -i {} \;
|
|
||||||
|
|
||||||
# To link RTS in the end we also need libffi now
|
|
||||||
find . -name 'rts*.conf' \
|
|
||||||
-exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib libffi}/lib' \
|
|
||||||
-e 's@/Library/Developer/.*/usr/include/ffi@${lib.getDev libffi}/include@' \
|
|
||||||
-i {} \;
|
|
||||||
'' +
|
|
||||||
# aarch64 does HAVE_NUMA so -lnuma requires it in library-dirs in rts/package.conf.in
|
|
||||||
# FFI_LIB_DIR is a good indication of places it must be needed.
|
|
||||||
lib.optionalString (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) ''
|
|
||||||
find . -name package.conf.in \
|
|
||||||
-exec sed -i "s@FFI_LIB_DIR@FFI_LIB_DIR ${numactl.out}/lib@g" {} \;
|
|
||||||
'' +
|
|
||||||
# Rename needed libraries and binaries, fix interpreter
|
|
||||||
lib.optionalString stdenv.isLinux ''
|
|
||||||
find . -type f -executable -exec patchelf \
|
|
||||||
--interpreter ${stdenv.cc.bintools.dynamicLinker} {} \;
|
|
||||||
'';
|
|
||||||
|
|
||||||
# fix for `configure: error: Your linker is affected by binutils #16177`
|
|
||||||
preConfigure = lib.optionalString
|
|
||||||
stdenv.targetPlatform.isAarch32
|
|
||||||
"LD=ld.gold";
|
|
||||||
|
|
||||||
configurePlatforms = [ ];
|
|
||||||
configureFlags = [
|
|
||||||
"--with-gmp-includes=${lib.getDev gmpUsed}/include"
|
|
||||||
# Note `--with-gmp-libraries` does nothing for GHC bindists:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124
|
|
||||||
] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
|
|
||||||
# From: https://github.com/NixOS/nixpkgs/pull/43369/commits
|
|
||||||
++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
|
|
||||||
|
|
||||||
# No building is necessary, but calling make without flags ironically
|
|
||||||
# calls install-strip ...
|
|
||||||
dontBuild = true;
|
|
||||||
|
|
||||||
# Patch scripts to include runtime dependencies in $PATH.
|
|
||||||
postInstall = ''
|
|
||||||
for i in "$out/bin/"*; do
|
|
||||||
test ! -h "$i" || continue
|
|
||||||
isScript "$i" || continue
|
|
||||||
sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Apparently necessary for the ghc Alpine (musl) bindist:
|
|
||||||
# When we strip, and then run the
|
|
||||||
# patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
|
|
||||||
# below, running ghc (e.g. during `installCheckPhase)` gives some apparently
|
|
||||||
# corrupted rpath or whatever makes the loader work on nonsensical strings:
|
|
||||||
# running install tests
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: : symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: ir6zf6c9f86pfx8sr30n2vjy-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: y/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: <20>: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: <20>?: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
|
|
||||||
# This is extremely bogus and should be investigated.
|
|
||||||
dontStrip = if stdenv.hostPlatform.isMusl then true else false; # `if` for explicitness
|
|
||||||
|
|
||||||
# On Linux, use patchelf to modify the executables so that they can
|
|
||||||
# find editline/gmp.
|
|
||||||
postFixup = lib.optionalString (stdenv.isLinux && !(binDistUsed.isStatic or false))
|
|
||||||
(if stdenv.hostPlatform.isAarch64 then
|
|
||||||
# Keep rpath as small as possible on aarch64 for patchelf#244. All Elfs
|
|
||||||
# are 2 directories deep from $out/lib, so pooling symlinks there makes
|
|
||||||
# a short rpath.
|
|
||||||
''
|
|
||||||
(cd $out/lib; ln -s ${ncurses6.out}/lib/libtinfo.so.6)
|
|
||||||
(cd $out/lib; ln -s ${lib.getLib gmpUsed}/lib/libgmp.so.10)
|
|
||||||
(cd $out/lib; ln -s ${numactl.out}/lib/libnuma.so.1)
|
|
||||||
for p in $(find "$out/lib" -type f -name "*\.so*"); do
|
|
||||||
(cd $out/lib; ln -s $p)
|
|
||||||
done
|
|
||||||
|
|
||||||
for p in $(find "$out/lib" -type f -executable); do
|
|
||||||
if isELF "$p"; then
|
|
||||||
echo "Patchelfing $p"
|
|
||||||
patchelf --set-rpath "\$ORIGIN:\$ORIGIN/../.." $p
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
''
|
|
||||||
else
|
|
||||||
''
|
|
||||||
for p in $(find "$out" -type f -executable); do
|
|
||||||
if isELF "$p"; then
|
|
||||||
echo "Patchelfing $p"
|
|
||||||
patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
'') + lib.optionalString stdenv.isDarwin ''
|
|
||||||
# not enough room in the object files for the full path to libiconv :(
|
|
||||||
for exe in $(find "$out" -type f -executable); do
|
|
||||||
isScript $exe && continue
|
|
||||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
|
||||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
|
||||||
done
|
|
||||||
|
|
||||||
for file in $(find "$out" -name setup-config); do
|
|
||||||
substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
|
|
||||||
done
|
|
||||||
'' +
|
|
||||||
lib.optionalString minimal ''
|
|
||||||
# Remove profiling files
|
|
||||||
find $out -type f -name '*.p_o' -delete
|
|
||||||
find $out -type f -name '*.p_hi' -delete
|
|
||||||
find $out -type f -name '*_p.a' -delete
|
|
||||||
# `-f` because e.g. musl bindist does not have this file.
|
|
||||||
rm -f $out/lib/ghc-*/bin/ghc-iserv-prof
|
|
||||||
# Hydra will redistribute this derivation, so we have to keep the docs for
|
|
||||||
# legal reasons (retaining the legal notices etc)
|
|
||||||
# As a last resort we could unpack the docs separately and symlink them in.
|
|
||||||
# They're in $out/share/{doc,man}.
|
|
||||||
''
|
|
||||||
# Recache package db which needs to happen for Hadrian bindists
|
|
||||||
# where we modify the package db before installing
|
|
||||||
+ ''
|
|
||||||
shopt -s nullglob
|
|
||||||
package_db=("$out"/lib/ghc-*/lib/package.conf.d "$out"/lib/ghc-*/package.conf.d)
|
|
||||||
"$out/bin/ghc-pkg" --package-db="$package_db" recache
|
|
||||||
'';
|
|
||||||
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
doInstallCheck = true;
|
|
||||||
installCheckPhase = ''
|
|
||||||
# Sanity check, can ghc create executables?
|
|
||||||
cd $TMP
|
|
||||||
mkdir test-ghc; cd test-ghc
|
|
||||||
cat > main.hs << EOF
|
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
|
||||||
module Main where
|
|
||||||
main = putStrLn \$([|"yes"|])
|
|
||||||
EOF
|
|
||||||
env -i $out/bin/ghc --make main.hs || exit 1
|
|
||||||
echo compilation ok
|
|
||||||
[ $(./main) == "yes" ]
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
targetPrefix = "";
|
|
||||||
enableShared = true;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
}
|
|
||||||
# We duplicate binDistUsed here since we have a sensible default even if no bindist is avaible,
|
|
||||||
# this makes sure that getting the `meta` attribute doesn't throw even on unsupported platforms.
|
|
||||||
// lib.optionalAttrs (ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}.isHadrian or false) {
|
|
||||||
# Normal GHC derivations expose the hadrian derivation used to build them
|
|
||||||
# here. In the case of bindists we just make sure that the attribute exists,
|
|
||||||
# as it is used for checking if a GHC derivation has been built with hadrian.
|
|
||||||
# The isHadrian mechanism will become obsolete with GHCs that use hadrian
|
|
||||||
# exclusively, i.e. 9.6 (and 9.4?).
|
|
||||||
hadrian = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = rec {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
license = lib.licenses.bsd3;
|
|
||||||
# HACK: since we can't encode the libc / abi in platforms, we need
|
|
||||||
# to make the platform list dependent on the evaluation platform
|
|
||||||
# in order to avoid eval errors with musl which supports less
|
|
||||||
# platforms than the default libcs (i. e. glibc / libSystem).
|
|
||||||
# This is done for the benefit of Hydra, so `packagePlatforms`
|
|
||||||
# won't return any platforms that would cause an evaluation
|
|
||||||
# failure for `pkgsMusl.haskell.compiler.ghc922Binary`, as
|
|
||||||
# long as the evaluator runs on a platform that supports
|
|
||||||
# `pkgsMusl`.
|
|
||||||
platforms = builtins.attrNames ghcBinDists.${distSetName};
|
|
||||||
maintainers = [ ];
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,387 +0,0 @@
|
||||||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
|
||||||
|
|
||||||
# build-tools
|
|
||||||
, bootPkgs
|
|
||||||
, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
|
|
||||||
, xattr, autoSignDarwinBinariesHook
|
|
||||||
, bash
|
|
||||||
|
|
||||||
, libiconv ? null, ncurses
|
|
||||||
, glibcLocales ? null
|
|
||||||
|
|
||||||
, # GHC can be built with system libffi or a bundled one.
|
|
||||||
libffi ? null
|
|
||||||
|
|
||||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
|
||||||
|| stdenv.targetPlatform.isPower
|
|
||||||
|| stdenv.targetPlatform.isSparc
|
|
||||||
|| stdenv.targetPlatform.isAarch64)
|
|
||||||
, # LLVM is conceptually a run-time-only dependency, but for
|
|
||||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
|
||||||
# build-time dependency too.
|
|
||||||
buildTargetLlvmPackages, llvmPackages
|
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
|
||||||
# bignum backend instead of the faster but GPLed gmp backend.
|
|
||||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
|
|
||||||
&& lib.meta.availableOn stdenv.targetPlatform gmp)
|
|
||||||
, gmp
|
|
||||||
|
|
||||||
, # If enabled, use -fPIC when compiling static libs.
|
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
|
||||||
|
|
||||||
, enableProfiledLibs ? true
|
|
||||||
|
|
||||||
, # Whether to build dynamic libs for the standard library (on the target
|
|
||||||
# platform). Static libs are always built.
|
|
||||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
|
||||||
|
|
||||||
, # Whether to build terminfo.
|
|
||||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
|
||||||
|
|
||||||
, # What flavour to build. An empty string indicates no
|
|
||||||
# specific flavour and falls back to ghc default values.
|
|
||||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
|
||||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
|
||||||
|
|
||||||
, # Whether to build sphinx documentation.
|
|
||||||
enableDocs ? (
|
|
||||||
# Docs disabled if we are building on musl because it's a large task to keep
|
|
||||||
# all `sphinx` dependencies building in this environment.
|
|
||||||
!stdenv.buildPlatform.isMusl
|
|
||||||
)
|
|
||||||
|
|
||||||
, enableHaddockProgram ?
|
|
||||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
|
||||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
|
||||||
|
|
||||||
, # Whether to disable the large address space allocator
|
|
||||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
|
||||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
|
||||||
}:
|
|
||||||
|
|
||||||
assert !enableNativeBignum -> gmp != null;
|
|
||||||
|
|
||||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
|
||||||
# see note [HADDOCK_DOCS].
|
|
||||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
|
||||||
|
|
||||||
inherit (bootPkgs) ghc;
|
|
||||||
|
|
||||||
# TODO(@Ericson2314) Make unconditional
|
|
||||||
targetPrefix = lib.optionalString
|
|
||||||
(targetPlatform != hostPlatform)
|
|
||||||
"${targetPlatform.config}-";
|
|
||||||
|
|
||||||
buildMK = ''
|
|
||||||
BuildFlavour = ${ghcFlavour}
|
|
||||||
ifneq \"\$(BuildFlavour)\" \"\"
|
|
||||||
include mk/flavours/\$(BuildFlavour).mk
|
|
||||||
endif
|
|
||||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
|
||||||
BUILD_SPHINX_PDF = NO
|
|
||||||
'' +
|
|
||||||
# Note [HADDOCK_DOCS]:
|
|
||||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
|
||||||
# program is built (which we generally always want to have a complete GHC install)
|
|
||||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
|
||||||
# (which is impossible for cross-compilation); see:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
|
||||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
|
||||||
# program, so it can never generate haddocks for any packages.
|
|
||||||
# If this is solved in the future, we'd like to unconditionally
|
|
||||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
|
||||||
''
|
|
||||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
|
||||||
# Build haddocks for boot packages with hyperlinking
|
|
||||||
EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
|
|
||||||
|
|
||||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
|
||||||
BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
|
|
||||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
|
||||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
|
||||||
CrossCompilePrefix = ${targetPrefix}
|
|
||||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
|
||||||
BUILD_PROF_LIBS = NO
|
|
||||||
'' +
|
|
||||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
|
||||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
|
||||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
|
||||||
lib.optionalString enableRelocatedStaticLibs ''
|
|
||||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
EXTRA_CC_OPTS += -std=gnu99
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Splicer will pull out correct variations
|
|
||||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
|
||||||
++ [libffi]
|
|
||||||
++ lib.optional (!enableNativeBignum) gmp
|
|
||||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
|
||||||
|
|
||||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
|
||||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
|
||||||
toolsForTarget = [
|
|
||||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
|
||||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
|
||||||
|
|
||||||
targetCC = builtins.head toolsForTarget;
|
|
||||||
|
|
||||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
|
||||||
# derivation for certain tools depending on the platform.
|
|
||||||
bintoolsFor = {
|
|
||||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
|
||||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
|
||||||
# x86_64-darwin.
|
|
||||||
install_name_tool =
|
|
||||||
if stdenv.targetPlatform.isAarch64
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
# Same goes for strip.
|
|
||||||
strip =
|
|
||||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
|
||||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
|
||||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
|
||||||
# see #84670 and #49071 for more background.
|
|
||||||
useLdGold = targetPlatform.linker == "gold" ||
|
|
||||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
|
||||||
|
|
||||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
|
||||||
variantSuffix = lib.concatStrings [
|
|
||||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
|
||||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
|
||||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
|
||||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
|
||||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
|
||||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
|
||||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
|
||||||
version = "9.2.5";
|
|
||||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
|
||||||
sha256 = "0606797d1b38e2d88ee2243f38ec6b9a1aa93e9b578e95f0de9a9c0a4144021c";
|
|
||||||
};
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
outputs = [ "out" "doc" ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# Fix docs build with sphinx >= 6.0
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/22766
|
|
||||||
(fetchpatch {
|
|
||||||
name = "ghc-docs-sphinx-6.0.patch";
|
|
||||||
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch";
|
|
||||||
sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv";
|
|
||||||
})
|
|
||||||
# Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129
|
|
||||||
./docs-sphinx-7.patch
|
|
||||||
# fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch";
|
|
||||||
sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk=";
|
|
||||||
extraPrefix = "utils/haddock/";
|
|
||||||
stripLen = 1;
|
|
||||||
})
|
|
||||||
# Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs
|
|
||||||
# Can be removed if the Cabal library included with ghc backports the linked fix
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://github.com/haskell/cabal/commit/6c796218c92f93c95e94d5ec2d077f6956f68e98.patch";
|
|
||||||
stripLen = 1;
|
|
||||||
extraPrefix = "libraries/Cabal/";
|
|
||||||
sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY=";
|
|
||||||
})
|
|
||||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
|
||||||
# Prevent the paths module from emitting symbols that we don't use
|
|
||||||
# when building with separate outputs.
|
|
||||||
#
|
|
||||||
# These cause problems as they're not eliminated by GHC's dead code
|
|
||||||
# elimination on aarch64-darwin. (see
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
|
||||||
./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = "patchShebangs .";
|
|
||||||
|
|
||||||
# GHC needs the locale configured during the Haddock phase.
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
|
|
||||||
# GHC is a bit confused on its cross terminology.
|
|
||||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
|
||||||
preConfigure = ''
|
|
||||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
|
||||||
export "''${env#TARGET_}=''${!env}"
|
|
||||||
done
|
|
||||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
|
||||||
# the *host* tools.
|
|
||||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
|
||||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
|
||||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
|
||||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
|
||||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
|
||||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
|
||||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
|
||||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
|
||||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
|
||||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
|
||||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
|
||||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
|
||||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
|
||||||
'' + lib.optionalString useLLVM ''
|
|
||||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
|
||||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
|
||||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
|
||||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
|
||||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
|
||||||
'' + ''
|
|
||||||
echo -n "${buildMK}" > mk/build.mk
|
|
||||||
'' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
|
|
||||||
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
|
|
||||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
||||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
|
|
||||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
|
||||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
|
||||||
'' + lib.optionalString targetPlatform.isMusl ''
|
|
||||||
echo "patching llvm-targets for musl targets..."
|
|
||||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
|
||||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
|
||||||
echo "(go go gadget sed)"
|
|
||||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
|
||||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
|
||||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
|
||||||
|
|
||||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
|
||||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
|
||||||
for x in configure aclocal.m4; do
|
|
||||||
substituteInPlace $x \
|
|
||||||
--replace '*-android*|*-gnueabi*)' \
|
|
||||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
|
||||||
configurePlatforms = [ "build" "host" ]
|
|
||||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
|
||||||
|
|
||||||
# `--with` flags for libraries needed for RTS linker
|
|
||||||
configureFlags = [
|
|
||||||
"--datadir=$doc/share/doc/ghc"
|
|
||||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
|
||||||
] ++ lib.optionals (libffi != null) [
|
|
||||||
"--with-system-libffi"
|
|
||||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
|
||||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
|
||||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
|
||||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
|
||||||
"--with-iconv-includes=${libiconv}/include"
|
|
||||||
"--with-iconv-libraries=${libiconv}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
|
||||||
"--enable-bootstrap-with-devel-snapshot"
|
|
||||||
] ++ lib.optionals useLdGold [
|
|
||||||
"CFLAGS=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
|
||||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
|
||||||
"--disable-large-address-space"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
|
||||||
dontAddExtraLibs = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
perl autoconf automake m4 python3
|
|
||||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
|
||||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
||||||
autoSignDarwinBinariesHook
|
|
||||||
] ++ lib.optionals enableDocs [
|
|
||||||
sphinx
|
|
||||||
];
|
|
||||||
|
|
||||||
# For building runtime libs
|
|
||||||
depsBuildTarget = toolsForTarget;
|
|
||||||
|
|
||||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
|
||||||
|
|
||||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
|
||||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
|
||||||
|
|
||||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
||||||
# that in turn causes GHCi to abort
|
|
||||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
|
||||||
|
|
||||||
checkTarget = "test";
|
|
||||||
|
|
||||||
hardeningDisable =
|
|
||||||
[ "format" ]
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
# big-parallel allows us to build with more than 2 cores on
|
|
||||||
# Hydra which already warrants a significant speedup
|
|
||||||
requiredSystemFeatures = [ "big-parallel" ];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
# Install the bash completion file.
|
|
||||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit bootPkgs targetPrefix;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
inherit enableShared;
|
|
||||||
|
|
||||||
# This is used by the haskell builder to query
|
|
||||||
# the presence of the haddock program.
|
|
||||||
hasHaddock = enableHaddockProgram;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
timeout = 24 * 3600;
|
|
||||||
inherit (ghc.meta) license platforms;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
|
||||||
dontStrip = true;
|
|
||||||
dontPatchELF = true;
|
|
||||||
noAuditTmpdir = true;
|
|
||||||
})
|
|
|
@ -1,387 +0,0 @@
|
||||||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
|
||||||
|
|
||||||
# build-tools
|
|
||||||
, bootPkgs
|
|
||||||
, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
|
|
||||||
, xattr, autoSignDarwinBinariesHook
|
|
||||||
, bash
|
|
||||||
|
|
||||||
, libiconv ? null, ncurses
|
|
||||||
, glibcLocales ? null
|
|
||||||
|
|
||||||
, # GHC can be built with system libffi or a bundled one.
|
|
||||||
libffi ? null
|
|
||||||
|
|
||||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
|
||||||
|| stdenv.targetPlatform.isPower
|
|
||||||
|| stdenv.targetPlatform.isSparc
|
|
||||||
|| stdenv.targetPlatform.isAarch64)
|
|
||||||
, # LLVM is conceptually a run-time-only dependency, but for
|
|
||||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
|
||||||
# build-time dependency too.
|
|
||||||
buildTargetLlvmPackages, llvmPackages
|
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
|
||||||
# bignum backend instead of the faster but GPLed gmp backend.
|
|
||||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
|
|
||||||
&& lib.meta.availableOn stdenv.targetPlatform gmp)
|
|
||||||
, gmp
|
|
||||||
|
|
||||||
, # If enabled, use -fPIC when compiling static libs.
|
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
|
||||||
|
|
||||||
, enableProfiledLibs ? true
|
|
||||||
|
|
||||||
, # Whether to build dynamic libs for the standard library (on the target
|
|
||||||
# platform). Static libs are always built.
|
|
||||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
|
||||||
|
|
||||||
, # Whether to build terminfo.
|
|
||||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
|
||||||
|
|
||||||
, # What flavour to build. An empty string indicates no
|
|
||||||
# specific flavour and falls back to ghc default values.
|
|
||||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
|
||||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
|
||||||
|
|
||||||
, # Whether to build sphinx documentation.
|
|
||||||
enableDocs ? (
|
|
||||||
# Docs disabled if we are building on musl because it's a large task to keep
|
|
||||||
# all `sphinx` dependencies building in this environment.
|
|
||||||
!stdenv.buildPlatform.isMusl
|
|
||||||
)
|
|
||||||
|
|
||||||
, enableHaddockProgram ?
|
|
||||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
|
||||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
|
||||||
|
|
||||||
, # Whether to disable the large address space allocator
|
|
||||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
|
||||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
|
||||||
}:
|
|
||||||
|
|
||||||
assert !enableNativeBignum -> gmp != null;
|
|
||||||
|
|
||||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
|
||||||
# see note [HADDOCK_DOCS].
|
|
||||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
|
||||||
|
|
||||||
inherit (bootPkgs) ghc;
|
|
||||||
|
|
||||||
# TODO(@Ericson2314) Make unconditional
|
|
||||||
targetPrefix = lib.optionalString
|
|
||||||
(targetPlatform != hostPlatform)
|
|
||||||
"${targetPlatform.config}-";
|
|
||||||
|
|
||||||
buildMK = ''
|
|
||||||
BuildFlavour = ${ghcFlavour}
|
|
||||||
ifneq \"\$(BuildFlavour)\" \"\"
|
|
||||||
include mk/flavours/\$(BuildFlavour).mk
|
|
||||||
endif
|
|
||||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
|
||||||
BUILD_SPHINX_PDF = NO
|
|
||||||
'' +
|
|
||||||
# Note [HADDOCK_DOCS]:
|
|
||||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
|
||||||
# program is built (which we generally always want to have a complete GHC install)
|
|
||||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
|
||||||
# (which is impossible for cross-compilation); see:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
|
||||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
|
||||||
# program, so it can never generate haddocks for any packages.
|
|
||||||
# If this is solved in the future, we'd like to unconditionally
|
|
||||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
|
||||||
''
|
|
||||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
|
||||||
# Build haddocks for boot packages with hyperlinking
|
|
||||||
EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
|
|
||||||
|
|
||||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
|
||||||
BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
|
|
||||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
|
||||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
|
||||||
CrossCompilePrefix = ${targetPrefix}
|
|
||||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
|
||||||
BUILD_PROF_LIBS = NO
|
|
||||||
'' +
|
|
||||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
|
||||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
|
||||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
|
||||||
lib.optionalString enableRelocatedStaticLibs ''
|
|
||||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
EXTRA_CC_OPTS += -std=gnu99
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Splicer will pull out correct variations
|
|
||||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
|
||||||
++ [libffi]
|
|
||||||
++ lib.optional (!enableNativeBignum) gmp
|
|
||||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
|
||||||
|
|
||||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
|
||||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
|
||||||
toolsForTarget = [
|
|
||||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
|
||||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
|
||||||
|
|
||||||
targetCC = builtins.head toolsForTarget;
|
|
||||||
|
|
||||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
|
||||||
# derivation for certain tools depending on the platform.
|
|
||||||
bintoolsFor = {
|
|
||||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
|
||||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
|
||||||
# x86_64-darwin.
|
|
||||||
install_name_tool =
|
|
||||||
if stdenv.targetPlatform.isAarch64
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
# Same goes for strip.
|
|
||||||
strip =
|
|
||||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
|
||||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
|
||||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
|
||||||
# see #84670 and #49071 for more background.
|
|
||||||
useLdGold = targetPlatform.linker == "gold" ||
|
|
||||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
|
||||||
|
|
||||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
|
||||||
variantSuffix = lib.concatStrings [
|
|
||||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
|
||||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
|
||||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
|
||||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
|
||||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
|
||||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
|
||||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
|
||||||
version = "9.2.6";
|
|
||||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
|
||||||
sha256 = "7a54cf0398ad488b4ed219e15d1d1e64c0b6876c43a0564550dd11f0540d7305";
|
|
||||||
};
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
outputs = [ "out" "doc" ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# Fix docs build with sphinx >= 6.0
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/22766
|
|
||||||
(fetchpatch {
|
|
||||||
name = "ghc-docs-sphinx-6.0.patch";
|
|
||||||
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch";
|
|
||||||
sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv";
|
|
||||||
})
|
|
||||||
# Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129
|
|
||||||
./docs-sphinx-7.patch
|
|
||||||
# fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch";
|
|
||||||
sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk=";
|
|
||||||
extraPrefix = "utils/haddock/";
|
|
||||||
stripLen = 1;
|
|
||||||
})
|
|
||||||
# Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs
|
|
||||||
# Can be removed if the Cabal library included with ghc backports the linked fix
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://github.com/haskell/cabal/commit/6c796218c92f93c95e94d5ec2d077f6956f68e98.patch";
|
|
||||||
stripLen = 1;
|
|
||||||
extraPrefix = "libraries/Cabal/";
|
|
||||||
sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY=";
|
|
||||||
})
|
|
||||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
|
||||||
# Prevent the paths module from emitting symbols that we don't use
|
|
||||||
# when building with separate outputs.
|
|
||||||
#
|
|
||||||
# These cause problems as they're not eliminated by GHC's dead code
|
|
||||||
# elimination on aarch64-darwin. (see
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
|
||||||
./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = "patchShebangs .";
|
|
||||||
|
|
||||||
# GHC needs the locale configured during the Haddock phase.
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
|
|
||||||
# GHC is a bit confused on its cross terminology.
|
|
||||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
|
||||||
preConfigure = ''
|
|
||||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
|
||||||
export "''${env#TARGET_}=''${!env}"
|
|
||||||
done
|
|
||||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
|
||||||
# the *host* tools.
|
|
||||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
|
||||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
|
||||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
|
||||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
|
||||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
|
||||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
|
||||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
|
||||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
|
||||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
|
||||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
|
||||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
|
||||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
|
||||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
|
||||||
'' + lib.optionalString useLLVM ''
|
|
||||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
|
||||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
|
||||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
|
||||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
|
||||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
|
||||||
'' + ''
|
|
||||||
echo -n "${buildMK}" > mk/build.mk
|
|
||||||
'' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
|
|
||||||
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
|
|
||||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
||||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
|
|
||||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
|
||||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
|
||||||
'' + lib.optionalString targetPlatform.isMusl ''
|
|
||||||
echo "patching llvm-targets for musl targets..."
|
|
||||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
|
||||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
|
||||||
echo "(go go gadget sed)"
|
|
||||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
|
||||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
|
||||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
|
||||||
|
|
||||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
|
||||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
|
||||||
for x in configure aclocal.m4; do
|
|
||||||
substituteInPlace $x \
|
|
||||||
--replace '*-android*|*-gnueabi*)' \
|
|
||||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
|
||||||
configurePlatforms = [ "build" "host" ]
|
|
||||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
|
||||||
|
|
||||||
# `--with` flags for libraries needed for RTS linker
|
|
||||||
configureFlags = [
|
|
||||||
"--datadir=$doc/share/doc/ghc"
|
|
||||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
|
||||||
] ++ lib.optionals (libffi != null) [
|
|
||||||
"--with-system-libffi"
|
|
||||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
|
||||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
|
||||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
|
||||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
|
||||||
"--with-iconv-includes=${libiconv}/include"
|
|
||||||
"--with-iconv-libraries=${libiconv}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
|
||||||
"--enable-bootstrap-with-devel-snapshot"
|
|
||||||
] ++ lib.optionals useLdGold [
|
|
||||||
"CFLAGS=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
|
||||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
|
||||||
"--disable-large-address-space"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
|
||||||
dontAddExtraLibs = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
perl autoconf automake m4 python3
|
|
||||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
|
||||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
||||||
autoSignDarwinBinariesHook
|
|
||||||
] ++ lib.optionals enableDocs [
|
|
||||||
sphinx
|
|
||||||
];
|
|
||||||
|
|
||||||
# For building runtime libs
|
|
||||||
depsBuildTarget = toolsForTarget;
|
|
||||||
|
|
||||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
|
||||||
|
|
||||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
|
||||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
|
||||||
|
|
||||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
||||||
# that in turn causes GHCi to abort
|
|
||||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
|
||||||
|
|
||||||
checkTarget = "test";
|
|
||||||
|
|
||||||
hardeningDisable =
|
|
||||||
[ "format" ]
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
# big-parallel allows us to build with more than 2 cores on
|
|
||||||
# Hydra which already warrants a significant speedup
|
|
||||||
requiredSystemFeatures = [ "big-parallel" ];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
# Install the bash completion file.
|
|
||||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit bootPkgs targetPrefix;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
inherit enableShared;
|
|
||||||
|
|
||||||
# This is used by the haskell builder to query
|
|
||||||
# the presence of the haddock program.
|
|
||||||
hasHaddock = enableHaddockProgram;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
timeout = 24 * 3600;
|
|
||||||
inherit (ghc.meta) license platforms;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
|
||||||
dontStrip = true;
|
|
||||||
dontPatchELF = true;
|
|
||||||
noAuditTmpdir = true;
|
|
||||||
})
|
|
|
@ -1,387 +0,0 @@
|
||||||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
|
||||||
|
|
||||||
# build-tools
|
|
||||||
, bootPkgs
|
|
||||||
, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
|
|
||||||
, xattr, autoSignDarwinBinariesHook
|
|
||||||
, bash
|
|
||||||
|
|
||||||
, libiconv ? null, ncurses
|
|
||||||
, glibcLocales ? null
|
|
||||||
|
|
||||||
, # GHC can be built with system libffi or a bundled one.
|
|
||||||
libffi ? null
|
|
||||||
|
|
||||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
|
||||||
|| stdenv.targetPlatform.isPower
|
|
||||||
|| stdenv.targetPlatform.isSparc
|
|
||||||
|| stdenv.targetPlatform.isAarch64)
|
|
||||||
, # LLVM is conceptually a run-time-only dependency, but for
|
|
||||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
|
||||||
# build-time dependency too.
|
|
||||||
buildTargetLlvmPackages, llvmPackages
|
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
|
||||||
# bignum backend instead of the faster but GPLed gmp backend.
|
|
||||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
|
|
||||||
&& lib.meta.availableOn stdenv.targetPlatform gmp)
|
|
||||||
, gmp
|
|
||||||
|
|
||||||
, # If enabled, use -fPIC when compiling static libs.
|
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
|
||||||
|
|
||||||
, enableProfiledLibs ? true
|
|
||||||
|
|
||||||
, # Whether to build dynamic libs for the standard library (on the target
|
|
||||||
# platform). Static libs are always built.
|
|
||||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
|
||||||
|
|
||||||
, # Whether to build terminfo.
|
|
||||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
|
||||||
|
|
||||||
, # What flavour to build. An empty string indicates no
|
|
||||||
# specific flavour and falls back to ghc default values.
|
|
||||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
|
||||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
|
||||||
|
|
||||||
, # Whether to build sphinx documentation.
|
|
||||||
enableDocs ? (
|
|
||||||
# Docs disabled if we are building on musl because it's a large task to keep
|
|
||||||
# all `sphinx` dependencies building in this environment.
|
|
||||||
!stdenv.buildPlatform.isMusl
|
|
||||||
)
|
|
||||||
|
|
||||||
, enableHaddockProgram ?
|
|
||||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
|
||||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
|
||||||
|
|
||||||
, # Whether to disable the large address space allocator
|
|
||||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
|
||||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
|
||||||
}:
|
|
||||||
|
|
||||||
assert !enableNativeBignum -> gmp != null;
|
|
||||||
|
|
||||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
|
||||||
# see note [HADDOCK_DOCS].
|
|
||||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
|
||||||
|
|
||||||
inherit (bootPkgs) ghc;
|
|
||||||
|
|
||||||
# TODO(@Ericson2314) Make unconditional
|
|
||||||
targetPrefix = lib.optionalString
|
|
||||||
(targetPlatform != hostPlatform)
|
|
||||||
"${targetPlatform.config}-";
|
|
||||||
|
|
||||||
buildMK = ''
|
|
||||||
BuildFlavour = ${ghcFlavour}
|
|
||||||
ifneq \"\$(BuildFlavour)\" \"\"
|
|
||||||
include mk/flavours/\$(BuildFlavour).mk
|
|
||||||
endif
|
|
||||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
|
||||||
BUILD_SPHINX_PDF = NO
|
|
||||||
'' +
|
|
||||||
# Note [HADDOCK_DOCS]:
|
|
||||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
|
||||||
# program is built (which we generally always want to have a complete GHC install)
|
|
||||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
|
||||||
# (which is impossible for cross-compilation); see:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
|
||||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
|
||||||
# program, so it can never generate haddocks for any packages.
|
|
||||||
# If this is solved in the future, we'd like to unconditionally
|
|
||||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
|
||||||
''
|
|
||||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
|
||||||
# Build haddocks for boot packages with hyperlinking
|
|
||||||
EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
|
|
||||||
|
|
||||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
|
||||||
BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
|
|
||||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
|
||||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
|
||||||
CrossCompilePrefix = ${targetPrefix}
|
|
||||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
|
||||||
BUILD_PROF_LIBS = NO
|
|
||||||
'' +
|
|
||||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
|
||||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
|
||||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
|
||||||
lib.optionalString enableRelocatedStaticLibs ''
|
|
||||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
EXTRA_CC_OPTS += -std=gnu99
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Splicer will pull out correct variations
|
|
||||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
|
||||||
++ [libffi]
|
|
||||||
++ lib.optional (!enableNativeBignum) gmp
|
|
||||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
|
||||||
|
|
||||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
|
||||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
|
||||||
toolsForTarget = [
|
|
||||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
|
||||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
|
||||||
|
|
||||||
targetCC = builtins.head toolsForTarget;
|
|
||||||
|
|
||||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
|
||||||
# derivation for certain tools depending on the platform.
|
|
||||||
bintoolsFor = {
|
|
||||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
|
||||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
|
||||||
# x86_64-darwin.
|
|
||||||
install_name_tool =
|
|
||||||
if stdenv.targetPlatform.isAarch64
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
# Same goes for strip.
|
|
||||||
strip =
|
|
||||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
|
||||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
|
||||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
|
||||||
# see #84670 and #49071 for more background.
|
|
||||||
useLdGold = targetPlatform.linker == "gold" ||
|
|
||||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
|
||||||
|
|
||||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
|
||||||
variantSuffix = lib.concatStrings [
|
|
||||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
|
||||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
|
||||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
|
||||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
|
||||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
|
||||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
|
||||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
|
||||||
version = "9.2.7";
|
|
||||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
|
||||||
sha256 = "a253567a17b734a4c0dd0ffa296d33c2a5b5a54a77df988806a2a1e1ca7e88b8";
|
|
||||||
};
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
outputs = [ "out" "doc" ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# Fix docs build with sphinx >= 6.0
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/22766
|
|
||||||
(fetchpatch {
|
|
||||||
name = "ghc-docs-sphinx-6.0.patch";
|
|
||||||
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch";
|
|
||||||
sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv";
|
|
||||||
})
|
|
||||||
# Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129
|
|
||||||
./docs-sphinx-7.patch
|
|
||||||
# fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch";
|
|
||||||
sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk=";
|
|
||||||
extraPrefix = "utils/haddock/";
|
|
||||||
stripLen = 1;
|
|
||||||
})
|
|
||||||
# Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs
|
|
||||||
# Can be removed if the Cabal library included with ghc backports the linked fix
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://github.com/haskell/cabal/commit/6c796218c92f93c95e94d5ec2d077f6956f68e98.patch";
|
|
||||||
stripLen = 1;
|
|
||||||
extraPrefix = "libraries/Cabal/";
|
|
||||||
sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY=";
|
|
||||||
})
|
|
||||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
|
||||||
# Prevent the paths module from emitting symbols that we don't use
|
|
||||||
# when building with separate outputs.
|
|
||||||
#
|
|
||||||
# These cause problems as they're not eliminated by GHC's dead code
|
|
||||||
# elimination on aarch64-darwin. (see
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
|
||||||
./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = "patchShebangs .";
|
|
||||||
|
|
||||||
# GHC needs the locale configured during the Haddock phase.
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
|
|
||||||
# GHC is a bit confused on its cross terminology.
|
|
||||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
|
||||||
preConfigure = ''
|
|
||||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
|
||||||
export "''${env#TARGET_}=''${!env}"
|
|
||||||
done
|
|
||||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
|
||||||
# the *host* tools.
|
|
||||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
|
||||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
|
||||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
|
||||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
|
||||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
|
||||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
|
||||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
|
||||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
|
||||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
|
||||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
|
||||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
|
||||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
|
||||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
|
||||||
'' + lib.optionalString useLLVM ''
|
|
||||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
|
||||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
|
||||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
|
||||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
|
||||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
|
||||||
'' + ''
|
|
||||||
echo -n "${buildMK}" > mk/build.mk
|
|
||||||
'' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
|
|
||||||
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
|
|
||||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
||||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
|
|
||||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
|
||||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
|
||||||
'' + lib.optionalString targetPlatform.isMusl ''
|
|
||||||
echo "patching llvm-targets for musl targets..."
|
|
||||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
|
||||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
|
||||||
echo "(go go gadget sed)"
|
|
||||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
|
||||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
|
||||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
|
||||||
|
|
||||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
|
||||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
|
||||||
for x in configure aclocal.m4; do
|
|
||||||
substituteInPlace $x \
|
|
||||||
--replace '*-android*|*-gnueabi*)' \
|
|
||||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
|
||||||
configurePlatforms = [ "build" "host" ]
|
|
||||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
|
||||||
|
|
||||||
# `--with` flags for libraries needed for RTS linker
|
|
||||||
configureFlags = [
|
|
||||||
"--datadir=$doc/share/doc/ghc"
|
|
||||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
|
||||||
] ++ lib.optionals (libffi != null) [
|
|
||||||
"--with-system-libffi"
|
|
||||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
|
||||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
|
||||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
|
||||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
|
||||||
"--with-iconv-includes=${libiconv}/include"
|
|
||||||
"--with-iconv-libraries=${libiconv}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
|
||||||
"--enable-bootstrap-with-devel-snapshot"
|
|
||||||
] ++ lib.optionals useLdGold [
|
|
||||||
"CFLAGS=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
|
||||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
|
||||||
"--disable-large-address-space"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
|
||||||
dontAddExtraLibs = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
perl autoconf automake m4 python3
|
|
||||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
|
||||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
||||||
autoSignDarwinBinariesHook
|
|
||||||
] ++ lib.optionals enableDocs [
|
|
||||||
sphinx
|
|
||||||
];
|
|
||||||
|
|
||||||
# For building runtime libs
|
|
||||||
depsBuildTarget = toolsForTarget;
|
|
||||||
|
|
||||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
|
||||||
|
|
||||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
|
||||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
|
||||||
|
|
||||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
||||||
# that in turn causes GHCi to abort
|
|
||||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
|
||||||
|
|
||||||
checkTarget = "test";
|
|
||||||
|
|
||||||
hardeningDisable =
|
|
||||||
[ "format" ]
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
# big-parallel allows us to build with more than 2 cores on
|
|
||||||
# Hydra which already warrants a significant speedup
|
|
||||||
requiredSystemFeatures = [ "big-parallel" ];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
# Install the bash completion file.
|
|
||||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit bootPkgs targetPrefix;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
inherit enableShared;
|
|
||||||
|
|
||||||
# This is used by the haskell builder to query
|
|
||||||
# the presence of the haddock program.
|
|
||||||
hasHaddock = enableHaddockProgram;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
timeout = 24 * 3600;
|
|
||||||
inherit (ghc.meta) license platforms;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
|
||||||
dontStrip = true;
|
|
||||||
dontPatchELF = true;
|
|
||||||
noAuditTmpdir = true;
|
|
||||||
})
|
|
|
@ -1,387 +0,0 @@
|
||||||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
|
||||||
|
|
||||||
# build-tools
|
|
||||||
, bootPkgs
|
|
||||||
, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
|
|
||||||
, xattr, autoSignDarwinBinariesHook
|
|
||||||
, bash
|
|
||||||
|
|
||||||
, libiconv ? null, ncurses
|
|
||||||
, glibcLocales ? null
|
|
||||||
|
|
||||||
, # GHC can be built with system libffi or a bundled one.
|
|
||||||
libffi ? null
|
|
||||||
|
|
||||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
|
||||||
|| stdenv.targetPlatform.isPower
|
|
||||||
|| stdenv.targetPlatform.isSparc
|
|
||||||
|| stdenv.targetPlatform.isAarch64)
|
|
||||||
, # LLVM is conceptually a run-time-only dependency, but for
|
|
||||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
|
||||||
# build-time dependency too.
|
|
||||||
buildTargetLlvmPackages, llvmPackages
|
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
|
||||||
# bignum backend instead of the faster but GPLed gmp backend.
|
|
||||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
|
|
||||||
&& lib.meta.availableOn stdenv.targetPlatform gmp)
|
|
||||||
, gmp
|
|
||||||
|
|
||||||
, # If enabled, use -fPIC when compiling static libs.
|
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
|
||||||
|
|
||||||
, enableProfiledLibs ? true
|
|
||||||
|
|
||||||
, # Whether to build dynamic libs for the standard library (on the target
|
|
||||||
# platform). Static libs are always built.
|
|
||||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
|
||||||
|
|
||||||
, # Whether to build terminfo.
|
|
||||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
|
||||||
|
|
||||||
, # What flavour to build. An empty string indicates no
|
|
||||||
# specific flavour and falls back to ghc default values.
|
|
||||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
|
||||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
|
||||||
|
|
||||||
, # Whether to build sphinx documentation.
|
|
||||||
enableDocs ? (
|
|
||||||
# Docs disabled if we are building on musl because it's a large task to keep
|
|
||||||
# all `sphinx` dependencies building in this environment.
|
|
||||||
!stdenv.buildPlatform.isMusl
|
|
||||||
)
|
|
||||||
|
|
||||||
, enableHaddockProgram ?
|
|
||||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
|
||||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
|
||||||
|
|
||||||
, # Whether to disable the large address space allocator
|
|
||||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
|
||||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
|
||||||
}:
|
|
||||||
|
|
||||||
assert !enableNativeBignum -> gmp != null;
|
|
||||||
|
|
||||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
|
||||||
# see note [HADDOCK_DOCS].
|
|
||||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
|
||||||
|
|
||||||
inherit (bootPkgs) ghc;
|
|
||||||
|
|
||||||
# TODO(@Ericson2314) Make unconditional
|
|
||||||
targetPrefix = lib.optionalString
|
|
||||||
(targetPlatform != hostPlatform)
|
|
||||||
"${targetPlatform.config}-";
|
|
||||||
|
|
||||||
buildMK = ''
|
|
||||||
BuildFlavour = ${ghcFlavour}
|
|
||||||
ifneq \"\$(BuildFlavour)\" \"\"
|
|
||||||
include mk/flavours/\$(BuildFlavour).mk
|
|
||||||
endif
|
|
||||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
|
||||||
BUILD_SPHINX_PDF = NO
|
|
||||||
'' +
|
|
||||||
# Note [HADDOCK_DOCS]:
|
|
||||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
|
||||||
# program is built (which we generally always want to have a complete GHC install)
|
|
||||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
|
||||||
# (which is impossible for cross-compilation); see:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
|
||||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
|
||||||
# program, so it can never generate haddocks for any packages.
|
|
||||||
# If this is solved in the future, we'd like to unconditionally
|
|
||||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
|
||||||
''
|
|
||||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
|
||||||
# Build haddocks for boot packages with hyperlinking
|
|
||||||
EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
|
|
||||||
|
|
||||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
|
||||||
BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
|
|
||||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
|
||||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
|
||||||
CrossCompilePrefix = ${targetPrefix}
|
|
||||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
|
||||||
BUILD_PROF_LIBS = NO
|
|
||||||
'' +
|
|
||||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
|
||||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
|
||||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
|
||||||
lib.optionalString enableRelocatedStaticLibs ''
|
|
||||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
EXTRA_CC_OPTS += -std=gnu99
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Splicer will pull out correct variations
|
|
||||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
|
||||||
++ [libffi]
|
|
||||||
++ lib.optional (!enableNativeBignum) gmp
|
|
||||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
|
||||||
|
|
||||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
|
||||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
|
||||||
toolsForTarget = [
|
|
||||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
|
||||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
|
||||||
|
|
||||||
targetCC = builtins.head toolsForTarget;
|
|
||||||
|
|
||||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
|
||||||
# derivation for certain tools depending on the platform.
|
|
||||||
bintoolsFor = {
|
|
||||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
|
||||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
|
||||||
# x86_64-darwin.
|
|
||||||
install_name_tool =
|
|
||||||
if stdenv.targetPlatform.isAarch64
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
# Same goes for strip.
|
|
||||||
strip =
|
|
||||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
|
||||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
|
||||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
|
||||||
# see #84670 and #49071 for more background.
|
|
||||||
useLdGold = targetPlatform.linker == "gold" ||
|
|
||||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
|
||||||
|
|
||||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
|
||||||
variantSuffix = lib.concatStrings [
|
|
||||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
|
||||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
|
||||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
|
||||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
|
||||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
|
||||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
|
||||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
|
||||||
version = "9.2.8";
|
|
||||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
|
||||||
sha256 = "sha256-XxPReGv0/RL0tF+qN6vttbs/NtXlj32lMH6L/oilZ6E=";
|
|
||||||
};
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
outputs = [ "out" "doc" ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# Fix docs build with sphinx >= 6.0
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/22766
|
|
||||||
(fetchpatch {
|
|
||||||
name = "ghc-docs-sphinx-6.0.patch";
|
|
||||||
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch";
|
|
||||||
sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv";
|
|
||||||
})
|
|
||||||
# Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129
|
|
||||||
./docs-sphinx-7.patch
|
|
||||||
# fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch";
|
|
||||||
sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk=";
|
|
||||||
extraPrefix = "utils/haddock/";
|
|
||||||
stripLen = 1;
|
|
||||||
})
|
|
||||||
# Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs
|
|
||||||
# Can be removed if the Cabal library included with ghc backports the linked fix
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://github.com/haskell/cabal/commit/6c796218c92f93c95e94d5ec2d077f6956f68e98.patch";
|
|
||||||
stripLen = 1;
|
|
||||||
extraPrefix = "libraries/Cabal/";
|
|
||||||
sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY=";
|
|
||||||
})
|
|
||||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
|
||||||
# Prevent the paths module from emitting symbols that we don't use
|
|
||||||
# when building with separate outputs.
|
|
||||||
#
|
|
||||||
# These cause problems as they're not eliminated by GHC's dead code
|
|
||||||
# elimination on aarch64-darwin. (see
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
|
||||||
./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = "patchShebangs .";
|
|
||||||
|
|
||||||
# GHC needs the locale configured during the Haddock phase.
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
|
|
||||||
# GHC is a bit confused on its cross terminology.
|
|
||||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
|
||||||
preConfigure = ''
|
|
||||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
|
||||||
export "''${env#TARGET_}=''${!env}"
|
|
||||||
done
|
|
||||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
|
||||||
# the *host* tools.
|
|
||||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
|
||||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
|
||||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
|
||||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
|
||||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
|
||||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
|
||||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
|
||||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
|
||||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
|
||||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
|
||||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
|
||||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
|
||||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
|
||||||
'' + lib.optionalString useLLVM ''
|
|
||||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
|
||||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
|
||||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
|
||||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
|
||||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
|
||||||
'' + ''
|
|
||||||
echo -n "${buildMK}" > mk/build.mk
|
|
||||||
'' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
|
|
||||||
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
|
|
||||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
||||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
|
|
||||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
|
||||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
|
||||||
'' + lib.optionalString targetPlatform.isMusl ''
|
|
||||||
echo "patching llvm-targets for musl targets..."
|
|
||||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
|
||||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
|
||||||
echo "(go go gadget sed)"
|
|
||||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
|
||||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
|
||||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
|
||||||
|
|
||||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
|
||||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
|
||||||
for x in configure aclocal.m4; do
|
|
||||||
substituteInPlace $x \
|
|
||||||
--replace '*-android*|*-gnueabi*)' \
|
|
||||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
|
||||||
configurePlatforms = [ "build" "host" ]
|
|
||||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
|
||||||
|
|
||||||
# `--with` flags for libraries needed for RTS linker
|
|
||||||
configureFlags = [
|
|
||||||
"--datadir=$doc/share/doc/ghc"
|
|
||||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
|
||||||
] ++ lib.optionals (libffi != null) [
|
|
||||||
"--with-system-libffi"
|
|
||||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
|
||||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
|
||||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
|
||||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
|
||||||
"--with-iconv-includes=${libiconv}/include"
|
|
||||||
"--with-iconv-libraries=${libiconv}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
|
||||||
"--enable-bootstrap-with-devel-snapshot"
|
|
||||||
] ++ lib.optionals useLdGold [
|
|
||||||
"CFLAGS=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
|
||||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
|
||||||
"--disable-large-address-space"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
|
||||||
dontAddExtraLibs = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
perl autoconf automake m4 python3
|
|
||||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
|
||||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
||||||
autoSignDarwinBinariesHook
|
|
||||||
] ++ lib.optionals enableDocs [
|
|
||||||
sphinx
|
|
||||||
];
|
|
||||||
|
|
||||||
# For building runtime libs
|
|
||||||
depsBuildTarget = toolsForTarget;
|
|
||||||
|
|
||||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
|
||||||
|
|
||||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
|
||||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
|
||||||
|
|
||||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
||||||
# that in turn causes GHCi to abort
|
|
||||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
|
||||||
|
|
||||||
checkTarget = "test";
|
|
||||||
|
|
||||||
hardeningDisable =
|
|
||||||
[ "format" ]
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
# big-parallel allows us to build with more than 2 cores on
|
|
||||||
# Hydra which already warrants a significant speedup
|
|
||||||
requiredSystemFeatures = [ "big-parallel" ];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
# Install the bash completion file.
|
|
||||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit bootPkgs targetPrefix;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
inherit enableShared;
|
|
||||||
|
|
||||||
# This is used by the haskell builder to query
|
|
||||||
# the presence of the haddock program.
|
|
||||||
hasHaddock = enableHaddockProgram;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
timeout = 24 * 3600;
|
|
||||||
inherit (ghc.meta) license platforms;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
|
||||||
dontStrip = true;
|
|
||||||
dontPatchELF = true;
|
|
||||||
noAuditTmpdir = true;
|
|
||||||
})
|
|
|
@ -1,394 +0,0 @@
|
||||||
# DO NOT port this expression to hadrian. It is not possible to build a GHC
|
|
||||||
# cross compiler with 9.4.* and hadrian.
|
|
||||||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
|
||||||
|
|
||||||
# build-tools
|
|
||||||
, bootPkgs
|
|
||||||
, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
|
|
||||||
, xattr, autoSignDarwinBinariesHook
|
|
||||||
, bash
|
|
||||||
|
|
||||||
, libiconv ? null, ncurses
|
|
||||||
, glibcLocales ? null
|
|
||||||
|
|
||||||
, # GHC can be built with system libffi or a bundled one.
|
|
||||||
libffi ? null
|
|
||||||
|
|
||||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
|
||||||
|| stdenv.targetPlatform.isPower
|
|
||||||
|| stdenv.targetPlatform.isSparc
|
|
||||||
|| stdenv.targetPlatform.isAarch64)
|
|
||||||
, # LLVM is conceptually a run-time-only dependency, but for
|
|
||||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
|
||||||
# build-time dependency too.
|
|
||||||
buildTargetLlvmPackages, llvmPackages
|
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
|
||||||
# bignum backend instead of the faster but GPLed gmp backend.
|
|
||||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
|
|
||||||
&& lib.meta.availableOn stdenv.targetPlatform gmp)
|
|
||||||
, gmp
|
|
||||||
|
|
||||||
, # If enabled, use -fPIC when compiling static libs.
|
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
|
||||||
|
|
||||||
, enableProfiledLibs ? true
|
|
||||||
|
|
||||||
, # Whether to build dynamic libs for the standard library (on the target
|
|
||||||
# platform). Static libs are always built.
|
|
||||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
|
||||||
|
|
||||||
, # Whether to build terminfo.
|
|
||||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
|
||||||
|
|
||||||
, # What flavour to build. An empty string indicates no
|
|
||||||
# specific flavour and falls back to ghc default values.
|
|
||||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
|
||||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
|
||||||
|
|
||||||
, # Whether to build sphinx documentation.
|
|
||||||
enableDocs ? (
|
|
||||||
# Docs disabled if we are building on musl because it's a large task to keep
|
|
||||||
# all `sphinx` dependencies building in this environment.
|
|
||||||
!stdenv.buildPlatform.isMusl
|
|
||||||
)
|
|
||||||
|
|
||||||
, enableHaddockProgram ?
|
|
||||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
|
||||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
|
||||||
|
|
||||||
, # Whether to disable the large address space allocator
|
|
||||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
|
||||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
|
||||||
}:
|
|
||||||
|
|
||||||
assert !enableNativeBignum -> gmp != null;
|
|
||||||
|
|
||||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
|
||||||
# see note [HADDOCK_DOCS].
|
|
||||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
|
||||||
|
|
||||||
inherit (bootPkgs) ghc;
|
|
||||||
|
|
||||||
# TODO(@Ericson2314) Make unconditional
|
|
||||||
targetPrefix = lib.optionalString
|
|
||||||
(targetPlatform != hostPlatform)
|
|
||||||
"${targetPlatform.config}-";
|
|
||||||
|
|
||||||
buildMK = ''
|
|
||||||
BuildFlavour = ${ghcFlavour}
|
|
||||||
ifneq \"\$(BuildFlavour)\" \"\"
|
|
||||||
include mk/flavours/\$(BuildFlavour).mk
|
|
||||||
endif
|
|
||||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
|
||||||
BUILD_SPHINX_PDF = NO
|
|
||||||
'' +
|
|
||||||
# Note [HADDOCK_DOCS]:
|
|
||||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
|
||||||
# program is built (which we generally always want to have a complete GHC install)
|
|
||||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
|
||||||
# (which is impossible for cross-compilation); see:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
|
||||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
|
||||||
# program, so it can never generate haddocks for any packages.
|
|
||||||
# If this is solved in the future, we'd like to unconditionally
|
|
||||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
|
||||||
''
|
|
||||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
|
||||||
# Build haddocks for boot packages with hyperlinking
|
|
||||||
EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
|
|
||||||
|
|
||||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
|
||||||
BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
|
|
||||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
|
||||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
|
||||||
CrossCompilePrefix = ${targetPrefix}
|
|
||||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
|
||||||
BUILD_PROF_LIBS = NO
|
|
||||||
'' +
|
|
||||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
|
||||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
|
||||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
|
||||||
lib.optionalString enableRelocatedStaticLibs ''
|
|
||||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
EXTRA_CC_OPTS += -std=gnu99
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Splicer will pull out correct variations
|
|
||||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
|
||||||
++ [libffi]
|
|
||||||
++ lib.optional (!enableNativeBignum) gmp
|
|
||||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
|
||||||
|
|
||||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
|
||||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
|
||||||
toolsForTarget = [
|
|
||||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
|
||||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
|
||||||
|
|
||||||
targetCC = builtins.head toolsForTarget;
|
|
||||||
|
|
||||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
|
||||||
# derivation for certain tools depending on the platform.
|
|
||||||
bintoolsFor = {
|
|
||||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
|
||||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
|
||||||
# x86_64-darwin.
|
|
||||||
install_name_tool =
|
|
||||||
if stdenv.targetPlatform.isAarch64
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
# Same goes for strip.
|
|
||||||
strip =
|
|
||||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
|
||||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
|
||||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
|
||||||
# see #84670 and #49071 for more background.
|
|
||||||
useLdGold = targetPlatform.linker == "gold" ||
|
|
||||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
|
||||||
|
|
||||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
|
||||||
variantSuffix = lib.concatStrings [
|
|
||||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
|
||||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
|
||||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
|
||||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
|
||||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
|
||||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
|
||||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
|
||||||
version = "9.4.5";
|
|
||||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
|
||||||
sha256 = "6256cf9caf6d6dc7b611dcfbb247df2d528e85aa39d22a698e870e5a590e8601";
|
|
||||||
};
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
outputs = [ "out" "doc" ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs
|
|
||||||
# Can be removed if the Cabal library included with ghc backports the linked fix
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://github.com/haskell/cabal/commit/6c796218c92f93c95e94d5ec2d077f6956f68e98.patch";
|
|
||||||
stripLen = 1;
|
|
||||||
extraPrefix = "libraries/Cabal/";
|
|
||||||
sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY=";
|
|
||||||
})
|
|
||||||
|
|
||||||
# Fix docs build with sphinx >= 6.0
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/22766
|
|
||||||
(fetchpatch {
|
|
||||||
name = "ghc-docs-sphinx-6.0.patch";
|
|
||||||
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch";
|
|
||||||
sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv";
|
|
||||||
})
|
|
||||||
|
|
||||||
# Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129
|
|
||||||
./docs-sphinx-7.patch
|
|
||||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
|
||||||
# Prevent the paths module from emitting symbols that we don't use
|
|
||||||
# when building with separate outputs.
|
|
||||||
#
|
|
||||||
# These cause problems as they're not eliminated by GHC's dead code
|
|
||||||
# elimination on aarch64-darwin. (see
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
|
||||||
./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = "patchShebangs .";
|
|
||||||
|
|
||||||
# GHC needs the locale configured during the Haddock phase.
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
|
|
||||||
# GHC is a bit confused on its cross terminology.
|
|
||||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
|
||||||
preConfigure = ''
|
|
||||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
|
||||||
export "''${env#TARGET_}=''${!env}"
|
|
||||||
done
|
|
||||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
|
||||||
# the *host* tools.
|
|
||||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
|
||||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
|
||||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
|
||||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
|
||||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
|
||||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
|
||||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
|
||||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
|
||||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
|
||||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
|
||||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
|
||||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
|
||||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
|
||||||
'' + lib.optionalString useLLVM ''
|
|
||||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
|
||||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
|
||||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
|
||||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
|
||||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
|
||||||
'' + ''
|
|
||||||
|
|
||||||
echo -n "${buildMK}" > mk/build.mk
|
|
||||||
|
|
||||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
|
||||||
'' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
|
|
||||||
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
|
|
||||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
||||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
|
|
||||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
|
||||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
|
||||||
'' + lib.optionalString targetPlatform.isMusl ''
|
|
||||||
echo "patching llvm-targets for musl targets..."
|
|
||||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
|
||||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
|
||||||
echo "(go go gadget sed)"
|
|
||||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
|
||||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
|
||||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
|
||||||
|
|
||||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
|
||||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
|
||||||
for x in configure aclocal.m4; do
|
|
||||||
substituteInPlace $x \
|
|
||||||
--replace '*-android*|*-gnueabi*)' \
|
|
||||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
|
||||||
done
|
|
||||||
''
|
|
||||||
# HACK: allow bootstrapping with GHC 8.10 which works fine, as we don't have
|
|
||||||
# binary 9.0 packaged. Bootstrapping with 9.2 is broken without hadrian.
|
|
||||||
+ ''
|
|
||||||
substituteInPlace configure --replace \
|
|
||||||
'MinBootGhcVersion="9.0"' \
|
|
||||||
'MinBootGhcVersion="8.10"'
|
|
||||||
'';
|
|
||||||
|
|
||||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
|
||||||
configurePlatforms = [ "build" "host" ]
|
|
||||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
|
||||||
|
|
||||||
# `--with` flags for libraries needed for RTS linker
|
|
||||||
configureFlags = [
|
|
||||||
"--datadir=$doc/share/doc/ghc"
|
|
||||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
|
||||||
] ++ lib.optionals (libffi != null) [
|
|
||||||
"--with-system-libffi"
|
|
||||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
|
||||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
|
||||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
|
||||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
|
||||||
"--with-iconv-includes=${libiconv}/include"
|
|
||||||
"--with-iconv-libraries=${libiconv}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
|
||||||
"--enable-bootstrap-with-devel-snapshot"
|
|
||||||
] ++ lib.optionals useLdGold [
|
|
||||||
"CFLAGS=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
|
||||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
|
||||||
"--disable-large-address-space"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
|
||||||
dontAddExtraLibs = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
perl autoconf automake m4 python3
|
|
||||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
|
||||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
||||||
autoSignDarwinBinariesHook
|
|
||||||
] ++ lib.optionals enableDocs [
|
|
||||||
sphinx
|
|
||||||
];
|
|
||||||
|
|
||||||
# For building runtime libs
|
|
||||||
depsBuildTarget = toolsForTarget;
|
|
||||||
|
|
||||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
|
||||||
|
|
||||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
|
||||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
|
||||||
|
|
||||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
||||||
# that in turn causes GHCi to abort
|
|
||||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
|
||||||
|
|
||||||
checkTarget = "test";
|
|
||||||
|
|
||||||
hardeningDisable =
|
|
||||||
[ "format" ]
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
# big-parallel allows us to build with more than 2 cores on
|
|
||||||
# Hydra which already warrants a significant speedup
|
|
||||||
requiredSystemFeatures = [ "big-parallel" ];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
# Install the bash completion file.
|
|
||||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit bootPkgs targetPrefix;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
inherit enableShared;
|
|
||||||
|
|
||||||
# This is used by the haskell builder to query
|
|
||||||
# the presence of the haddock program.
|
|
||||||
hasHaddock = enableHaddockProgram;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
timeout = 24 * 3600;
|
|
||||||
inherit (ghc.meta) license platforms;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
|
||||||
dontStrip = true;
|
|
||||||
dontPatchELF = true;
|
|
||||||
noAuditTmpdir = true;
|
|
||||||
})
|
|
|
@ -1,15 +0,0 @@
|
||||||
Make sure that the appropriate feature flags are set when
|
|
||||||
Rts.h is included, so that clockid_t is defined.
|
|
||||||
|
|
||||||
diff --git a/cbits/is-valid-utf8.c b/cbits/is-valid-utf8.c
|
|
||||||
index 01b3b41..c69596a 100644
|
|
||||||
--- a/libraries/bytestring/cbits/is-valid-utf8.c
|
|
||||||
+++ b/libraries/bytestring/cbits/is-valid-utf8.c
|
|
||||||
@@ -29,6 +29,7 @@ SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
#pragma GCC push_options
|
|
||||||
#pragma GCC optimize("-O2")
|
|
||||||
+#include "rts/PosixSource.h"
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
|
@ -1,390 +0,0 @@
|
||||||
# DO NOT port this expression to hadrian. It is not possible to build a GHC
|
|
||||||
# cross compiler with 9.4.* and hadrian.
|
|
||||||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
|
||||||
|
|
||||||
# build-tools
|
|
||||||
, bootPkgs
|
|
||||||
, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
|
|
||||||
, xattr, autoSignDarwinBinariesHook
|
|
||||||
, bash
|
|
||||||
|
|
||||||
, libiconv ? null, ncurses
|
|
||||||
, glibcLocales ? null
|
|
||||||
|
|
||||||
, # GHC can be built with system libffi or a bundled one.
|
|
||||||
libffi ? null
|
|
||||||
|
|
||||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
|
||||||
|| stdenv.targetPlatform.isPower
|
|
||||||
|| stdenv.targetPlatform.isSparc
|
|
||||||
|| stdenv.targetPlatform.isAarch64)
|
|
||||||
, # LLVM is conceptually a run-time-only dependency, but for
|
|
||||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
|
||||||
# build-time dependency too.
|
|
||||||
buildTargetLlvmPackages, llvmPackages
|
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
|
||||||
# bignum backend instead of the faster but GPLed gmp backend.
|
|
||||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
|
|
||||||
&& lib.meta.availableOn stdenv.targetPlatform gmp)
|
|
||||||
, gmp
|
|
||||||
|
|
||||||
, # If enabled, use -fPIC when compiling static libs.
|
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
|
||||||
|
|
||||||
, enableProfiledLibs ? true
|
|
||||||
|
|
||||||
, # Whether to build dynamic libs for the standard library (on the target
|
|
||||||
# platform). Static libs are always built.
|
|
||||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
|
||||||
|
|
||||||
, # Whether to build terminfo.
|
|
||||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
|
||||||
|
|
||||||
, # What flavour to build. An empty string indicates no
|
|
||||||
# specific flavour and falls back to ghc default values.
|
|
||||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
|
||||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
|
||||||
|
|
||||||
, # Whether to build sphinx documentation.
|
|
||||||
enableDocs ? (
|
|
||||||
# Docs disabled if we are building on musl because it's a large task to keep
|
|
||||||
# all `sphinx` dependencies building in this environment.
|
|
||||||
!stdenv.buildPlatform.isMusl
|
|
||||||
)
|
|
||||||
|
|
||||||
, enableHaddockProgram ?
|
|
||||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
|
||||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
|
||||||
|
|
||||||
, # Whether to disable the large address space allocator
|
|
||||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
|
||||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
|
||||||
}:
|
|
||||||
|
|
||||||
assert !enableNativeBignum -> gmp != null;
|
|
||||||
|
|
||||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
|
||||||
# see note [HADDOCK_DOCS].
|
|
||||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
|
||||||
|
|
||||||
inherit (bootPkgs) ghc;
|
|
||||||
|
|
||||||
# TODO(@Ericson2314) Make unconditional
|
|
||||||
targetPrefix = lib.optionalString
|
|
||||||
(targetPlatform != hostPlatform)
|
|
||||||
"${targetPlatform.config}-";
|
|
||||||
|
|
||||||
buildMK = ''
|
|
||||||
BuildFlavour = ${ghcFlavour}
|
|
||||||
ifneq \"\$(BuildFlavour)\" \"\"
|
|
||||||
include mk/flavours/\$(BuildFlavour).mk
|
|
||||||
endif
|
|
||||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
|
||||||
BUILD_SPHINX_PDF = NO
|
|
||||||
'' +
|
|
||||||
# Note [HADDOCK_DOCS]:
|
|
||||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
|
||||||
# program is built (which we generally always want to have a complete GHC install)
|
|
||||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
|
||||||
# (which is impossible for cross-compilation); see:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
|
||||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
|
||||||
# program, so it can never generate haddocks for any packages.
|
|
||||||
# If this is solved in the future, we'd like to unconditionally
|
|
||||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
|
||||||
''
|
|
||||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
|
||||||
# Build haddocks for boot packages with hyperlinking
|
|
||||||
EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
|
|
||||||
|
|
||||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
|
||||||
BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
|
|
||||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
|
||||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
|
||||||
CrossCompilePrefix = ${targetPrefix}
|
|
||||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
|
||||||
BUILD_PROF_LIBS = NO
|
|
||||||
'' +
|
|
||||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
|
||||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
|
||||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
|
||||||
lib.optionalString enableRelocatedStaticLibs ''
|
|
||||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
EXTRA_CC_OPTS += -std=gnu99
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Splicer will pull out correct variations
|
|
||||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
|
||||||
++ [libffi]
|
|
||||||
++ lib.optional (!enableNativeBignum) gmp
|
|
||||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
|
||||||
|
|
||||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
|
||||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
|
||||||
toolsForTarget = [
|
|
||||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
|
||||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
|
||||||
|
|
||||||
targetCC = builtins.head toolsForTarget;
|
|
||||||
|
|
||||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
|
||||||
# derivation for certain tools depending on the platform.
|
|
||||||
bintoolsFor = {
|
|
||||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
|
||||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
|
||||||
# x86_64-darwin.
|
|
||||||
install_name_tool =
|
|
||||||
if stdenv.targetPlatform.isAarch64
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
# Same goes for strip.
|
|
||||||
strip =
|
|
||||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
|
||||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
|
||||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
|
||||||
# see #84670 and #49071 for more background.
|
|
||||||
useLdGold = targetPlatform.linker == "gold" ||
|
|
||||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
|
||||||
|
|
||||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
|
||||||
variantSuffix = lib.concatStrings [
|
|
||||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
|
||||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
|
||||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
|
||||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
|
||||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
|
||||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
|
||||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
|
||||||
version = "9.4.6";
|
|
||||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
|
||||||
sha256 = "1b705cf52692f9d4d6707cdf8e761590f5f56ec8ea6a65e36610db392d3d24b9";
|
|
||||||
};
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
outputs = [ "out" "doc" ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs
|
|
||||||
# Can be removed if the Cabal library included with ghc backports the linked fix
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://github.com/haskell/cabal/commit/6c796218c92f93c95e94d5ec2d077f6956f68e98.patch";
|
|
||||||
stripLen = 1;
|
|
||||||
extraPrefix = "libraries/Cabal/";
|
|
||||||
sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY=";
|
|
||||||
})
|
|
||||||
|
|
||||||
# Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129
|
|
||||||
./docs-sphinx-7.patch
|
|
||||||
|
|
||||||
# Work around a type not being defined when including Rts.h in bytestring's cbits
|
|
||||||
# due to missing feature macros. See https://gitlab.haskell.org/ghc/ghc/-/issues/23810.
|
|
||||||
./9.4.6-bytestring-posix-source.patch
|
|
||||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
|
||||||
# Prevent the paths module from emitting symbols that we don't use
|
|
||||||
# when building with separate outputs.
|
|
||||||
#
|
|
||||||
# These cause problems as they're not eliminated by GHC's dead code
|
|
||||||
# elimination on aarch64-darwin. (see
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
|
||||||
./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = "patchShebangs .";
|
|
||||||
|
|
||||||
# GHC needs the locale configured during the Haddock phase.
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
|
|
||||||
# GHC is a bit confused on its cross terminology.
|
|
||||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
|
||||||
preConfigure = ''
|
|
||||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
|
||||||
export "''${env#TARGET_}=''${!env}"
|
|
||||||
done
|
|
||||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
|
||||||
# the *host* tools.
|
|
||||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
|
||||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
|
||||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
|
||||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
|
||||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
|
||||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
|
||||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
|
||||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
|
||||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
|
||||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
|
||||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
|
||||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
|
||||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
|
||||||
'' + lib.optionalString useLLVM ''
|
|
||||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
|
||||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
|
||||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
|
||||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
|
||||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
|
||||||
'' + ''
|
|
||||||
|
|
||||||
echo -n "${buildMK}" > mk/build.mk
|
|
||||||
|
|
||||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
|
||||||
'' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
|
|
||||||
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
|
|
||||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
||||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
|
|
||||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
|
||||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
|
||||||
'' + lib.optionalString targetPlatform.isMusl ''
|
|
||||||
echo "patching llvm-targets for musl targets..."
|
|
||||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
|
||||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
|
||||||
echo "(go go gadget sed)"
|
|
||||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
|
||||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
|
||||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
|
||||||
|
|
||||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
|
||||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
|
||||||
for x in configure aclocal.m4; do
|
|
||||||
substituteInPlace $x \
|
|
||||||
--replace '*-android*|*-gnueabi*)' \
|
|
||||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
|
||||||
done
|
|
||||||
''
|
|
||||||
# HACK: allow bootstrapping with GHC 8.10 which works fine, as we don't have
|
|
||||||
# binary 9.0 packaged. Bootstrapping with 9.2 is broken without hadrian.
|
|
||||||
+ ''
|
|
||||||
substituteInPlace configure --replace \
|
|
||||||
'MinBootGhcVersion="9.0"' \
|
|
||||||
'MinBootGhcVersion="8.10"'
|
|
||||||
'';
|
|
||||||
|
|
||||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
|
||||||
configurePlatforms = [ "build" "host" ]
|
|
||||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
|
||||||
|
|
||||||
# `--with` flags for libraries needed for RTS linker
|
|
||||||
configureFlags = [
|
|
||||||
"--datadir=$doc/share/doc/ghc"
|
|
||||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
|
||||||
] ++ lib.optionals (libffi != null) [
|
|
||||||
"--with-system-libffi"
|
|
||||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
|
||||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
|
||||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
|
||||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
|
||||||
"--with-iconv-includes=${libiconv}/include"
|
|
||||||
"--with-iconv-libraries=${libiconv}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
|
||||||
"--enable-bootstrap-with-devel-snapshot"
|
|
||||||
] ++ lib.optionals useLdGold [
|
|
||||||
"CFLAGS=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
|
||||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
|
||||||
"--disable-large-address-space"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
|
||||||
dontAddExtraLibs = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
perl autoconf automake m4 python3
|
|
||||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
|
||||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
||||||
autoSignDarwinBinariesHook
|
|
||||||
] ++ lib.optionals enableDocs [
|
|
||||||
sphinx
|
|
||||||
];
|
|
||||||
|
|
||||||
# For building runtime libs
|
|
||||||
depsBuildTarget = toolsForTarget;
|
|
||||||
|
|
||||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
|
||||||
|
|
||||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
|
||||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
|
||||||
|
|
||||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
||||||
# that in turn causes GHCi to abort
|
|
||||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
|
||||||
|
|
||||||
checkTarget = "test";
|
|
||||||
|
|
||||||
hardeningDisable =
|
|
||||||
[ "format" ]
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
# big-parallel allows us to build with more than 2 cores on
|
|
||||||
# Hydra which already warrants a significant speedup
|
|
||||||
requiredSystemFeatures = [ "big-parallel" ];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
# Install the bash completion file.
|
|
||||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit bootPkgs targetPrefix;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
inherit enableShared;
|
|
||||||
|
|
||||||
# This is used by the haskell builder to query
|
|
||||||
# the presence of the haddock program.
|
|
||||||
hasHaddock = enableHaddockProgram;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
timeout = 24 * 3600;
|
|
||||||
inherit (ghc.meta) license platforms;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
|
||||||
dontStrip = true;
|
|
||||||
dontPatchELF = true;
|
|
||||||
noAuditTmpdir = true;
|
|
||||||
})
|
|
|
@ -1,386 +0,0 @@
|
||||||
# DO NOT port this expression to hadrian. It is not possible to build a GHC
|
|
||||||
# cross compiler with 9.4.* and hadrian.
|
|
||||||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
|
||||||
|
|
||||||
# build-tools
|
|
||||||
, bootPkgs
|
|
||||||
, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
|
|
||||||
, xattr, autoSignDarwinBinariesHook
|
|
||||||
, bash
|
|
||||||
|
|
||||||
, libiconv ? null, ncurses
|
|
||||||
, glibcLocales ? null
|
|
||||||
|
|
||||||
, # GHC can be built with system libffi or a bundled one.
|
|
||||||
libffi ? null
|
|
||||||
|
|
||||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
|
||||||
|| stdenv.targetPlatform.isPower
|
|
||||||
|| stdenv.targetPlatform.isSparc
|
|
||||||
|| stdenv.targetPlatform.isAarch64)
|
|
||||||
, # LLVM is conceptually a run-time-only dependency, but for
|
|
||||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
|
||||||
# build-time dependency too.
|
|
||||||
buildTargetLlvmPackages, llvmPackages
|
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
|
||||||
# bignum backend instead of the faster but GPLed gmp backend.
|
|
||||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
|
|
||||||
&& lib.meta.availableOn stdenv.targetPlatform gmp)
|
|
||||||
, gmp
|
|
||||||
|
|
||||||
, # If enabled, use -fPIC when compiling static libs.
|
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
|
||||||
|
|
||||||
, enableProfiledLibs ? true
|
|
||||||
|
|
||||||
, # Whether to build dynamic libs for the standard library (on the target
|
|
||||||
# platform). Static libs are always built.
|
|
||||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
|
||||||
|
|
||||||
, # Whether to build terminfo.
|
|
||||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
|
||||||
|
|
||||||
, # What flavour to build. An empty string indicates no
|
|
||||||
# specific flavour and falls back to ghc default values.
|
|
||||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
|
||||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
|
||||||
|
|
||||||
, # Whether to build sphinx documentation.
|
|
||||||
enableDocs ? (
|
|
||||||
# Docs disabled if we are building on musl because it's a large task to keep
|
|
||||||
# all `sphinx` dependencies building in this environment.
|
|
||||||
!stdenv.buildPlatform.isMusl
|
|
||||||
)
|
|
||||||
|
|
||||||
, enableHaddockProgram ?
|
|
||||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
|
||||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
|
||||||
|
|
||||||
, # Whether to disable the large address space allocator
|
|
||||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
|
||||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
|
||||||
}:
|
|
||||||
|
|
||||||
assert !enableNativeBignum -> gmp != null;
|
|
||||||
|
|
||||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
|
||||||
# see note [HADDOCK_DOCS].
|
|
||||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
|
||||||
|
|
||||||
inherit (bootPkgs) ghc;
|
|
||||||
|
|
||||||
# TODO(@Ericson2314) Make unconditional
|
|
||||||
targetPrefix = lib.optionalString
|
|
||||||
(targetPlatform != hostPlatform)
|
|
||||||
"${targetPlatform.config}-";
|
|
||||||
|
|
||||||
buildMK = ''
|
|
||||||
BuildFlavour = ${ghcFlavour}
|
|
||||||
ifneq \"\$(BuildFlavour)\" \"\"
|
|
||||||
include mk/flavours/\$(BuildFlavour).mk
|
|
||||||
endif
|
|
||||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
|
||||||
BUILD_SPHINX_PDF = NO
|
|
||||||
'' +
|
|
||||||
# Note [HADDOCK_DOCS]:
|
|
||||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
|
||||||
# program is built (which we generally always want to have a complete GHC install)
|
|
||||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
|
||||||
# (which is impossible for cross-compilation); see:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
|
||||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
|
||||||
# program, so it can never generate haddocks for any packages.
|
|
||||||
# If this is solved in the future, we'd like to unconditionally
|
|
||||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
|
||||||
''
|
|
||||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
|
||||||
# Build haddocks for boot packages with hyperlinking
|
|
||||||
EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
|
|
||||||
|
|
||||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
|
||||||
BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
|
|
||||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
|
||||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
|
||||||
CrossCompilePrefix = ${targetPrefix}
|
|
||||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
|
||||||
BUILD_PROF_LIBS = NO
|
|
||||||
'' +
|
|
||||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
|
||||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
|
||||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
|
||||||
lib.optionalString enableRelocatedStaticLibs ''
|
|
||||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
EXTRA_CC_OPTS += -std=gnu99
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Splicer will pull out correct variations
|
|
||||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
|
||||||
++ [libffi]
|
|
||||||
++ lib.optional (!enableNativeBignum) gmp
|
|
||||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
|
||||||
|
|
||||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
|
||||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
|
||||||
toolsForTarget = [
|
|
||||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
|
||||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
|
||||||
|
|
||||||
targetCC = builtins.head toolsForTarget;
|
|
||||||
|
|
||||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
|
||||||
# derivation for certain tools depending on the platform.
|
|
||||||
bintoolsFor = {
|
|
||||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
|
||||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
|
||||||
# x86_64-darwin.
|
|
||||||
install_name_tool =
|
|
||||||
if stdenv.targetPlatform.isAarch64
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
# Same goes for strip.
|
|
||||||
strip =
|
|
||||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
|
||||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
|
||||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
|
||||||
# see #84670 and #49071 for more background.
|
|
||||||
useLdGold = targetPlatform.linker == "gold" ||
|
|
||||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
|
||||||
|
|
||||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
|
||||||
variantSuffix = lib.concatStrings [
|
|
||||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
|
||||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
|
||||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
|
||||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
|
||||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
|
||||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
|
||||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
|
||||||
version = "9.4.7";
|
|
||||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
|
||||||
sha256 = "06775a52b4d13ac09edc6dabc299fd11e59d8886bbcae450af367baee2684c8f";
|
|
||||||
};
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
outputs = [ "out" "doc" ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs
|
|
||||||
# Can be removed if the Cabal library included with ghc backports the linked fix
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://github.com/haskell/cabal/commit/6c796218c92f93c95e94d5ec2d077f6956f68e98.patch";
|
|
||||||
stripLen = 1;
|
|
||||||
extraPrefix = "libraries/Cabal/";
|
|
||||||
sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY=";
|
|
||||||
})
|
|
||||||
|
|
||||||
# Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129
|
|
||||||
./docs-sphinx-7.patch
|
|
||||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
|
||||||
# Prevent the paths module from emitting symbols that we don't use
|
|
||||||
# when building with separate outputs.
|
|
||||||
#
|
|
||||||
# These cause problems as they're not eliminated by GHC's dead code
|
|
||||||
# elimination on aarch64-darwin. (see
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
|
||||||
./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = "patchShebangs .";
|
|
||||||
|
|
||||||
# GHC needs the locale configured during the Haddock phase.
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
|
|
||||||
# GHC is a bit confused on its cross terminology.
|
|
||||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
|
||||||
preConfigure = ''
|
|
||||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
|
||||||
export "''${env#TARGET_}=''${!env}"
|
|
||||||
done
|
|
||||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
|
||||||
# the *host* tools.
|
|
||||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
|
||||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
|
||||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
|
||||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
|
||||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
|
||||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
|
||||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
|
||||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
|
||||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
|
||||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
|
||||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
|
||||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
|
||||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
|
||||||
'' + lib.optionalString useLLVM ''
|
|
||||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
|
||||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
|
||||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
|
||||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
|
||||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
|
||||||
'' + ''
|
|
||||||
|
|
||||||
echo -n "${buildMK}" > mk/build.mk
|
|
||||||
|
|
||||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
|
||||||
'' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
|
|
||||||
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
|
|
||||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
||||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
|
|
||||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
|
||||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
|
||||||
'' + lib.optionalString targetPlatform.isMusl ''
|
|
||||||
echo "patching llvm-targets for musl targets..."
|
|
||||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
|
||||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
|
||||||
echo "(go go gadget sed)"
|
|
||||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
|
||||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
|
||||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
|
||||||
|
|
||||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
|
||||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
|
||||||
for x in configure aclocal.m4; do
|
|
||||||
substituteInPlace $x \
|
|
||||||
--replace '*-android*|*-gnueabi*)' \
|
|
||||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
|
||||||
done
|
|
||||||
''
|
|
||||||
# HACK: allow bootstrapping with GHC 8.10 which works fine, as we don't have
|
|
||||||
# binary 9.0 packaged. Bootstrapping with 9.2 is broken without hadrian.
|
|
||||||
+ ''
|
|
||||||
substituteInPlace configure --replace \
|
|
||||||
'MinBootGhcVersion="9.0"' \
|
|
||||||
'MinBootGhcVersion="8.10"'
|
|
||||||
'';
|
|
||||||
|
|
||||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
|
||||||
configurePlatforms = [ "build" "host" ]
|
|
||||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
|
||||||
|
|
||||||
# `--with` flags for libraries needed for RTS linker
|
|
||||||
configureFlags = [
|
|
||||||
"--datadir=$doc/share/doc/ghc"
|
|
||||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
|
||||||
] ++ lib.optionals (libffi != null) [
|
|
||||||
"--with-system-libffi"
|
|
||||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
|
||||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
|
||||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
|
||||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
|
||||||
"--with-iconv-includes=${libiconv}/include"
|
|
||||||
"--with-iconv-libraries=${libiconv}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
|
||||||
"--enable-bootstrap-with-devel-snapshot"
|
|
||||||
] ++ lib.optionals useLdGold [
|
|
||||||
"CFLAGS=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
|
||||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
|
||||||
"--disable-large-address-space"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
|
||||||
dontAddExtraLibs = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
perl autoconf automake m4 python3
|
|
||||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
|
||||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
||||||
autoSignDarwinBinariesHook
|
|
||||||
] ++ lib.optionals enableDocs [
|
|
||||||
sphinx
|
|
||||||
];
|
|
||||||
|
|
||||||
# For building runtime libs
|
|
||||||
depsBuildTarget = toolsForTarget;
|
|
||||||
|
|
||||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
|
||||||
|
|
||||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
|
||||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
|
||||||
|
|
||||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
||||||
# that in turn causes GHCi to abort
|
|
||||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
|
||||||
|
|
||||||
checkTarget = "test";
|
|
||||||
|
|
||||||
hardeningDisable =
|
|
||||||
[ "format" ]
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
# big-parallel allows us to build with more than 2 cores on
|
|
||||||
# Hydra which already warrants a significant speedup
|
|
||||||
requiredSystemFeatures = [ "big-parallel" ];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
# Install the bash completion file.
|
|
||||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit bootPkgs targetPrefix;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
inherit enableShared;
|
|
||||||
|
|
||||||
# This is used by the haskell builder to query
|
|
||||||
# the presence of the haddock program.
|
|
||||||
hasHaddock = enableHaddockProgram;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
timeout = 24 * 3600;
|
|
||||||
inherit (ghc.meta) license platforms;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
|
||||||
dontStrip = true;
|
|
||||||
dontPatchELF = true;
|
|
||||||
noAuditTmpdir = true;
|
|
||||||
})
|
|
|
@ -1,386 +0,0 @@
|
||||||
# DO NOT port this expression to hadrian. It is not possible to build a GHC
|
|
||||||
# cross compiler with 9.4.* and hadrian.
|
|
||||||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
|
||||||
|
|
||||||
# build-tools
|
|
||||||
, bootPkgs
|
|
||||||
, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
|
|
||||||
, xattr, autoSignDarwinBinariesHook
|
|
||||||
, bash
|
|
||||||
|
|
||||||
, libiconv ? null, ncurses
|
|
||||||
, glibcLocales ? null
|
|
||||||
|
|
||||||
, # GHC can be built with system libffi or a bundled one.
|
|
||||||
libffi ? null
|
|
||||||
|
|
||||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
|
||||||
|| stdenv.targetPlatform.isPower
|
|
||||||
|| stdenv.targetPlatform.isSparc
|
|
||||||
|| stdenv.targetPlatform.isAarch64)
|
|
||||||
, # LLVM is conceptually a run-time-only dependency, but for
|
|
||||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
|
||||||
# build-time dependency too.
|
|
||||||
buildTargetLlvmPackages, llvmPackages
|
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
|
||||||
# bignum backend instead of the faster but GPLed gmp backend.
|
|
||||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
|
|
||||||
&& lib.meta.availableOn stdenv.targetPlatform gmp)
|
|
||||||
, gmp
|
|
||||||
|
|
||||||
, # If enabled, use -fPIC when compiling static libs.
|
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
|
||||||
|
|
||||||
, enableProfiledLibs ? true
|
|
||||||
|
|
||||||
, # Whether to build dynamic libs for the standard library (on the target
|
|
||||||
# platform). Static libs are always built.
|
|
||||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
|
||||||
|
|
||||||
, # Whether to build terminfo.
|
|
||||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
|
||||||
|
|
||||||
, # What flavour to build. An empty string indicates no
|
|
||||||
# specific flavour and falls back to ghc default values.
|
|
||||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
|
||||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
|
||||||
|
|
||||||
, # Whether to build sphinx documentation.
|
|
||||||
enableDocs ? (
|
|
||||||
# Docs disabled if we are building on musl because it's a large task to keep
|
|
||||||
# all `sphinx` dependencies building in this environment.
|
|
||||||
!stdenv.buildPlatform.isMusl
|
|
||||||
)
|
|
||||||
|
|
||||||
, enableHaddockProgram ?
|
|
||||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
|
||||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
|
||||||
|
|
||||||
, # Whether to disable the large address space allocator
|
|
||||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
|
||||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
|
||||||
}:
|
|
||||||
|
|
||||||
assert !enableNativeBignum -> gmp != null;
|
|
||||||
|
|
||||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
|
||||||
# see note [HADDOCK_DOCS].
|
|
||||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
|
||||||
|
|
||||||
inherit (bootPkgs) ghc;
|
|
||||||
|
|
||||||
# TODO(@Ericson2314) Make unconditional
|
|
||||||
targetPrefix = lib.optionalString
|
|
||||||
(targetPlatform != hostPlatform)
|
|
||||||
"${targetPlatform.config}-";
|
|
||||||
|
|
||||||
buildMK = ''
|
|
||||||
BuildFlavour = ${ghcFlavour}
|
|
||||||
ifneq \"\$(BuildFlavour)\" \"\"
|
|
||||||
include mk/flavours/\$(BuildFlavour).mk
|
|
||||||
endif
|
|
||||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
|
||||||
BUILD_SPHINX_PDF = NO
|
|
||||||
'' +
|
|
||||||
# Note [HADDOCK_DOCS]:
|
|
||||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
|
||||||
# program is built (which we generally always want to have a complete GHC install)
|
|
||||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
|
||||||
# (which is impossible for cross-compilation); see:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
|
||||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
|
||||||
# program, so it can never generate haddocks for any packages.
|
|
||||||
# If this is solved in the future, we'd like to unconditionally
|
|
||||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
|
||||||
''
|
|
||||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
|
||||||
# Build haddocks for boot packages with hyperlinking
|
|
||||||
EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump
|
|
||||||
|
|
||||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
|
||||||
BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
|
|
||||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
|
||||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
|
||||||
CrossCompilePrefix = ${targetPrefix}
|
|
||||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
|
||||||
BUILD_PROF_LIBS = NO
|
|
||||||
'' +
|
|
||||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
|
||||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
|
||||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
|
||||||
lib.optionalString enableRelocatedStaticLibs ''
|
|
||||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
EXTRA_CC_OPTS += -std=gnu99
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Splicer will pull out correct variations
|
|
||||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
|
||||||
++ [libffi]
|
|
||||||
++ lib.optional (!enableNativeBignum) gmp
|
|
||||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
|
||||||
|
|
||||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
|
||||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
|
||||||
toolsForTarget = [
|
|
||||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
|
||||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
|
||||||
|
|
||||||
targetCC = builtins.head toolsForTarget;
|
|
||||||
|
|
||||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
|
||||||
# derivation for certain tools depending on the platform.
|
|
||||||
bintoolsFor = {
|
|
||||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
|
||||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
|
||||||
# x86_64-darwin.
|
|
||||||
install_name_tool =
|
|
||||||
if stdenv.targetPlatform.isAarch64
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
# Same goes for strip.
|
|
||||||
strip =
|
|
||||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
|
||||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
|
||||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
|
||||||
# see #84670 and #49071 for more background.
|
|
||||||
useLdGold = targetPlatform.linker == "gold" ||
|
|
||||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
|
||||||
|
|
||||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
|
||||||
variantSuffix = lib.concatStrings [
|
|
||||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
|
||||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
|
||||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
|
||||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
|
||||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
|
||||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
|
||||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
|
||||||
|
|
||||||
stdenv.mkDerivation (rec {
|
|
||||||
version = "9.4.8";
|
|
||||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
|
||||||
sha256 = "0bf407eb67fe3e3c24b0f4c8dea8cb63e07f63ca0f76cf2058565143507ab85e";
|
|
||||||
};
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
outputs = [ "out" "doc" ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs
|
|
||||||
# Can be removed if the Cabal library included with ghc backports the linked fix
|
|
||||||
(fetchpatch {
|
|
||||||
url = "https://github.com/haskell/cabal/commit/6c796218c92f93c95e94d5ec2d077f6956f68e98.patch";
|
|
||||||
stripLen = 1;
|
|
||||||
extraPrefix = "libraries/Cabal/";
|
|
||||||
sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY=";
|
|
||||||
})
|
|
||||||
|
|
||||||
# Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129
|
|
||||||
./docs-sphinx-7.patch
|
|
||||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
|
||||||
# Prevent the paths module from emitting symbols that we don't use
|
|
||||||
# when building with separate outputs.
|
|
||||||
#
|
|
||||||
# These cause problems as they're not eliminated by GHC's dead code
|
|
||||||
# elimination on aarch64-darwin. (see
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
|
||||||
./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = "patchShebangs .";
|
|
||||||
|
|
||||||
# GHC needs the locale configured during the Haddock phase.
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
|
|
||||||
# GHC is a bit confused on its cross terminology.
|
|
||||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
|
||||||
preConfigure = ''
|
|
||||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
|
||||||
export "''${env#TARGET_}=''${!env}"
|
|
||||||
done
|
|
||||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
|
||||||
# the *host* tools.
|
|
||||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
|
||||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
|
||||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
|
||||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
|
||||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
|
||||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
|
||||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
|
||||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
|
||||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
|
||||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
|
||||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
|
||||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
|
||||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
|
||||||
'' + lib.optionalString useLLVM ''
|
|
||||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
|
||||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
|
||||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
|
||||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
|
||||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
|
||||||
'' + ''
|
|
||||||
|
|
||||||
echo -n "${buildMK}" > mk/build.mk
|
|
||||||
|
|
||||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
|
||||||
'' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
|
|
||||||
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
|
|
||||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
||||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
|
|
||||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
|
||||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
|
||||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
|
||||||
'' + lib.optionalString targetPlatform.isMusl ''
|
|
||||||
echo "patching llvm-targets for musl targets..."
|
|
||||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
|
||||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
|
||||||
echo "(go go gadget sed)"
|
|
||||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
|
||||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
|
||||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
|
||||||
|
|
||||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
|
||||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
|
||||||
for x in configure aclocal.m4; do
|
|
||||||
substituteInPlace $x \
|
|
||||||
--replace '*-android*|*-gnueabi*)' \
|
|
||||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
|
||||||
done
|
|
||||||
''
|
|
||||||
# HACK: allow bootstrapping with GHC 8.10 which works fine, as we don't have
|
|
||||||
# binary 9.0 packaged. Bootstrapping with 9.2 is broken without hadrian.
|
|
||||||
+ ''
|
|
||||||
substituteInPlace configure --replace \
|
|
||||||
'MinBootGhcVersion="9.0"' \
|
|
||||||
'MinBootGhcVersion="8.10"'
|
|
||||||
'';
|
|
||||||
|
|
||||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
|
||||||
configurePlatforms = [ "build" "host" ]
|
|
||||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
|
||||||
|
|
||||||
# `--with` flags for libraries needed for RTS linker
|
|
||||||
configureFlags = [
|
|
||||||
"--datadir=$doc/share/doc/ghc"
|
|
||||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
|
||||||
] ++ lib.optionals (libffi != null) [
|
|
||||||
"--with-system-libffi"
|
|
||||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
|
||||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
|
||||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
|
||||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
|
||||||
"--with-iconv-includes=${libiconv}/include"
|
|
||||||
"--with-iconv-libraries=${libiconv}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
|
||||||
"--enable-bootstrap-with-devel-snapshot"
|
|
||||||
] ++ lib.optionals useLdGold [
|
|
||||||
"CFLAGS=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
|
||||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
|
||||||
"--disable-large-address-space"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
|
||||||
dontAddExtraLibs = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
perl autoconf automake m4 python3
|
|
||||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
|
||||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
||||||
autoSignDarwinBinariesHook
|
|
||||||
] ++ lib.optionals enableDocs [
|
|
||||||
sphinx
|
|
||||||
];
|
|
||||||
|
|
||||||
# For building runtime libs
|
|
||||||
depsBuildTarget = toolsForTarget;
|
|
||||||
|
|
||||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
|
||||||
|
|
||||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
|
||||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
|
||||||
|
|
||||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
||||||
# that in turn causes GHCi to abort
|
|
||||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
|
||||||
|
|
||||||
checkTarget = "test";
|
|
||||||
|
|
||||||
hardeningDisable =
|
|
||||||
[ "format" ]
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
# big-parallel allows us to build with more than 2 cores on
|
|
||||||
# Hydra which already warrants a significant speedup
|
|
||||||
requiredSystemFeatures = [ "big-parallel" ];
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
# Install the bash completion file.
|
|
||||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit bootPkgs targetPrefix;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
inherit enableShared;
|
|
||||||
|
|
||||||
# This is used by the haskell builder to query
|
|
||||||
# the presence of the haddock program.
|
|
||||||
hasHaddock = enableHaddockProgram;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
timeout = 24 * 3600;
|
|
||||||
inherit (ghc.meta) license platforms;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
|
||||||
dontStrip = true;
|
|
||||||
dontPatchELF = true;
|
|
||||||
noAuditTmpdir = true;
|
|
||||||
})
|
|
|
@ -1,410 +0,0 @@
|
||||||
{ lib, stdenv
|
|
||||||
, fetchurl, perl, gcc
|
|
||||||
, ncurses5
|
|
||||||
, ncurses6, gmp, libiconv, numactl, libffi
|
|
||||||
, llvmPackages
|
|
||||||
, coreutils
|
|
||||||
, targetPackages
|
|
||||||
|
|
||||||
# minimal = true; will remove files that aren't strictly necessary for
|
|
||||||
# regular builds and GHC bootstrapping.
|
|
||||||
# This is "useful" for staying within hydra's output limits for at least the
|
|
||||||
# aarch64-linux architecture.
|
|
||||||
, minimal ? false
|
|
||||||
}:
|
|
||||||
|
|
||||||
# Prebuilt only does native
|
|
||||||
assert stdenv.targetPlatform == stdenv.hostPlatform;
|
|
||||||
|
|
||||||
let
|
|
||||||
downloadsUrl = "https://downloads.haskell.org/ghc";
|
|
||||||
|
|
||||||
# Copy sha256 from https://downloads.haskell.org/~ghc/9.6.3/SHA256SUMS
|
|
||||||
version = "9.6.3";
|
|
||||||
|
|
||||||
# Information about available bindists that we use in the build.
|
|
||||||
#
|
|
||||||
# # Bindist library checking
|
|
||||||
#
|
|
||||||
# The field `archSpecificLibraries` also provides a way for us get notified
|
|
||||||
# early when the upstream bindist changes its dependencies (e.g. because a
|
|
||||||
# newer Debian version is used that uses a new `ncurses` version).
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# * You can find the `fileToCheckFor` of libraries by running `readelf -d`
|
|
||||||
# on the compiler binary (`exePathForLibraryCheck`).
|
|
||||||
# * To skip library checking for an architecture,
|
|
||||||
# set `exePathForLibraryCheck = null`.
|
|
||||||
# * To skip file checking for a specific arch specfic library,
|
|
||||||
# set `fileToCheckFor = null`.
|
|
||||||
ghcBinDists = {
|
|
||||||
# Binary distributions for the default libc (e.g. glibc, or libSystem on Darwin)
|
|
||||||
# nixpkgs uses for the respective system.
|
|
||||||
defaultLibc = {
|
|
||||||
i686-linux = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
|
|
||||||
sha256 = "58be26f8b8f6b5bd8baf5c32abb03e2c4621646b2142fab10e5c7de5af5c50f8";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = "bin/ghc";
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
# The i686-linux bindist provided by GHC HQ is currently built on Debian 9,
|
|
||||||
# which link it against `libtinfo.so.5` (ncurses 5).
|
|
||||||
# Other bindists are linked `libtinfo.so.6` (ncurses 6).
|
|
||||||
{ nixPackage = ncurses5; fileToCheckFor = "libtinfo.so.5"; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
x86_64-linux = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb11-linux.tar.xz";
|
|
||||||
sha256 = "c4c0124857265926f1cf22a09d950d7ba989ff94053a4ddf3dcdab5359f4cab7";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = "bin/ghc";
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
aarch64-linux = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
|
|
||||||
sha256 = "03c389859319f09452081310fc13af7525063ea8930830ef76be2a14b312271e";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = "bin/ghc";
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
|
||||||
{ nixPackage = numactl; fileToCheckFor = null; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
x86_64-darwin = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
|
|
||||||
sha256 = "dde46118ab8388fb1066312c097123e93b1dcf6ae366e3370f88ea456382c9db";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = null; # we don't have a library check for darwin yet
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = libiconv; fileToCheckFor = null; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
aarch64-darwin = {
|
|
||||||
variantSuffix = "";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz";
|
|
||||||
sha256 = "e1cdf458926b2eaf52d2a8287d99a965040ff9051171f5c3b7467049cf0eb213";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = null; # we don't have a library check for darwin yet
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = libiconv; fileToCheckFor = null; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
# Binary distributions for the musl libc for the respective system.
|
|
||||||
musl = {
|
|
||||||
x86_64-linux = {
|
|
||||||
variantSuffix = "-musl";
|
|
||||||
src = {
|
|
||||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3_12-linux.tar.xz";
|
|
||||||
sha256 = "8f457af0aa40127049c11134c8793f64351a446e87da1f8ec256e1279b5ab61f";
|
|
||||||
};
|
|
||||||
exePathForLibraryCheck = "bin/ghc";
|
|
||||||
archSpecificLibraries = [
|
|
||||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
|
||||||
{ nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; }
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
distSetName = if stdenv.hostPlatform.isMusl then "musl" else "defaultLibc";
|
|
||||||
|
|
||||||
binDistUsed = ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}
|
|
||||||
or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')");
|
|
||||||
|
|
||||||
gmpUsed = (builtins.head (
|
|
||||||
builtins.filter (
|
|
||||||
drv: lib.hasPrefix "gmp" (drv.nixPackage.name or "")
|
|
||||||
) binDistUsed.archSpecificLibraries
|
|
||||||
)).nixPackage;
|
|
||||||
|
|
||||||
# GHC has other native backends (like PowerPC), but here only the ones
|
|
||||||
# we ship bindists for matter.
|
|
||||||
useLLVM = !(stdenv.targetPlatform.isx86
|
|
||||||
|| (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin));
|
|
||||||
|
|
||||||
libPath =
|
|
||||||
lib.makeLibraryPath (
|
|
||||||
# Add arch-specific libraries.
|
|
||||||
map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries
|
|
||||||
);
|
|
||||||
|
|
||||||
libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
|
|
||||||
+ "LD_LIBRARY_PATH";
|
|
||||||
|
|
||||||
runtimeDeps = [
|
|
||||||
targetPackages.stdenv.cc
|
|
||||||
targetPackages.stdenv.cc.bintools
|
|
||||||
coreutils # for cat
|
|
||||||
]
|
|
||||||
++ lib.optionals useLLVM [
|
|
||||||
(lib.getBin llvmPackages.llvm)
|
|
||||||
]
|
|
||||||
# On darwin, we need unwrapped bintools as well (for otool)
|
|
||||||
++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [
|
|
||||||
targetPackages.stdenv.cc.bintools.bintools
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
|
||||||
inherit version;
|
|
||||||
pname = "ghc-binary${binDistUsed.variantSuffix}";
|
|
||||||
|
|
||||||
src = fetchurl binDistUsed.src;
|
|
||||||
|
|
||||||
nativeBuildInputs = [ perl ];
|
|
||||||
|
|
||||||
# Set LD_LIBRARY_PATH or equivalent so that the programs running as part
|
|
||||||
# of the bindist installer can find the libraries they expect.
|
|
||||||
# Cannot patchelf beforehand due to relative RPATHs that anticipate
|
|
||||||
# the final install location.
|
|
||||||
${libEnvVar} = libPath;
|
|
||||||
|
|
||||||
postUnpack =
|
|
||||||
# Verify our assumptions of which `libtinfo.so` (ncurses) version is used,
|
|
||||||
# so that we know when ghc bindists upgrade that and we need to update the
|
|
||||||
# version used in `libPath`.
|
|
||||||
lib.optionalString
|
|
||||||
(binDistUsed.exePathForLibraryCheck != null)
|
|
||||||
# Note the `*` glob because some GHCs have a suffix when unpacked, e.g.
|
|
||||||
# the musl bindist has dir `ghc-VERSION-x86_64-unknown-linux/`.
|
|
||||||
# As a result, don't shell-quote this glob when splicing the string.
|
|
||||||
(let buildExeGlob = ''ghc-${version}*/"${binDistUsed.exePathForLibraryCheck}"''; in
|
|
||||||
lib.concatStringsSep "\n" [
|
|
||||||
(''
|
|
||||||
shopt -u nullglob
|
|
||||||
echo "Checking that ghc binary exists in bindist at ${buildExeGlob}"
|
|
||||||
if ! test -e ${buildExeGlob}; then
|
|
||||||
echo >&2 "GHC binary ${binDistUsed.exePathForLibraryCheck} could not be found in the bindist build directory (at ${buildExeGlob}) for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
|
||||||
fi
|
|
||||||
'')
|
|
||||||
(lib.concatMapStringsSep
|
|
||||||
"\n"
|
|
||||||
({ fileToCheckFor, nixPackage }:
|
|
||||||
lib.optionalString (fileToCheckFor != null) ''
|
|
||||||
echo "Checking bindist for ${fileToCheckFor} to ensure that is still used"
|
|
||||||
if ! readelf -d ${buildExeGlob} | grep "${fileToCheckFor}"; then
|
|
||||||
echo >&2 "File ${fileToCheckFor} could not be found in ${binDistUsed.exePathForLibraryCheck} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Checking that the nix package ${nixPackage} contains ${fileToCheckFor}"
|
|
||||||
if ! test -e "${lib.getLib nixPackage}/lib/${fileToCheckFor}"; then
|
|
||||||
echo >&2 "Nix package ${nixPackage} did not contain ${fileToCheckFor} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
|
||||||
fi
|
|
||||||
''
|
|
||||||
)
|
|
||||||
binDistUsed.archSpecificLibraries
|
|
||||||
)
|
|
||||||
])
|
|
||||||
# GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
|
|
||||||
# during linking
|
|
||||||
+ lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
# not enough room in the object files for the full path to libiconv :(
|
|
||||||
for exe in $(find . -type f -executable); do
|
|
||||||
isMachO $exe || continue
|
|
||||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
|
||||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
|
||||||
done
|
|
||||||
''
|
|
||||||
|
|
||||||
# We have to patch the GMP paths for the ghc-bignum package, for hadrian by
|
|
||||||
# modifying the package-db directly
|
|
||||||
+ ''
|
|
||||||
find . -name 'ghc-bignum*.conf' \
|
|
||||||
-exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib gmpUsed}/lib' -i {} \;
|
|
||||||
''
|
|
||||||
# Similar for iconv and libffi on darwin
|
|
||||||
+ lib.optionalString stdenv.isDarwin ''
|
|
||||||
find . -name 'base*.conf' \
|
|
||||||
-exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib libiconv}/lib' -i {} \;
|
|
||||||
|
|
||||||
# To link RTS in the end we also need libffi now
|
|
||||||
find . -name 'rts*.conf' \
|
|
||||||
-exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib libffi}/lib' \
|
|
||||||
-e 's@/Library/Developer/.*/usr/include/ffi@${lib.getDev libffi}/include@' \
|
|
||||||
-i {} \;
|
|
||||||
'' +
|
|
||||||
# aarch64 does HAVE_NUMA so -lnuma requires it in library-dirs in rts/package.conf.in
|
|
||||||
# FFI_LIB_DIR is a good indication of places it must be needed.
|
|
||||||
lib.optionalString (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) ''
|
|
||||||
find . -name package.conf.in \
|
|
||||||
-exec sed -i "s@FFI_LIB_DIR@FFI_LIB_DIR ${numactl.out}/lib@g" {} \;
|
|
||||||
'' +
|
|
||||||
# Rename needed libraries and binaries, fix interpreter
|
|
||||||
lib.optionalString stdenv.isLinux ''
|
|
||||||
find . -type f -executable -exec patchelf \
|
|
||||||
--interpreter ${stdenv.cc.bintools.dynamicLinker} {} \;
|
|
||||||
'';
|
|
||||||
|
|
||||||
# fix for `configure: error: Your linker is affected by binutils #16177`
|
|
||||||
preConfigure = lib.optionalString
|
|
||||||
stdenv.targetPlatform.isAarch32
|
|
||||||
"LD=ld.gold";
|
|
||||||
|
|
||||||
# GHC has a patched config.sub and bindists' platforms should always work
|
|
||||||
dontUpdateAutotoolsGnuConfigScripts = true;
|
|
||||||
|
|
||||||
configurePlatforms = [ ];
|
|
||||||
configureFlags =
|
|
||||||
lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
|
|
||||||
# From: https://github.com/NixOS/nixpkgs/pull/43369/commits
|
|
||||||
++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
|
|
||||||
|
|
||||||
# No building is necessary, but calling make without flags ironically
|
|
||||||
# calls install-strip ...
|
|
||||||
dontBuild = true;
|
|
||||||
|
|
||||||
# Patch scripts to include runtime dependencies in $PATH.
|
|
||||||
postInstall = ''
|
|
||||||
for i in "$out/bin/"*; do
|
|
||||||
test ! -h "$i" || continue
|
|
||||||
isScript "$i" || continue
|
|
||||||
sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Apparently necessary for the ghc Alpine (musl) bindist:
|
|
||||||
# When we strip, and then run the
|
|
||||||
# patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
|
|
||||||
# below, running ghc (e.g. during `installCheckPhase)` gives some apparently
|
|
||||||
# corrupted rpath or whatever makes the loader work on nonsensical strings:
|
|
||||||
# running install tests
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: : symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: ir6zf6c9f86pfx8sr30n2vjy-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: y/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: <20>: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: <20>?: symbol not found
|
|
||||||
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
|
|
||||||
# This is extremely bogus and should be investigated.
|
|
||||||
dontStrip = if stdenv.hostPlatform.isMusl then true else false; # `if` for explicitness
|
|
||||||
|
|
||||||
# On Linux, use patchelf to modify the executables so that they can
|
|
||||||
# find editline/gmp.
|
|
||||||
postFixup = lib.optionalString (stdenv.isLinux && !(binDistUsed.isStatic or false))
|
|
||||||
(if stdenv.hostPlatform.isAarch64 then
|
|
||||||
# Keep rpath as small as possible on aarch64 for patchelf#244. All Elfs
|
|
||||||
# are 2 directories deep from $out/lib, so pooling symlinks there makes
|
|
||||||
# a short rpath.
|
|
||||||
''
|
|
||||||
(cd $out/lib; ln -s ${ncurses6.out}/lib/libtinfo.so.6)
|
|
||||||
(cd $out/lib; ln -s ${lib.getLib gmpUsed}/lib/libgmp.so.10)
|
|
||||||
(cd $out/lib; ln -s ${numactl.out}/lib/libnuma.so.1)
|
|
||||||
for p in $(find "$out/lib" -type f -name "*\.so*"); do
|
|
||||||
(cd $out/lib; ln -s $p)
|
|
||||||
done
|
|
||||||
|
|
||||||
for p in $(find "$out/lib" -type f -executable); do
|
|
||||||
if isELF "$p"; then
|
|
||||||
echo "Patchelfing $p"
|
|
||||||
patchelf --set-rpath "\$ORIGIN:\$ORIGIN/../.." $p
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
''
|
|
||||||
else
|
|
||||||
''
|
|
||||||
for p in $(find "$out" -type f -executable); do
|
|
||||||
if isELF "$p"; then
|
|
||||||
echo "Patchelfing $p"
|
|
||||||
patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
'') + lib.optionalString stdenv.isDarwin ''
|
|
||||||
# not enough room in the object files for the full path to libiconv :(
|
|
||||||
for exe in $(find "$out" -type f -executable); do
|
|
||||||
isMachO $exe || continue
|
|
||||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
|
||||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
|
||||||
done
|
|
||||||
|
|
||||||
for file in $(find "$out" -name setup-config); do
|
|
||||||
substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
|
|
||||||
done
|
|
||||||
''
|
|
||||||
# Recache package db which needs to happen for Hadrian bindists
|
|
||||||
# where we modify the package db before installing
|
|
||||||
+ ''
|
|
||||||
package_db=("$out"/lib/ghc-*/lib/package.conf.d)
|
|
||||||
"$out/bin/ghc-pkg" --package-db="$package_db" recache
|
|
||||||
'';
|
|
||||||
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
doInstallCheck = true;
|
|
||||||
installCheckPhase = ''
|
|
||||||
# Sanity check, can ghc create executables?
|
|
||||||
cd $TMP
|
|
||||||
mkdir test-ghc; cd test-ghc
|
|
||||||
cat > main.hs << EOF
|
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
|
||||||
module Main where
|
|
||||||
main = putStrLn \$([|"yes"|])
|
|
||||||
EOF
|
|
||||||
env -i $out/bin/ghc --make main.hs || exit 1
|
|
||||||
echo compilation ok
|
|
||||||
[ $(./main) == "yes" ]
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
targetPrefix = "";
|
|
||||||
enableShared = true;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
|
|
||||||
# Normal GHC derivations expose the hadrian derivation used to build them
|
|
||||||
# here. In the case of bindists we just make sure that the attribute exists,
|
|
||||||
# as it is used for checking if a GHC derivation has been built with hadrian.
|
|
||||||
hadrian = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = rec {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
license = lib.licenses.bsd3;
|
|
||||||
# HACK: since we can't encode the libc / abi in platforms, we need
|
|
||||||
# to make the platform list dependent on the evaluation platform
|
|
||||||
# in order to avoid eval errors with musl which supports less
|
|
||||||
# platforms than the default libcs (i. e. glibc / libSystem).
|
|
||||||
# This is done for the benefit of Hydra, so `packagePlatforms`
|
|
||||||
# won't return any platforms that would cause an evaluation
|
|
||||||
# failure for `pkgsMusl.haskell.compiler.ghc922Binary`, as
|
|
||||||
# long as the evaluator runs on a platform that supports
|
|
||||||
# `pkgsMusl`.
|
|
||||||
platforms = builtins.attrNames ghcBinDists.${distSetName};
|
|
||||||
maintainers = [ ];
|
|
||||||
# packages involving hsc2hs (clock) produce libraries our
|
|
||||||
# ld can't link against
|
|
||||||
broken = stdenv.hostPlatform.isDarwin;
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
import ./common-hadrian.nix rec {
|
|
||||||
version = "9.6.3";
|
|
||||||
sha256 = "1xbpxchmvm9gswrwwz1rsvx9kjaxhc2q3fx9l6wa0l5599xydkfz";
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
import ./common-hadrian.nix {
|
|
||||||
version = "9.6.4";
|
|
||||||
sha256 = "10bf25b8b07174fdd9868b5c0c56c17c0ef1edcb6247b4b864be933651bfd4c0";
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
import ./common-hadrian.nix {
|
|
||||||
version = "9.6.5";
|
|
||||||
sha256 = "87b389924f98c1a26c205122757338c8dab33ad1fcf670faa22622742432b93c";
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
import ./common-hadrian.nix rec {
|
|
||||||
version = "9.8.1";
|
|
||||||
sha256 = "b2f8ed6b7f733797a92436f4ff6e088a520913149c9a9be90465b40ad1f20751";
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
import ./common-hadrian.nix rec {
|
|
||||||
version = "9.8.2";
|
|
||||||
sha256 = "4vt6fddGEjfSLoNlqD7dnhp30uFdBF85RTloRah3gck=";
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
diff --git a/Cabal/Distribution/Simple/Build/PathsModule.hs b/Cabal/Distribution/Simple/Build/PathsModule.hs
|
|
||||||
index 5e660e8d6..1ae603c94 100644
|
|
||||||
--- a/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs
|
|
||||||
+++ b/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs
|
|
||||||
@@ -37,6 +37,9 @@ import System.FilePath ( pathSeparator )
|
|
||||||
-- * Building Paths_<pkg>.hs
|
|
||||||
-- ------------------------------------------------------------
|
|
||||||
|
|
||||||
+splitPath :: FilePath -> [ String ]
|
|
||||||
+splitPath = unintersperse pathSeparator
|
|
||||||
+
|
|
||||||
generatePathsModule :: PackageDescription -> LocalBuildInfo -> ComponentLocalBuildInfo -> String
|
|
||||||
generatePathsModule pkg_descr lbi clbi =
|
|
||||||
let pragmas =
|
|
||||||
@@ -78,12 +81,44 @@ generatePathsModule pkg_descr lbi clbi =
|
|
||||||
"import System.Environment (getExecutablePath)\n"
|
|
||||||
| otherwise = ""
|
|
||||||
|
|
||||||
+ dirs = [ (flat_libdir, "LibDir")
|
|
||||||
+ , (flat_dynlibdir, "DynLibDir")
|
|
||||||
+ , (flat_datadir, "DataDir")
|
|
||||||
+ , (flat_libexecdir, "LibexecDir")
|
|
||||||
+ , (flat_sysconfdir, "SysconfDir") ];
|
|
||||||
+
|
|
||||||
+ shouldEmitPath p
|
|
||||||
+ | (splitPath flat_prefix) `isPrefixOf` (splitPath flat_bindir) = True
|
|
||||||
+ | (splitPath flat_prefix) `isPrefixOf` (splitPath p) = False
|
|
||||||
+ | otherwise = True
|
|
||||||
+
|
|
||||||
+ shouldEmitDataDir = shouldEmitPath flat_datadir
|
|
||||||
+
|
|
||||||
+ nixEmitPathFn (path, name) = let
|
|
||||||
+ varName = toLower <$> name
|
|
||||||
+ fnName = "get"++name
|
|
||||||
+ in if shouldEmitPath path then
|
|
||||||
+ varName ++ " :: FilePath\n"++
|
|
||||||
+ varName ++ " = " ++ show path ++
|
|
||||||
+ "\n" ++ fnName ++ " :: IO FilePath" ++
|
|
||||||
+ "\n" ++ fnName ++ " = " ++ mkGetEnvOr varName ("return " ++ varName)++"\n"
|
|
||||||
+ else ""
|
|
||||||
+
|
|
||||||
+ absBody = intercalate "\n" $ nixEmitPathFn <$> dirs
|
|
||||||
+
|
|
||||||
+ warnPragma = case filter (not . shouldEmitPath . fst) dirs of
|
|
||||||
+ [] -> ""
|
|
||||||
+ omittedDirs -> "{-# WARNING \"The functions: "++omittedFns++" Have been omitted by the Nix build system.\" #-}"
|
|
||||||
+ where omittedFns = intercalate ", " $ map snd omittedDirs
|
|
||||||
+
|
|
||||||
+ importList = intercalate ", " $ ("get" ++) . snd <$> filter (shouldEmitPath . fst) dirs
|
|
||||||
+
|
|
||||||
header =
|
|
||||||
pragmas++
|
|
||||||
- "module " ++ prettyShow paths_modulename ++ " (\n"++
|
|
||||||
- " version,\n"++
|
|
||||||
- " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n"++
|
|
||||||
- " getDataFileName, getSysconfDir\n"++
|
|
||||||
+ "module " ++ prettyShow paths_modulename ++ " " ++ warnPragma ++ " (\n"++
|
|
||||||
+ " version, getBinDir,\n"++
|
|
||||||
+ (if shouldEmitDataDir then " getDataFileName, \n" else "\n")++
|
|
||||||
+ " " ++ importList ++"\n"++
|
|
||||||
" ) where\n"++
|
|
||||||
"\n"++
|
|
||||||
foreign_imports++
|
|
||||||
@@ -136,26 +171,18 @@ generatePathsModule pkg_descr lbi clbi =
|
|
||||||
"\n"++
|
|
||||||
filename_stuff
|
|
||||||
| absolute =
|
|
||||||
- "\nbindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath\n"++
|
|
||||||
+ "\nbindir :: FilePath\n"++
|
|
||||||
"\nbindir = " ++ show flat_bindir ++
|
|
||||||
- "\nlibdir = " ++ show flat_libdir ++
|
|
||||||
- "\ndynlibdir = " ++ show flat_dynlibdir ++
|
|
||||||
- "\ndatadir = " ++ show flat_datadir ++
|
|
||||||
- "\nlibexecdir = " ++ show flat_libexecdir ++
|
|
||||||
- "\nsysconfdir = " ++ show flat_sysconfdir ++
|
|
||||||
"\n"++
|
|
||||||
- "\ngetBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"++
|
|
||||||
+ "\ngetBinDir :: IO FilePath\n"++
|
|
||||||
"getBinDir = "++mkGetEnvOr "bindir" "return bindir"++"\n"++
|
|
||||||
- "getLibDir = "++mkGetEnvOr "libdir" "return libdir"++"\n"++
|
|
||||||
- "getDynLibDir = "++mkGetEnvOr "dynlibdir" "return dynlibdir"++"\n"++
|
|
||||||
- "getDataDir = "++mkGetEnvOr "datadir" "return datadir"++"\n"++
|
|
||||||
- "getLibexecDir = "++mkGetEnvOr "libexecdir" "return libexecdir"++"\n"++
|
|
||||||
- "getSysconfDir = "++mkGetEnvOr "sysconfdir" "return sysconfdir"++"\n"++
|
|
||||||
- "\n"++
|
|
||||||
- "getDataFileName :: FilePath -> IO FilePath\n"++
|
|
||||||
- "getDataFileName name = do\n"++
|
|
||||||
- " dir <- getDataDir\n"++
|
|
||||||
- " return (dir ++ "++path_sep++" ++ name)\n"
|
|
||||||
+ absBody ++ "\n"++
|
|
||||||
+ (if shouldEmitDataDir then
|
|
||||||
+ "getDataFileName :: FilePath -> IO FilePath\n"++
|
|
||||||
+ "getDataFileName name = do\n"++
|
|
||||||
+ " dir <- getDataDir\n"++
|
|
||||||
+ " return (dir ++ "++path_sep++" ++ name)\n"
|
|
||||||
+ else "\n")
|
|
||||||
| otherwise =
|
|
||||||
"\nprefix, bindirrel :: FilePath" ++
|
|
||||||
"\nprefix = " ++ show flat_prefix ++
|
|
|
@ -1,602 +0,0 @@
|
||||||
This patch is based on https://github.com/sternenseemann/cabal/compare/982646d67b95b32813b89ab5d2d2f4d4dc03fb2b..7c49047f253e1f128e2df356400ec5da6f11066b
|
|
||||||
and has been postprocessed with `filterdiff --strip=1 --addoldprefix=a/libraries/Cabal/ --addnewprefix=b/libraries/Cabal/`.
|
|
||||||
Note that the base for the diff is not the Cabal 3.6.3.0 release tag, but
|
|
||||||
982646d67b95b32813b89ab5d2d2f4d4dc03fb2b which is obtained by applying
|
|
||||||
https://github.com/haskell/cabal/commit/6c796218c92f93c95e94d5ec2d077f6956f68e98
|
|
||||||
on top of said release tag. That patch is applied to all our GHCs in the 9.2 series.
|
|
||||||
|
|
||||||
Reasoning and explanation of the patch can be found in the comment in the diff for PathsModule.hs below.
|
|
||||||
|
|
||||||
diffCabal/src/Distribution/Simple/Build/PathsModule.hs b/Cabal/src/Distribution/Simple/Build/PathsModule.hs
|
|
||||||
index b2be7e1a8..9b63e9850 100644
|
|
||||||
--- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule.hs
|
|
||||||
+++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule.hs
|
|
||||||
@@ -46,6 +46,7 @@ generatePathsModule pkg_descr lbi clbi = Z.render Z.Z
|
|
||||||
, Z.zIsWindows = isWindows
|
|
||||||
, Z.zIsI386 = buildArch == I386
|
|
||||||
, Z.zIsX8664 = buildArch == X86_64
|
|
||||||
+ , Z.zOr = (||)
|
|
||||||
, Z.zNot = not
|
|
||||||
, Z.zManglePkgName = showPkgName
|
|
||||||
|
|
||||||
@@ -56,8 +57,112 @@ generatePathsModule pkg_descr lbi clbi = Z.render Z.Z
|
|
||||||
, Z.zDatadir = zDatadir
|
|
||||||
, Z.zLibexecdir = zLibexecdir
|
|
||||||
, Z.zSysconfdir = zSysconfdir
|
|
||||||
+
|
|
||||||
+ -- Sadly we can't be cleverer about this – we can't have literals in the template
|
|
||||||
+ , Z.zShouldEmitDataDir = shouldEmit "DataDir"
|
|
||||||
+ , Z.zShouldEmitLibDir = shouldEmit "LibDir"
|
|
||||||
+ , Z.zShouldEmitDynLibDir = shouldEmit "DynLibDir"
|
|
||||||
+ , Z.zShouldEmitLibexecDir = shouldEmit "LibexecDir"
|
|
||||||
+ , Z.zShouldEmitSysconfDir = shouldEmit "SysconfDir"
|
|
||||||
+
|
|
||||||
+ , Z.zWarning = zWarning
|
|
||||||
+ , Z.zShouldEmitWarning = zShouldEmitWarning
|
|
||||||
}
|
|
||||||
where
|
|
||||||
+ -- GHC's NCG backend for aarch64-darwin does not support link-time dead code
|
|
||||||
+ -- elimination to the extent that NCG does for other targets. Consequently,
|
|
||||||
+ -- we struggle with unnecessarily retained store path references due to the
|
|
||||||
+ -- use of `Paths_*` modules – even if `getLibDir` is not used, it'll end up
|
|
||||||
+ -- in the final library or executables we build.
|
|
||||||
+ --
|
|
||||||
+ -- When using a different output for the executables and library, this
|
|
||||||
+ -- becomes more sinister: The library will contain a reference to the bin
|
|
||||||
+ -- output and itself due to `getLibDir` and `getBinDir`, but the executables
|
|
||||||
+ -- will do so, too. Either due to linking dynamically or because the library
|
|
||||||
+ -- is linked statically into the executable and retains those references.
|
|
||||||
+ -- Since Nix disallows cyclical references between two outputs, it becomes
|
|
||||||
+ -- impossible to use the `Paths_*` module and a separate `bin` output for
|
|
||||||
+ -- aarch64-darwin.
|
|
||||||
+ --
|
|
||||||
+ -- The solution we have resorted to for now, is to trim the `Paths_*` module
|
|
||||||
+ -- dynamically depending on what references *could* be used without causing
|
|
||||||
+ -- a cyclical reference. That has the effect that any code that would not
|
|
||||||
+ -- cause a cyclical reference with dead code elimination will compile and
|
|
||||||
+ -- work for aarch64-darwin. If the code would use a `get*Dir` function that
|
|
||||||
+ -- has been omitted, this would indicate that the code would have caused a
|
|
||||||
+ -- cyclical reference anyways.
|
|
||||||
+ --
|
|
||||||
+ -- The logic for this makes some pretty big assumptions about installation
|
|
||||||
+ -- prefixes that probably only hold fully in nixpkgs with
|
|
||||||
+ -- `haskellPackages.mkDerivation`. Simple uses outside nixpkgs that have
|
|
||||||
+ -- everything below the same prefix should continue to work as expected,
|
|
||||||
+ -- though.
|
|
||||||
+ --
|
|
||||||
+ -- We assume the following:
|
|
||||||
+ --
|
|
||||||
+ -- - flat_prefix is `$out`.
|
|
||||||
+ -- - flat_libdir etc. are always below `$out`.
|
|
||||||
+ --
|
|
||||||
+ -- Since in the normal case due to static linking `$bin` and `$out` will
|
|
||||||
+ -- have the same references in libraries/executables, we need to either
|
|
||||||
+ -- prevent usage of `getBinDir` or `getLibDir` to break the cycle in case
|
|
||||||
+ -- `flat_bindir` is not below `$out`. We have decided to always allow usage
|
|
||||||
+ -- of `getBinDir`, so `getLibDir` gets dropped if a separate `bin` output is
|
|
||||||
+ -- used. This has the simple reason that `$out` which contains `flat_libdir`
|
|
||||||
+ -- tends to be quite big – we would like to have a `bin` output that doesn't
|
|
||||||
+ -- require keeping that around.
|
|
||||||
+ pathEmittable :: FilePath -> Bool
|
|
||||||
+ pathEmittable p
|
|
||||||
+ -- If the executable installation target is below `$out` the reference
|
|
||||||
+ -- cycle is within a single output (since libs are installed to `$out`)
|
|
||||||
+ -- and thus unproblematic. We can use any and all `get*Dir` functions.
|
|
||||||
+ | flat_prefix `isPrefixOf` flat_bindir = True
|
|
||||||
+ -- Otherwise, we need to disallow all `get*Dir` functions that would cause
|
|
||||||
+ -- a reference to `$out` which contains the libraries that would in turn
|
|
||||||
+ -- reference `$bin`. This always include `flat_libdir` and friends, but
|
|
||||||
+ -- can also include `flat_datadir` if no separate output for data files is
|
|
||||||
+ -- used.
|
|
||||||
+ | otherwise = not (flat_prefix `isPrefixOf` p)
|
|
||||||
+
|
|
||||||
+ -- This list maps the "name" of the directory to whether we want to include
|
|
||||||
+ -- it in the `Paths_*` module or not. `shouldEmit` performs a lookup in this.
|
|
||||||
+ dirs :: [(String, Bool)]
|
|
||||||
+ dirs =
|
|
||||||
+ map
|
|
||||||
+ (\(name, path) -> (name, pathEmittable path))
|
|
||||||
+ [ ("LibDir", flat_libdir)
|
|
||||||
+ , ("DynLibDir", flat_dynlibdir)
|
|
||||||
+ , ("DataDir", flat_datadir)
|
|
||||||
+ , ("LibexecDir", flat_libexecdir)
|
|
||||||
+ , ("SysconfDir", flat_sysconfdir)
|
|
||||||
+ ]
|
|
||||||
+
|
|
||||||
+ shouldEmit :: String -> Bool
|
|
||||||
+ shouldEmit name =
|
|
||||||
+ case lookup name dirs of
|
|
||||||
+ Just b -> b
|
|
||||||
+ Nothing -> error "panic! BUG in Cabal Paths_ patch for aarch64-darwin, report this at https://github.com/nixos/nixpkgs/issues"
|
|
||||||
+
|
|
||||||
+ -- This is a comma separated list of all functions that have been omitted.
|
|
||||||
+ -- This is included in a GHC warning which will be attached to the `Paths_*`
|
|
||||||
+ -- module in case we are dropping any `get*Dir` functions that would
|
|
||||||
+ -- normally exist.
|
|
||||||
+ --
|
|
||||||
+ -- TODO: getDataFileName is not accounted for at the moment.
|
|
||||||
+ omittedFunctions :: String
|
|
||||||
+ omittedFunctions =
|
|
||||||
+ intercalate ", "
|
|
||||||
+ $ map (("get" ++) . fst)
|
|
||||||
+ $ filter (not . snd) dirs
|
|
||||||
+
|
|
||||||
+ zWarning :: String
|
|
||||||
+ zWarning =
|
|
||||||
+ show $
|
|
||||||
+ "The following functions have been omitted by a nixpkgs-specific patch to Cabal: "
|
|
||||||
+ ++ omittedFunctions
|
|
||||||
+ zShouldEmitWarning :: Bool
|
|
||||||
+ zShouldEmitWarning = any (not . snd) dirs
|
|
||||||
+
|
|
||||||
supports_cpp = supports_language_pragma
|
|
||||||
supports_rebindable_syntax = ghc_newer_than (mkVersion [7,0,1])
|
|
||||||
supports_language_pragma = ghc_newer_than (mkVersion [6,6,1])
|
|
||||||
diffCabal/src/Distribution/Simple/Build/PathsModule/Z.hs b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
|
|
||||||
index 6488ea061..a6cdc8e31 100644
|
|
||||||
--- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
|
|
||||||
+++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
|
|
||||||
@@ -18,6 +18,14 @@ data Z
|
|
||||||
zDatadir :: FilePath,
|
|
||||||
zLibexecdir :: FilePath,
|
|
||||||
zSysconfdir :: FilePath,
|
|
||||||
+ zShouldEmitLibDir :: Bool,
|
|
||||||
+ zShouldEmitDynLibDir :: Bool,
|
|
||||||
+ zShouldEmitLibexecDir :: Bool,
|
|
||||||
+ zShouldEmitDataDir :: Bool,
|
|
||||||
+ zShouldEmitSysconfDir :: Bool,
|
|
||||||
+ zShouldEmitWarning :: Bool,
|
|
||||||
+ zWarning :: String,
|
|
||||||
+ zOr :: (Bool -> Bool -> Bool),
|
|
||||||
zNot :: (Bool -> Bool),
|
|
||||||
zManglePkgName :: (PackageName -> String)}
|
|
||||||
deriving Generic
|
|
||||||
@@ -45,10 +53,51 @@ render z_root = execWriter $ do
|
|
||||||
tell "{-# OPTIONS_GHC -w #-}\n"
|
|
||||||
tell "module Paths_"
|
|
||||||
tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
- tell " (\n"
|
|
||||||
+ tell "\n"
|
|
||||||
+ tell " "
|
|
||||||
+ if (zShouldEmitWarning z_root)
|
|
||||||
+ then do
|
|
||||||
+ tell "{-# WARNING "
|
|
||||||
+ tell (zWarning z_root)
|
|
||||||
+ tell " #-}"
|
|
||||||
+ return ()
|
|
||||||
+ else do
|
|
||||||
+ return ()
|
|
||||||
+ tell "\n"
|
|
||||||
+ tell " (\n"
|
|
||||||
tell " version,\n"
|
|
||||||
- tell " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n"
|
|
||||||
- tell " getDataFileName, getSysconfDir\n"
|
|
||||||
+ tell " getBinDir,\n"
|
|
||||||
+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitLibDir z_root))
|
|
||||||
+ then do
|
|
||||||
+ tell " getLibDir,\n"
|
|
||||||
+ return ()
|
|
||||||
+ else do
|
|
||||||
+ return ()
|
|
||||||
+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDynLibDir z_root))
|
|
||||||
+ then do
|
|
||||||
+ tell " getDynLibDir,\n"
|
|
||||||
+ return ()
|
|
||||||
+ else do
|
|
||||||
+ return ()
|
|
||||||
+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitLibexecDir z_root))
|
|
||||||
+ then do
|
|
||||||
+ tell " getLibexecDir,\n"
|
|
||||||
+ return ()
|
|
||||||
+ else do
|
|
||||||
+ return ()
|
|
||||||
+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDataDir z_root))
|
|
||||||
+ then do
|
|
||||||
+ tell " getDataFileName,\n"
|
|
||||||
+ tell " getDataDir,\n"
|
|
||||||
+ return ()
|
|
||||||
+ else do
|
|
||||||
+ return ()
|
|
||||||
+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitSysconfDir z_root))
|
|
||||||
+ then do
|
|
||||||
+ tell " getSysconfDir\n"
|
|
||||||
+ return ()
|
|
||||||
+ else do
|
|
||||||
+ return ()
|
|
||||||
tell " ) where\n"
|
|
||||||
tell "\n"
|
|
||||||
if (zNot z_root (zAbsolute z_root))
|
|
||||||
@@ -97,12 +146,15 @@ render z_root = execWriter $ do
|
|
||||||
tell (zVersionDigits z_root)
|
|
||||||
tell " []\n"
|
|
||||||
tell "\n"
|
|
||||||
- tell "getDataFileName :: FilePath -> IO FilePath\n"
|
|
||||||
- tell "getDataFileName name = do\n"
|
|
||||||
- tell " dir <- getDataDir\n"
|
|
||||||
- tell " return (dir `joinFileName` name)\n"
|
|
||||||
- tell "\n"
|
|
||||||
- tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"
|
|
||||||
+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDataDir z_root))
|
|
||||||
+ then do
|
|
||||||
+ tell "getDataFileName :: FilePath -> IO FilePath\n"
|
|
||||||
+ tell "getDataFileName name = do\n"
|
|
||||||
+ tell " dir <- getDataDir\n"
|
|
||||||
+ tell " return (dir `joinFileName` name)\n"
|
|
||||||
+ return ()
|
|
||||||
+ else do
|
|
||||||
+ return ()
|
|
||||||
tell "\n"
|
|
||||||
let
|
|
||||||
z_var0_function_defs = do
|
|
||||||
@@ -130,6 +182,7 @@ render z_root = execWriter $ do
|
|
||||||
tell "\n"
|
|
||||||
if (zRelocatable z_root)
|
|
||||||
then do
|
|
||||||
+ tell "\n"
|
|
||||||
tell "\n"
|
|
||||||
tell "getPrefixDirReloc :: FilePath -> IO FilePath\n"
|
|
||||||
tell "getPrefixDirReloc dirRel = do\n"
|
|
||||||
@@ -139,31 +192,37 @@ render z_root = execWriter $ do
|
|
||||||
tell (zBindir z_root)
|
|
||||||
tell ") `joinFileName` dirRel)\n"
|
|
||||||
tell "\n"
|
|
||||||
+ tell "getBinDir :: IO FilePath\n"
|
|
||||||
tell "getBinDir = catchIO (getEnv \""
|
|
||||||
tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
tell "_bindir\") (\\_ -> getPrefixDirReloc $ "
|
|
||||||
tell (zBindir z_root)
|
|
||||||
tell ")\n"
|
|
||||||
+ tell "getLibDir :: IO FilePath\n"
|
|
||||||
tell "getLibDir = catchIO (getEnv \""
|
|
||||||
tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
tell "_libdir\") (\\_ -> getPrefixDirReloc $ "
|
|
||||||
tell (zLibdir z_root)
|
|
||||||
tell ")\n"
|
|
||||||
+ tell "getDynLibDir :: IO FilePath\n"
|
|
||||||
tell "getDynLibDir = catchIO (getEnv \""
|
|
||||||
tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
tell "_dynlibdir\") (\\_ -> getPrefixDirReloc $ "
|
|
||||||
tell (zDynlibdir z_root)
|
|
||||||
tell ")\n"
|
|
||||||
+ tell "getDataDir :: IO FilePath\n"
|
|
||||||
tell "getDataDir = catchIO (getEnv \""
|
|
||||||
tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
tell "_datadir\") (\\_ -> getPrefixDirReloc $ "
|
|
||||||
tell (zDatadir z_root)
|
|
||||||
tell ")\n"
|
|
||||||
+ tell "getLibexecDir :: IO FilePath\n"
|
|
||||||
tell "getLibexecDir = catchIO (getEnv \""
|
|
||||||
tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
tell "_libexecdir\") (\\_ -> getPrefixDirReloc $ "
|
|
||||||
tell (zLibexecdir z_root)
|
|
||||||
tell ")\n"
|
|
||||||
+ tell "getSysconfDir :: IO FilePath\n"
|
|
||||||
tell "getSysconfDir = catchIO (getEnv \""
|
|
||||||
tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
tell "_sysconfdir\") (\\_ -> getPrefixDirReloc $ "
|
|
||||||
@@ -177,72 +236,119 @@ render z_root = execWriter $ do
|
|
||||||
if (zAbsolute z_root)
|
|
||||||
then do
|
|
||||||
tell "\n"
|
|
||||||
- tell "bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath\n"
|
|
||||||
+ tell "bindir :: FilePath\n"
|
|
||||||
tell "bindir = "
|
|
||||||
tell (zBindir z_root)
|
|
||||||
tell "\n"
|
|
||||||
- tell "libdir = "
|
|
||||||
- tell (zLibdir z_root)
|
|
||||||
- tell "\n"
|
|
||||||
- tell "dynlibdir = "
|
|
||||||
- tell (zDynlibdir z_root)
|
|
||||||
+ tell "getBinDir :: IO FilePath\n"
|
|
||||||
+ tell "getBinDir = catchIO (getEnv \""
|
|
||||||
+ tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
+ tell "_bindir\") (\\_ -> return bindir)\n"
|
|
||||||
tell "\n"
|
|
||||||
- tell "datadir = "
|
|
||||||
- tell (zDatadir z_root)
|
|
||||||
+ if (zShouldEmitLibDir z_root)
|
|
||||||
+ then do
|
|
||||||
+ tell "libdir :: FilePath\n"
|
|
||||||
+ tell "libdir = "
|
|
||||||
+ tell (zLibdir z_root)
|
|
||||||
+ tell "\n"
|
|
||||||
+ tell "getLibDir :: IO FilePath\n"
|
|
||||||
+ tell "getLibDir = catchIO (getEnv \""
|
|
||||||
+ tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
+ tell "_libdir\") (\\_ -> return libdir)\n"
|
|
||||||
+ return ()
|
|
||||||
+ else do
|
|
||||||
+ return ()
|
|
||||||
tell "\n"
|
|
||||||
- tell "libexecdir = "
|
|
||||||
- tell (zLibexecdir z_root)
|
|
||||||
+ if (zShouldEmitDynLibDir z_root)
|
|
||||||
+ then do
|
|
||||||
+ tell "dynlibdir :: FilePath\n"
|
|
||||||
+ tell "dynlibdir = "
|
|
||||||
+ tell (zDynlibdir z_root)
|
|
||||||
+ tell "\n"
|
|
||||||
+ tell "getDynLibDir :: IO FilePath\n"
|
|
||||||
+ tell "getDynLibDir = catchIO (getEnv \""
|
|
||||||
+ tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
+ tell "_dynlibdir\") (\\_ -> return dynlibdir)\n"
|
|
||||||
+ return ()
|
|
||||||
+ else do
|
|
||||||
+ return ()
|
|
||||||
tell "\n"
|
|
||||||
- tell "sysconfdir = "
|
|
||||||
- tell (zSysconfdir z_root)
|
|
||||||
+ if (zShouldEmitDataDir z_root)
|
|
||||||
+ then do
|
|
||||||
+ tell "datadir :: FilePath\n"
|
|
||||||
+ tell "datadir = "
|
|
||||||
+ tell (zDatadir z_root)
|
|
||||||
+ tell "\n"
|
|
||||||
+ tell "getDataDir :: IO FilePath\n"
|
|
||||||
+ tell "getDataDir = catchIO (getEnv \""
|
|
||||||
+ tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
+ tell "_datadir\") (\\_ -> return datadir)\n"
|
|
||||||
+ return ()
|
|
||||||
+ else do
|
|
||||||
+ return ()
|
|
||||||
tell "\n"
|
|
||||||
+ if (zShouldEmitLibexecDir z_root)
|
|
||||||
+ then do
|
|
||||||
+ tell "libexecdir :: FilePath\n"
|
|
||||||
+ tell "libexecdir = "
|
|
||||||
+ tell (zLibexecdir z_root)
|
|
||||||
+ tell "\n"
|
|
||||||
+ tell "getLibexecDir :: IO FilePath\n"
|
|
||||||
+ tell "getLibexecDir = catchIO (getEnv \""
|
|
||||||
+ tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
+ tell "_libexecdir\") (\\_ -> return libexecdir)\n"
|
|
||||||
+ return ()
|
|
||||||
+ else do
|
|
||||||
+ return ()
|
|
||||||
tell "\n"
|
|
||||||
- tell "getBinDir = catchIO (getEnv \""
|
|
||||||
- tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
- tell "_bindir\") (\\_ -> return bindir)\n"
|
|
||||||
- tell "getLibDir = catchIO (getEnv \""
|
|
||||||
- tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
- tell "_libdir\") (\\_ -> return libdir)\n"
|
|
||||||
- tell "getDynLibDir = catchIO (getEnv \""
|
|
||||||
- tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
- tell "_dynlibdir\") (\\_ -> return dynlibdir)\n"
|
|
||||||
- tell "getDataDir = catchIO (getEnv \""
|
|
||||||
- tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
- tell "_datadir\") (\\_ -> return datadir)\n"
|
|
||||||
- tell "getLibexecDir = catchIO (getEnv \""
|
|
||||||
- tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
- tell "_libexecdir\") (\\_ -> return libexecdir)\n"
|
|
||||||
- tell "getSysconfDir = catchIO (getEnv \""
|
|
||||||
- tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
- tell "_sysconfdir\") (\\_ -> return sysconfdir)\n"
|
|
||||||
+ if (zShouldEmitSysconfDir z_root)
|
|
||||||
+ then do
|
|
||||||
+ tell "sysconfdir :: FilePath\n"
|
|
||||||
+ tell "sysconfdir = "
|
|
||||||
+ tell (zSysconfdir z_root)
|
|
||||||
+ tell "\n"
|
|
||||||
+ tell "getSysconfDir :: IO FilePath\n"
|
|
||||||
+ tell "getSysconfDir = catchIO (getEnv \""
|
|
||||||
+ tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
+ tell "_sysconfdir\") (\\_ -> return sysconfdir)\n"
|
|
||||||
+ return ()
|
|
||||||
+ else do
|
|
||||||
+ return ()
|
|
||||||
tell "\n"
|
|
||||||
return ()
|
|
||||||
else do
|
|
||||||
if (zIsWindows z_root)
|
|
||||||
then do
|
|
||||||
+ tell "\n"
|
|
||||||
tell "\n"
|
|
||||||
tell "prefix :: FilePath\n"
|
|
||||||
tell "prefix = "
|
|
||||||
tell (zPrefix z_root)
|
|
||||||
tell "\n"
|
|
||||||
tell "\n"
|
|
||||||
+ tell "getBinDir :: IO FilePath\n"
|
|
||||||
tell "getBinDir = getPrefixDirRel $ "
|
|
||||||
tell (zBindir z_root)
|
|
||||||
tell "\n"
|
|
||||||
+ tell "getLibDir :: IO FilePath\n"
|
|
||||||
tell "getLibDir = "
|
|
||||||
tell (zLibdir z_root)
|
|
||||||
tell "\n"
|
|
||||||
+ tell "getDynLibDir :: IO FilePath\n"
|
|
||||||
tell "getDynLibDir = "
|
|
||||||
tell (zDynlibdir z_root)
|
|
||||||
tell "\n"
|
|
||||||
+ tell "getDataDir :: IO FilePath\n"
|
|
||||||
tell "getDataDir = catchIO (getEnv \""
|
|
||||||
tell (zManglePkgName z_root (zPackageName z_root))
|
|
||||||
tell "_datadir\") (\\_ -> "
|
|
||||||
tell (zDatadir z_root)
|
|
||||||
tell ")\n"
|
|
||||||
+ tell "getLibexecDir :: IO FilePath\n"
|
|
||||||
tell "getLibexecDir = "
|
|
||||||
tell (zLibexecdir z_root)
|
|
||||||
tell "\n"
|
|
||||||
+ tell "getSysconfDir :: IO FilePath\n"
|
|
||||||
tell "getSysconfDir = "
|
|
||||||
tell (zSysconfdir z_root)
|
|
||||||
tell "\n"
|
|
||||||
diffcabal-dev-scripts/src/GenPathsModule.hs b/cabal-dev-scripts/src/GenPathsModule.hs
|
|
||||||
index e4b930635..9b978f284 100644
|
|
||||||
--- a/libraries/Cabal/cabal-dev-scripts/src/GenPathsModule.hs
|
|
||||||
+++ b/libraries/Cabal/cabal-dev-scripts/src/GenPathsModule.hs
|
|
||||||
@@ -41,6 +41,16 @@ $(capture "decls" [d|
|
|
||||||
, zLibexecdir :: FilePath
|
|
||||||
, zSysconfdir :: FilePath
|
|
||||||
|
|
||||||
+ , zShouldEmitLibDir :: Bool
|
|
||||||
+ , zShouldEmitDynLibDir :: Bool
|
|
||||||
+ , zShouldEmitLibexecDir :: Bool
|
|
||||||
+ , zShouldEmitDataDir :: Bool
|
|
||||||
+ , zShouldEmitSysconfDir :: Bool
|
|
||||||
+
|
|
||||||
+ , zShouldEmitWarning :: Bool
|
|
||||||
+ , zWarning :: String
|
|
||||||
+
|
|
||||||
+ , zOr :: Bool -> Bool -> Bool
|
|
||||||
, zNot :: Bool -> Bool
|
|
||||||
, zManglePkgName :: PackageName -> String
|
|
||||||
}
|
|
||||||
difftemplates/Paths_pkg.template.hs b/templates/Paths_pkg.template.hs
|
|
||||||
index 6bc6b7875..aa90a9382 100644
|
|
||||||
--- a/libraries/Cabal/templates/Paths_pkg.template.hs
|
|
||||||
+++ b/libraries/Cabal/templates/Paths_pkg.template.hs
|
|
||||||
@@ -9,10 +9,31 @@
|
|
||||||
{% endif %}
|
|
||||||
{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}
|
|
||||||
{-# OPTIONS_GHC -w #-}
|
|
||||||
-module Paths_{{ manglePkgName packageName }} (
|
|
||||||
+module Paths_{{ manglePkgName packageName }}
|
|
||||||
+ {% if shouldEmitWarning %}{-# WARNING {{ warning }} #-}{% endif %}
|
|
||||||
+ (
|
|
||||||
version,
|
|
||||||
- getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,
|
|
||||||
- getDataFileName, getSysconfDir
|
|
||||||
+ getBinDir,
|
|
||||||
+{# We only care about the absolute case for our emit logic, since only in this
|
|
||||||
+ case references are incurred. We are not going to hit isWindows and relocatable
|
|
||||||
+ has no absolute references to begin with.
|
|
||||||
+#}
|
|
||||||
+{% if or (not absolute) shouldEmitLibDir %}
|
|
||||||
+ getLibDir,
|
|
||||||
+{% endif %}
|
|
||||||
+{% if or (not absolute) shouldEmitDynLibDir %}
|
|
||||||
+ getDynLibDir,
|
|
||||||
+{% endif %}
|
|
||||||
+{% if or (not absolute) shouldEmitLibexecDir %}
|
|
||||||
+ getLibexecDir,
|
|
||||||
+{% endif %}
|
|
||||||
+{% if or (not absolute) shouldEmitDataDir %}
|
|
||||||
+ getDataFileName,
|
|
||||||
+ getDataDir,
|
|
||||||
+{% endif %}
|
|
||||||
+{% if or (not absolute) shouldEmitSysconfDir %}
|
|
||||||
+ getSysconfDir
|
|
||||||
+{% endif %}
|
|
||||||
) where
|
|
||||||
|
|
||||||
{% if not absolute %}
|
|
||||||
@@ -51,12 +72,12 @@ catchIO = Exception.catch
|
|
||||||
version :: Version
|
|
||||||
version = Version {{ versionDigits }} []
|
|
||||||
|
|
||||||
+{% if or (not absolute) shouldEmitDataDir %}
|
|
||||||
getDataFileName :: FilePath -> IO FilePath
|
|
||||||
getDataFileName name = do
|
|
||||||
dir <- getDataDir
|
|
||||||
return (dir `joinFileName` name)
|
|
||||||
-
|
|
||||||
-getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath
|
|
||||||
+{% endif %}
|
|
||||||
|
|
||||||
{% defblock function_defs %}
|
|
||||||
minusFileName :: FilePath -> String -> FilePath
|
|
||||||
@@ -85,48 +106,93 @@ splitFileName p = (reverse (path2++drive), reverse fname)
|
|
||||||
|
|
||||||
{% if relocatable %}
|
|
||||||
|
|
||||||
+{# Relocatable can not incur any absolute references, so we can ignore it.
|
|
||||||
+ Additionally, --enable-relocatable is virtually useless in Nix builds
|
|
||||||
+#}
|
|
||||||
+
|
|
||||||
getPrefixDirReloc :: FilePath -> IO FilePath
|
|
||||||
getPrefixDirReloc dirRel = do
|
|
||||||
exePath <- getExecutablePath
|
|
||||||
let (dir,_) = splitFileName exePath
|
|
||||||
return ((dir `minusFileName` {{ bindir }}) `joinFileName` dirRel)
|
|
||||||
|
|
||||||
+getBinDir :: IO FilePath
|
|
||||||
getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\_ -> getPrefixDirReloc $ {{ bindir }})
|
|
||||||
+getLibDir :: IO FilePath
|
|
||||||
getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> getPrefixDirReloc $ {{ libdir }})
|
|
||||||
+getDynLibDir :: IO FilePath
|
|
||||||
getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> getPrefixDirReloc $ {{ dynlibdir }})
|
|
||||||
+getDataDir :: IO FilePath
|
|
||||||
getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> getPrefixDirReloc $ {{ datadir }})
|
|
||||||
+getLibexecDir :: IO FilePath
|
|
||||||
getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> getPrefixDirReloc $ {{ libexecdir }})
|
|
||||||
+getSysconfDir :: IO FilePath
|
|
||||||
getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> getPrefixDirReloc $ {{ sysconfdir }})
|
|
||||||
|
|
||||||
{% useblock function_defs %}
|
|
||||||
|
|
||||||
{% elif absolute %}
|
|
||||||
|
|
||||||
-bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath
|
|
||||||
+bindir :: FilePath
|
|
||||||
bindir = {{ bindir }}
|
|
||||||
-libdir = {{ libdir }}
|
|
||||||
-dynlibdir = {{ dynlibdir }}
|
|
||||||
-datadir = {{ datadir }}
|
|
||||||
-libexecdir = {{ libexecdir }}
|
|
||||||
-sysconfdir = {{ sysconfdir }}
|
|
||||||
-
|
|
||||||
+getBinDir :: IO FilePath
|
|
||||||
getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\_ -> return bindir)
|
|
||||||
+
|
|
||||||
+{% if shouldEmitLibDir %}
|
|
||||||
+libdir :: FilePath
|
|
||||||
+libdir = {{ libdir }}
|
|
||||||
+getLibDir :: IO FilePath
|
|
||||||
getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> return libdir)
|
|
||||||
+{% endif %}
|
|
||||||
+
|
|
||||||
+{% if shouldEmitDynLibDir %}
|
|
||||||
+dynlibdir :: FilePath
|
|
||||||
+dynlibdir = {{ dynlibdir }}
|
|
||||||
+getDynLibDir :: IO FilePath
|
|
||||||
getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> return dynlibdir)
|
|
||||||
+{% endif %}
|
|
||||||
+
|
|
||||||
+{% if shouldEmitDataDir %}
|
|
||||||
+datadir :: FilePath
|
|
||||||
+datadir = {{ datadir }}
|
|
||||||
+getDataDir :: IO FilePath
|
|
||||||
getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> return datadir)
|
|
||||||
+{% endif %}
|
|
||||||
+
|
|
||||||
+{% if shouldEmitLibexecDir %}
|
|
||||||
+libexecdir :: FilePath
|
|
||||||
+libexecdir = {{ libexecdir }}
|
|
||||||
+getLibexecDir :: IO FilePath
|
|
||||||
getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> return libexecdir)
|
|
||||||
+{% endif %}
|
|
||||||
+
|
|
||||||
+{% if shouldEmitSysconfDir %}
|
|
||||||
+sysconfdir :: FilePath
|
|
||||||
+sysconfdir = {{ sysconfdir }}
|
|
||||||
+getSysconfDir :: IO FilePath
|
|
||||||
getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> return sysconfdir)
|
|
||||||
+{% endif %}
|
|
||||||
|
|
||||||
{% elif isWindows %}
|
|
||||||
|
|
||||||
+{# We are only trying to fix the problem for aarch64-darwin with this patch,
|
|
||||||
+ so let's ignore Windows which we can reach via pkgsCross, for example.
|
|
||||||
+#}
|
|
||||||
+
|
|
||||||
prefix :: FilePath
|
|
||||||
prefix = {{ prefix }}
|
|
||||||
|
|
||||||
+getBinDir :: IO FilePath
|
|
||||||
getBinDir = getPrefixDirRel $ {{ bindir }}
|
|
||||||
+getLibDir :: IO FilePath
|
|
||||||
getLibDir = {{ libdir }}
|
|
||||||
+getDynLibDir :: IO FilePath
|
|
||||||
getDynLibDir = {{ dynlibdir }}
|
|
||||||
+getDataDir :: IO FilePath
|
|
||||||
getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> {{ datadir }})
|
|
||||||
+getLibexecDir :: IO FilePath
|
|
||||||
getLibexecDir = {{ libexecdir }}
|
|
||||||
+getSysconfDir :: IO FilePath
|
|
||||||
getSysconfDir = {{ sysconfdir }}
|
|
||||||
|
|
||||||
getPrefixDirRel :: FilePath -> IO FilePath
|
|
|
@ -1,544 +0,0 @@
|
||||||
{ version
|
|
||||||
, rev ? null
|
|
||||||
, sha256
|
|
||||||
, url ?
|
|
||||||
if rev != null
|
|
||||||
then "https://gitlab.haskell.org/ghc/ghc.git"
|
|
||||||
else "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz"
|
|
||||||
, postFetch ? null
|
|
||||||
}:
|
|
||||||
|
|
||||||
{ lib
|
|
||||||
, stdenv
|
|
||||||
, pkgsBuildTarget
|
|
||||||
, pkgsHostTarget
|
|
||||||
, targetPackages
|
|
||||||
|
|
||||||
# build-tools
|
|
||||||
, bootPkgs
|
|
||||||
, autoconf
|
|
||||||
, automake
|
|
||||||
, coreutils
|
|
||||||
, fetchpatch
|
|
||||||
, fetchurl
|
|
||||||
, fetchgit
|
|
||||||
, perl
|
|
||||||
, python3
|
|
||||||
, m4
|
|
||||||
, sphinx
|
|
||||||
, xattr
|
|
||||||
, autoSignDarwinBinariesHook
|
|
||||||
, bash
|
|
||||||
|
|
||||||
, libiconv ? null, ncurses
|
|
||||||
, glibcLocales ? null
|
|
||||||
|
|
||||||
, # GHC can be built with system libffi or a bundled one.
|
|
||||||
libffi ? null
|
|
||||||
|
|
||||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
|
||||||
|| stdenv.targetPlatform.isPower
|
|
||||||
|| stdenv.targetPlatform.isSparc
|
|
||||||
|| stdenv.targetPlatform.isAarch64
|
|
||||||
|| stdenv.targetPlatform.isGhcjs)
|
|
||||||
, # LLVM is conceptually a run-time-only dependency, but for
|
|
||||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
|
||||||
# build-time dependency too.
|
|
||||||
buildTargetLlvmPackages
|
|
||||||
, llvmPackages
|
|
||||||
|
|
||||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
|
||||||
# bignum backend instead of the faster but GPLed gmp backend.
|
|
||||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp
|
|
||||||
&& lib.meta.availableOn stdenv.targetPlatform gmp)
|
|
||||||
|| stdenv.targetPlatform.isGhcjs
|
|
||||||
, gmp
|
|
||||||
|
|
||||||
, # If enabled, use -fPIC when compiling static libs.
|
|
||||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
|
||||||
|
|
||||||
, enableProfiledLibs ? true
|
|
||||||
|
|
||||||
, # Whether to build dynamic libs for the standard library (on the target
|
|
||||||
# platform). Static libs are always built.
|
|
||||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic && !isGhcjs
|
|
||||||
|
|
||||||
, # Whether to build terminfo.
|
|
||||||
enableTerminfo ? !(stdenv.targetPlatform.isWindows
|
|
||||||
|| stdenv.targetPlatform.isGhcjs)
|
|
||||||
|
|
||||||
, # Libdw.c only supports x86_64, i686 and s390x as of 2022-08-04
|
|
||||||
enableDwarf ? (stdenv.targetPlatform.isx86 ||
|
|
||||||
(stdenv.targetPlatform.isS390 && stdenv.targetPlatform.is64bit)) &&
|
|
||||||
lib.meta.availableOn stdenv.hostPlatform elfutils &&
|
|
||||||
lib.meta.availableOn stdenv.targetPlatform elfutils &&
|
|
||||||
# HACK: elfutils is marked as broken on static platforms
|
|
||||||
# which availableOn can't tell.
|
|
||||||
!stdenv.targetPlatform.isStatic &&
|
|
||||||
!stdenv.hostPlatform.isStatic
|
|
||||||
, elfutils
|
|
||||||
|
|
||||||
, # What flavour to build. Flavour string may contain a flavour and flavour
|
|
||||||
# transformers as accepted by hadrian.
|
|
||||||
ghcFlavour ?
|
|
||||||
let
|
|
||||||
# TODO(@sternenseemann): does using the static flavour make sense?
|
|
||||||
baseFlavour = "release";
|
|
||||||
# Note: in case hadrian's flavour transformers cease being expressive
|
|
||||||
# enough for us, we'll need to resort to defining a "nixpkgs" flavour
|
|
||||||
# in hadrianUserSettings and using that instead.
|
|
||||||
transformers =
|
|
||||||
lib.optionals useLLVM [ "llvm" ]
|
|
||||||
++ lib.optionals (!enableShared) [
|
|
||||||
"no_dynamic_libs"
|
|
||||||
"no_dynamic_ghc"
|
|
||||||
]
|
|
||||||
++ lib.optionals (!enableProfiledLibs) [ "no_profiled_libs" ]
|
|
||||||
# While split sections are now enabled by default in ghc 8.8 for windows,
|
|
||||||
# they seem to lead to `too many sections` errors when building base for
|
|
||||||
# profiling.
|
|
||||||
++ lib.optionals (!stdenv.targetPlatform.isWindows) [ "split_sections" ]
|
|
||||||
;
|
|
||||||
in
|
|
||||||
baseFlavour + lib.concatMapStrings (t: "+${t}") transformers
|
|
||||||
|
|
||||||
, # Contents of the UserSettings.hs file to use when compiling hadrian.
|
|
||||||
hadrianUserSettings ? ''
|
|
||||||
module UserSettings (
|
|
||||||
userFlavours, userPackages, userDefaultFlavour,
|
|
||||||
verboseCommand, buildProgressColour, successColour, finalStage
|
|
||||||
) where
|
|
||||||
|
|
||||||
import Flavour.Type
|
|
||||||
import Expression
|
|
||||||
import {-# SOURCE #-} Settings.Default
|
|
||||||
|
|
||||||
-- no way to set this via the command line
|
|
||||||
finalStage :: Stage
|
|
||||||
finalStage = ${
|
|
||||||
# Always build the stage 2 compiler if possible. Note we can currently
|
|
||||||
# assume hostPlatform == buildPlatform.
|
|
||||||
# TODO(@sternenseemann): improve this condition when we can cross-compile GHC
|
|
||||||
if stdenv.hostPlatform.canExecute stdenv.targetPlatform
|
|
||||||
then "Stage2" # native compiler or “native” cross e.g. pkgsStatic
|
|
||||||
else "Stage1" # cross compiler
|
|
||||||
}
|
|
||||||
|
|
||||||
userDefaultFlavour :: String
|
|
||||||
userDefaultFlavour = "release"
|
|
||||||
|
|
||||||
userFlavours :: [Flavour]
|
|
||||||
userFlavours = []
|
|
||||||
|
|
||||||
-- Disable Colours
|
|
||||||
buildProgressColour :: BuildProgressColour
|
|
||||||
buildProgressColour = mkBuildProgressColour (Dull Reset)
|
|
||||||
successColour :: SuccessColour
|
|
||||||
successColour = mkSuccessColour (Dull Reset)
|
|
||||||
|
|
||||||
-- taken from src/UserSettings.hs unchanged, need to be there
|
|
||||||
userPackages :: [Package]
|
|
||||||
userPackages = []
|
|
||||||
verboseCommand :: Predicate
|
|
||||||
verboseCommand = do
|
|
||||||
verbosity <- expr getVerbosity
|
|
||||||
return $ verbosity >= Verbose
|
|
||||||
''
|
|
||||||
|
|
||||||
, ghcSrc ? (if rev != null then fetchgit else fetchurl) ({
|
|
||||||
inherit url sha256;
|
|
||||||
} // lib.optionalAttrs (rev != null) {
|
|
||||||
inherit rev;
|
|
||||||
} // lib.optionalAttrs (postFetch != null) {
|
|
||||||
inherit postFetch;
|
|
||||||
})
|
|
||||||
|
|
||||||
# GHC's build system hadrian built from the GHC-to-build's source tree
|
|
||||||
# using our bootstrap GHC.
|
|
||||||
, hadrian ? import ../hadrian/make-hadrian.nix { inherit bootPkgs lib; } {
|
|
||||||
ghcSrc = ghcSrc;
|
|
||||||
ghcVersion = version;
|
|
||||||
userSettings = hadrianUserSettings;
|
|
||||||
# Disable haddock generating pretty source listings to stay under 3GB on aarch64-linux
|
|
||||||
enableHyperlinkedSource =
|
|
||||||
# TODO(@sternenseemann): Disabling currently doesn't work with GHC >= 9.8
|
|
||||||
lib.versionAtLeast version "9.8" ||
|
|
||||||
!(stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux);
|
|
||||||
}
|
|
||||||
|
|
||||||
, # Whether to build sphinx documentation.
|
|
||||||
# TODO(@sternenseemann): Hadrian ignores the --docs flag if finalStage = Stage1
|
|
||||||
enableDocs ? (
|
|
||||||
# Docs disabled if we are building on musl because it's a large task to keep
|
|
||||||
# all `sphinx` dependencies building in this environment.
|
|
||||||
!stdenv.buildPlatform.isMusl
|
|
||||||
)
|
|
||||||
|
|
||||||
, # Whether to disable the large address space allocator
|
|
||||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
|
||||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
|
||||||
}:
|
|
||||||
|
|
||||||
assert !enableNativeBignum -> gmp != null;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
|
||||||
|
|
||||||
inherit (bootPkgs) ghc;
|
|
||||||
|
|
||||||
# TODO(@Ericson2314) Make unconditional
|
|
||||||
targetPrefix = lib.optionalString
|
|
||||||
(targetPlatform != hostPlatform)
|
|
||||||
"${targetPlatform.config}-";
|
|
||||||
|
|
||||||
hadrianSettings =
|
|
||||||
# -fexternal-dynamic-refs apparently (because it's not clear from the
|
|
||||||
# documentation) makes the GHC RTS able to load static libraries, which may
|
|
||||||
# be needed for TemplateHaskell. This solution was described in
|
|
||||||
# https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
|
||||||
lib.optionals enableRelocatedStaticLibs [
|
|
||||||
"*.*.ghc.*.opts += -fPIC -fexternal-dynamic-refs"
|
|
||||||
]
|
|
||||||
++ lib.optionals targetPlatform.useAndroidPrebuilt [
|
|
||||||
"*.*.ghc.c.opts += -optc-std=gnu99"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Splicer will pull out correct variations
|
|
||||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
|
||||||
++ lib.optionals (!targetPlatform.isGhcjs) [libffi]
|
|
||||||
# Bindist configure script fails w/o elfutils in linker search path
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/22081
|
|
||||||
++ lib.optional enableDwarf elfutils
|
|
||||||
++ lib.optional (!enableNativeBignum) gmp
|
|
||||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows && !targetPlatform.isGhcjs) libiconv;
|
|
||||||
|
|
||||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
|
||||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
|
||||||
toolsForTarget = [
|
|
||||||
(if targetPlatform.isGhcjs
|
|
||||||
then pkgsBuildTarget.emscripten
|
|
||||||
else pkgsBuildTarget.targetPackages.stdenv.cc)
|
|
||||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
|
||||||
|
|
||||||
targetCC = builtins.head toolsForTarget;
|
|
||||||
|
|
||||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
|
||||||
# derivation for certain tools depending on the platform.
|
|
||||||
bintoolsFor = {
|
|
||||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
|
||||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
|
||||||
# x86_64-darwin.
|
|
||||||
install_name_tool =
|
|
||||||
if stdenv.targetPlatform.isAarch64
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
# Same goes for strip.
|
|
||||||
strip =
|
|
||||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
|
||||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
|
||||||
then targetCC.bintools
|
|
||||||
else targetCC.bintools.bintools;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
|
||||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
|
||||||
# see #84670 and #49071 for more background.
|
|
||||||
useLdGold = targetPlatform.linker == "gold" ||
|
|
||||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
|
||||||
|
|
||||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
|
||||||
variantSuffix = lib.concatStrings [
|
|
||||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
|
||||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
|
||||||
];
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
|
||||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
|
||||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
|
||||||
assert !targetPlatform.isGhcjs -> targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
|
||||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
|
||||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
|
||||||
|
|
||||||
stdenv.mkDerivation ({
|
|
||||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
|
||||||
inherit version;
|
|
||||||
|
|
||||||
src = ghcSrc;
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
# Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129
|
|
||||||
(if lib.versionAtLeast version "9.8"
|
|
||||||
then ./docs-sphinx-7-ghc98.patch
|
|
||||||
else ./docs-sphinx-7.patch )
|
|
||||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
|
||||||
# Prevent the paths module from emitting symbols that we don't use
|
|
||||||
# when building with separate outputs.
|
|
||||||
#
|
|
||||||
# These cause problems as they're not eliminated by GHC's dead code
|
|
||||||
# elimination on aarch64-darwin. (see
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
|
||||||
./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch
|
|
||||||
];
|
|
||||||
|
|
||||||
postPatch = ''
|
|
||||||
patchShebangs --build .
|
|
||||||
'';
|
|
||||||
|
|
||||||
# GHC needs the locale configured during the Haddock phase.
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
|
|
||||||
# GHC is a bit confused on its cross terminology.
|
|
||||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
|
||||||
preConfigure = ''
|
|
||||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
|
||||||
export "''${env#TARGET_}=''${!env}"
|
|
||||||
done
|
|
||||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
|
||||||
# the *host* tools.
|
|
||||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
|
||||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
|
||||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
|
||||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
|
||||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
|
||||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
|
||||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
|
||||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
|
||||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
|
||||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
|
||||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
|
||||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
|
||||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
|
||||||
'' + lib.optionalString useLLVM ''
|
|
||||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
|
||||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
|
||||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
|
||||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
|
||||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
|
||||||
'' +
|
|
||||||
lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
|
|
||||||
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
|
|
||||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
||||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
||||||
|
|
||||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
|
||||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
|
||||||
''
|
|
||||||
# If we are not using release tarballs, some files need to be generated using
|
|
||||||
# the boot script.
|
|
||||||
+ lib.optionalString (rev != null) ''
|
|
||||||
echo ${version} > VERSION
|
|
||||||
echo ${rev} > GIT_COMMIT_ID
|
|
||||||
./boot
|
|
||||||
''
|
|
||||||
+ lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
|
||||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
|
||||||
'' + lib.optionalString targetPlatform.isMusl ''
|
|
||||||
echo "patching llvm-targets for musl targets..."
|
|
||||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
|
||||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
|
||||||
echo "(go go gadget sed)"
|
|
||||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
|
||||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
|
||||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
|
||||||
|
|
||||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
|
||||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
|
||||||
for x in configure aclocal.m4; do
|
|
||||||
substituteInPlace $x \
|
|
||||||
--replace '*-android*|*-gnueabi*)' \
|
|
||||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
|
||||||
done
|
|
||||||
''
|
|
||||||
# Need to make writable EM_CACHE for emscripten. The path in EM_CACHE must be absolute.
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend#configure-fails-with-sub-word-sized-atomic-operations-not-available
|
|
||||||
+ lib.optionalString targetPlatform.isGhcjs ''
|
|
||||||
export EM_CACHE="$(realpath $(mktemp -d emcache.XXXXXXXXXX))"
|
|
||||||
cp -Lr ${targetCC /* == emscripten */}/share/emscripten/cache/* "$EM_CACHE/"
|
|
||||||
chmod u+rwX -R "$EM_CACHE"
|
|
||||||
''
|
|
||||||
# Create bash array hadrianFlagsArray for use in buildPhase. Do it in
|
|
||||||
# preConfigure, so overrideAttrs can be used to modify it effectively.
|
|
||||||
# hadrianSettings are passed via the command line so they are more visible
|
|
||||||
# in the build log.
|
|
||||||
+ ''
|
|
||||||
hadrianFlagsArray=(
|
|
||||||
"-j$NIX_BUILD_CORES"
|
|
||||||
${lib.escapeShellArgs hadrianSettings}
|
|
||||||
)
|
|
||||||
'';
|
|
||||||
|
|
||||||
${if targetPlatform.isGhcjs then "configureScript" else null} = "emconfigure ./configure";
|
|
||||||
# GHC currently ships an edited config.sub so ghcjs is accepted which we can not rollback
|
|
||||||
${if targetPlatform.isGhcjs then "dontUpdateAutotoolsGnuConfigScripts" else null} = true;
|
|
||||||
|
|
||||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
|
||||||
configurePlatforms = [ "build" "host" ]
|
|
||||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
|
||||||
|
|
||||||
# `--with` flags for libraries needed for RTS linker
|
|
||||||
configureFlags = [
|
|
||||||
"--datadir=$doc/share/doc/ghc"
|
|
||||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
|
||||||
] ++ lib.optionals (libffi != null && !targetPlatform.isGhcjs) [
|
|
||||||
"--with-system-libffi"
|
|
||||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
|
||||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
|
||||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
|
||||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
|
||||||
"--with-iconv-includes=${libiconv}/include"
|
|
||||||
"--with-iconv-libraries=${libiconv}/lib"
|
|
||||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
|
||||||
"--enable-bootstrap-with-devel-snapshot"
|
|
||||||
] ++ lib.optionals useLdGold [
|
|
||||||
"CFLAGS=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
|
||||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
|
||||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
|
||||||
"--disable-large-address-space"
|
|
||||||
] ++ lib.optionals enableDwarf [
|
|
||||||
"--enable-dwarf-unwind"
|
|
||||||
"--with-libdw-includes=${lib.getDev elfutils}/include"
|
|
||||||
"--with-libdw-libraries=${lib.getLib elfutils}/lib"
|
|
||||||
] ++ lib.optionals targetPlatform.isDarwin [
|
|
||||||
# Darwin uses llvm-ar. GHC will try to use `-L` with `ar` when it is `llvm-ar`
|
|
||||||
# but it doesn’t currently work because Cabal never uses `-L` on Darwin. See:
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/23188
|
|
||||||
# https://github.com/haskell/cabal/issues/8882
|
|
||||||
"fp_cv_prog_ar_supports_dash_l=no"
|
|
||||||
];
|
|
||||||
|
|
||||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
|
||||||
dontAddExtraLibs = true;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
perl ghc hadrian bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
|
||||||
# autoconf and friends are necessary for hadrian to create the bindist
|
|
||||||
autoconf automake m4
|
|
||||||
# Python is used in a few scripts invoked by hadrian to generate e.g. rts headers.
|
|
||||||
python3
|
|
||||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
||||||
autoSignDarwinBinariesHook
|
|
||||||
] ++ lib.optionals enableDocs [
|
|
||||||
sphinx
|
|
||||||
];
|
|
||||||
|
|
||||||
# For building runtime libs
|
|
||||||
depsBuildTarget = toolsForTarget;
|
|
||||||
|
|
||||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
|
||||||
|
|
||||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
|
||||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
|
||||||
|
|
||||||
hadrianFlags = [
|
|
||||||
"--flavour=${ghcFlavour}"
|
|
||||||
"--bignum=${if enableNativeBignum then "native" else "gmp"}"
|
|
||||||
"--docs=${if enableDocs then "no-sphinx-pdfs" else "no-sphinx"}"
|
|
||||||
];
|
|
||||||
|
|
||||||
buildPhase = ''
|
|
||||||
runHook preBuild
|
|
||||||
|
|
||||||
# hadrianFlagsArray is created in preConfigure
|
|
||||||
echo "hadrianFlags: $hadrianFlags ''${hadrianFlagsArray[@]}"
|
|
||||||
|
|
||||||
# We need to go via the bindist for installing
|
|
||||||
hadrian $hadrianFlags "''${hadrianFlagsArray[@]}" binary-dist-dir
|
|
||||||
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
|
|
||||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
||||||
# that in turn causes GHCi to abort
|
|
||||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
|
||||||
|
|
||||||
checkTarget = "test";
|
|
||||||
|
|
||||||
hardeningDisable =
|
|
||||||
[ "format" ]
|
|
||||||
# In nixpkgs, musl based builds currently enable `pie` hardening by default
|
|
||||||
# (see `defaultHardeningFlags` in `make-derivation.nix`).
|
|
||||||
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
|
|
||||||
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
|
|
||||||
# See:
|
|
||||||
# * https://github.com/NixOS/nixpkgs/issues/129247
|
|
||||||
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
|
|
||||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
|
||||||
|
|
||||||
# big-parallel allows us to build with more than 2 cores on
|
|
||||||
# Hydra which already warrants a significant speedup
|
|
||||||
requiredSystemFeatures = [ "big-parallel" ];
|
|
||||||
|
|
||||||
outputs = [ "out" "doc" ];
|
|
||||||
|
|
||||||
# We need to configure the bindist *again* before installing
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/22058
|
|
||||||
# TODO(@sternenseemann): it would be nice if the bindist could be an intermediate
|
|
||||||
# derivation, but since it is > 2GB even on x86_64-linux, not a good idea?
|
|
||||||
preInstall = ''
|
|
||||||
pushd _build/bindist/*
|
|
||||||
|
|
||||||
''
|
|
||||||
# the bindist configure script uses different env variables than the GHC configure script
|
|
||||||
# see https://github.com/NixOS/nixpkgs/issues/267250 and https://gitlab.haskell.org/ghc/ghc/-/issues/24211
|
|
||||||
+ lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
|
||||||
export InstallNameToolCmd=$INSTALL_NAME_TOOL
|
|
||||||
export OtoolCmd=$OTOOL
|
|
||||||
''
|
|
||||||
+ ''
|
|
||||||
$configureScript $configureFlags "''${configureFlagsArray[@]}"
|
|
||||||
'';
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
# leave bindist directory
|
|
||||||
popd
|
|
||||||
|
|
||||||
# Install the bash completion file.
|
|
||||||
install -Dm 644 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit bootPkgs targetPrefix;
|
|
||||||
|
|
||||||
inherit llvmPackages;
|
|
||||||
inherit enableShared;
|
|
||||||
|
|
||||||
# Our Cabal compiler name
|
|
||||||
haskellCompilerName = "ghc-${version}";
|
|
||||||
|
|
||||||
# Expose hadrian used for bootstrapping, for debugging purposes
|
|
||||||
inherit hadrian;
|
|
||||||
|
|
||||||
# TODO(@sternenseemann): there's no stage0:exe:haddock target by default,
|
|
||||||
# so haddock isn't available for GHC cross-compilers. Can we fix that?
|
|
||||||
hasHaddock = stdenv.hostPlatform == stdenv.targetPlatform;
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
homepage = "http://haskell.org/ghc";
|
|
||||||
description = "The Glasgow Haskell Compiler";
|
|
||||||
maintainers = with lib.maintainers; [ ];
|
|
||||||
timeout = 24 * 3600;
|
|
||||||
inherit (ghc.meta) license platforms;
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/208959
|
|
||||||
broken =
|
|
||||||
(lib.versionAtLeast version "9.6" && lib.versionOlder version "9.8")
|
|
||||||
&& stdenv.targetPlatform.isStatic;
|
|
||||||
};
|
|
||||||
|
|
||||||
dontStrip = targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm;
|
|
||||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
|
||||||
dontPatchELF = true;
|
|
||||||
noAuditTmpdir = true;
|
|
||||||
})
|
|
|
@ -1,8 +0,0 @@
|
||||||
Fix build of docs after sphinx update.
|
|
||||||
https://github.com/sphinx-doc/sphinx/pull/11381
|
|
||||||
https://gitlab.haskell.org/ghc/ghc/-/issues/24129
|
|
||||||
--- a/docs/users_guide/rtd-theme/layout.html
|
|
||||||
+++ b/docs/users_guide/rtd-theme/layout.html
|
|
||||||
@@ -28 +28 @@
|
|
||||||
- <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
|
|
||||||
+ <link rel="stylesheet" href="{{ pathto('_static/' + styles[-1], 1) }}" type="text/css" />
|
|
|
@ -1,8 +0,0 @@
|
||||||
Fix build of docs after sphinx update.
|
|
||||||
https://github.com/sphinx-doc/sphinx/pull/11381
|
|
||||||
https://gitlab.haskell.org/ghc/ghc/-/issues/24129
|
|
||||||
--- a/docs/users_guide/rtd-theme/layout.html
|
|
||||||
+++ b/docs/users_guide/rtd-theme/layout.html
|
|
||||||
@@ -67 +67 @@
|
|
||||||
- <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
|
|
||||||
+ <link rel="stylesheet" href="{{ pathto('_static/' + styles[-1], 1) }}" type="text/css" />
|
|
|
@ -1,46 +0,0 @@
|
||||||
#!@shell@
|
|
||||||
|
|
||||||
inPreprocessorMode () {
|
|
||||||
hasE=0
|
|
||||||
hasU=0
|
|
||||||
hasT=0
|
|
||||||
for arg in "$@"
|
|
||||||
do
|
|
||||||
if [ 'x-E' = "x$arg" ]; then hasE=1; fi
|
|
||||||
if [ 'x-undef' = "x$arg" ]; then hasU=1; fi
|
|
||||||
if [ 'x-traditional' = "x$arg" ]; then hasT=1; fi
|
|
||||||
done
|
|
||||||
[ "$hasE$hasU$hasT" = '111' ]
|
|
||||||
}
|
|
||||||
|
|
||||||
extraClangArgs="-Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs"
|
|
||||||
|
|
||||||
adjustPreprocessorLanguage () {
|
|
||||||
newArgs=''
|
|
||||||
while [ $# -gt 0 ]
|
|
||||||
do
|
|
||||||
newArgs="$newArgs $1"
|
|
||||||
if [ "$1" = '-x' ]
|
|
||||||
then
|
|
||||||
shift
|
|
||||||
if [ $# -gt 0 ]
|
|
||||||
then
|
|
||||||
if [ "$1" = 'c' ]
|
|
||||||
then
|
|
||||||
newArgs="$newArgs assembler-with-cpp"
|
|
||||||
else
|
|
||||||
newArgs="$newArgs $1"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
echo $newArgs
|
|
||||||
}
|
|
||||||
|
|
||||||
if inPreprocessorMode "$@"
|
|
||||||
then
|
|
||||||
exec clang $extraClangArgs `adjustPreprocessorLanguage "$@"`
|
|
||||||
else
|
|
||||||
exec clang $extraClangArgs "${@/-nodefaultlibs/}"
|
|
||||||
fi
|
|
|
@ -1,11 +0,0 @@
|
||||||
import ./common-hadrian.nix {
|
|
||||||
version = "9.11.20240410";
|
|
||||||
rev = "1b1a92bd25c3f7249cf922c5dbf4415d2de44a36";
|
|
||||||
sha256 = "sha256-2HdhxhVrKn8c/ZOGYoYThqXpod2OPiGXgH+mAV69Ip0=";
|
|
||||||
# The STM benchmark contains chanbench.hs and ChanBench.hs causing a hash
|
|
||||||
# mismatch on case insensitive filesystems. See also
|
|
||||||
# https://gitlab.haskell.org/ghc/packages/stm/-/issues/2
|
|
||||||
postFetch = ''
|
|
||||||
rm -rf "$out/libraries/stm/bench"
|
|
||||||
'';
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
diff -urd a/aclocal.m4 b/aclocal.m4
|
|
||||||
--- a/aclocal.m4
|
|
||||||
+++ b/aclocal.m4
|
|
||||||
@@ -1199,7 +1199,8 @@
|
|
||||||
# thinks that target == host so it never checks the unqualified
|
|
||||||
# tools for Windows. See #14274.
|
|
||||||
AC_DEFUN([FP_PROG_AR],
|
|
||||||
-[if test -z "$fp_prog_ar"; then
|
|
||||||
+[AC_SUBST(fp_prog_ar,$AR)
|
|
||||||
+if test -z "$fp_prog_ar"; then
|
|
||||||
if test "$HostOS" = "mingw32"
|
|
||||||
then
|
|
||||||
AC_PATH_PROG([fp_prog_ar], [ar])
|
|
||||||
diff -urd a/configure b/configure
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -10744,6 +10744,8 @@
|
|
||||||
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
|
|
||||||
|
|
||||||
|
|
||||||
+fp_prog_ar=$AR
|
|
||||||
+
|
|
||||||
if test -z "$fp_prog_ar"; then
|
|
||||||
if test "$HostOS" = "mingw32"
|
|
||||||
then
|
|
|
@ -1,12 +0,0 @@
|
||||||
diff --git a/hadrian/src/Settings/Builders/Haddock.hs b/hadrian/src/Settings/Builders/Haddock.hs
|
|
||||||
index 902b2f85e2..429a441c3b 100644
|
|
||||||
--- a/src/Settings/Builders/Haddock.hs
|
|
||||||
+++ b/src/Settings/Builders/Haddock.hs
|
|
||||||
@@ -57,7 +57,6 @@ haddockBuilderArgs = mconcat
|
|
||||||
, arg $ "--odir=" ++ takeDirectory output
|
|
||||||
, arg $ "--dump-interface=" ++ output
|
|
||||||
, arg "--html"
|
|
||||||
- , arg "--hyperlinked-source"
|
|
||||||
, arg "--hoogle"
|
|
||||||
, arg "--quickjump"
|
|
||||||
, arg $ "--title=" ++ pkgName pkg ++ "-" ++ version
|
|
|
@ -1,16 +0,0 @@
|
||||||
{ mkDerivation, base, lib
|
|
||||||
# GHC source tree to build ghc-toolchain from
|
|
||||||
, ghcSrc
|
|
||||||
, ghcVersion
|
|
||||||
}:
|
|
||||||
mkDerivation {
|
|
||||||
pname = "ghc-platform";
|
|
||||||
version = ghcVersion;
|
|
||||||
src = ghcSrc;
|
|
||||||
postUnpack = ''
|
|
||||||
sourceRoot="$sourceRoot/libraries/ghc-platform"
|
|
||||||
'';
|
|
||||||
libraryHaskellDepends = [ base ];
|
|
||||||
description = "Platform information used by GHC and friends";
|
|
||||||
license = lib.licenses.bsd3;
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
{ mkDerivation, base, directory, filepath, ghc-platform, lib
|
|
||||||
, process, text, transformers
|
|
||||||
# GHC source tree to build ghc-toolchain from
|
|
||||||
, ghcVersion
|
|
||||||
, ghcSrc
|
|
||||||
}:
|
|
||||||
mkDerivation {
|
|
||||||
pname = "ghc-toolchain";
|
|
||||||
version = ghcVersion;
|
|
||||||
src = ghcSrc;
|
|
||||||
postUnpack = ''
|
|
||||||
sourceRoot="$sourceRoot/utils/ghc-toolchain"
|
|
||||||
'';
|
|
||||||
libraryHaskellDepends = [
|
|
||||||
base directory filepath ghc-platform process text transformers
|
|
||||||
];
|
|
||||||
description = "Utility for managing GHC target toolchains";
|
|
||||||
license = lib.licenses.bsd3;
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
diff --git a/hadrian.cabal b/hadrian.cabal
|
|
||||||
index 70fded11aa..3893537f05 100644
|
|
||||||
--- a/hadrian.cabal
|
|
||||||
+++ b/hadrian.cabal
|
|
||||||
@@ -150,7 +150,7 @@ executable hadrian
|
|
||||||
, TypeOperators
|
|
||||||
other-extensions: MultiParamTypeClasses
|
|
||||||
, TypeFamilies
|
|
||||||
- build-depends: Cabal >= 3.2 && < 3.9
|
|
||||||
+ build-depends: Cabal >= 3.2 && < 3.11
|
|
||||||
, base >= 4.11 && < 5
|
|
||||||
, bytestring >= 0.10 && < 0.13
|
|
||||||
, containers >= 0.5 && < 0.7
|
|
|
@ -1,59 +0,0 @@
|
||||||
# See also ./make-hadria.nix
|
|
||||||
{ mkDerivation, base, bytestring, Cabal, containers, directory
|
|
||||||
, extra, filepath, lib, mtl, parsec, shake, text, transformers
|
|
||||||
, unordered-containers, cryptohash-sha256, base16-bytestring
|
|
||||||
, writeText
|
|
||||||
# Dependencies that are not on Hackage and only used in certain Hadrian versions
|
|
||||||
, ghc-platform ? null
|
|
||||||
, ghc-toolchain ? null
|
|
||||||
# GHC source tree to build hadrian from
|
|
||||||
, ghcSrc
|
|
||||||
, ghcVersion
|
|
||||||
# Customization
|
|
||||||
, userSettings ? null
|
|
||||||
, enableHyperlinkedSource
|
|
||||||
}:
|
|
||||||
|
|
||||||
mkDerivation {
|
|
||||||
pname = "hadrian";
|
|
||||||
version = ghcVersion;
|
|
||||||
src = ghcSrc;
|
|
||||||
postUnpack = ''
|
|
||||||
sourceRoot="$sourceRoot/hadrian"
|
|
||||||
'';
|
|
||||||
patches = lib.optionals (!enableHyperlinkedSource) [
|
|
||||||
./disable-hyperlinked-source.patch
|
|
||||||
] ++ lib.optionals (lib.elem ghcVersion [ "9.8.1" "9.8.2" ]) [
|
|
||||||
# Incorrect bounds on Cabal
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/24100
|
|
||||||
./hadrian-9.8.1-allow-Cabal-3.10.patch
|
|
||||||
];
|
|
||||||
# Overwrite UserSettings.hs with a provided custom one
|
|
||||||
postPatch = lib.optionalString (userSettings != null) ''
|
|
||||||
install -m644 "${writeText "UserSettings.hs" userSettings}" src/UserSettings.hs
|
|
||||||
'';
|
|
||||||
configureFlags = [
|
|
||||||
# avoid QuickCheck dep which needs shared libs / TH
|
|
||||||
"-f-selftest"
|
|
||||||
# Building hadrian with -O1 takes quite some time with little benefit.
|
|
||||||
# Additionally we need to recompile it on every change of UserSettings.hs.
|
|
||||||
# See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/1190
|
|
||||||
"-O0"
|
|
||||||
];
|
|
||||||
isLibrary = false;
|
|
||||||
isExecutable = true;
|
|
||||||
executableHaskellDepends = [
|
|
||||||
base bytestring Cabal containers directory extra filepath mtl
|
|
||||||
parsec shake text transformers unordered-containers
|
|
||||||
] ++ lib.optionals (lib.versionAtLeast ghcVersion "9.7") [
|
|
||||||
cryptohash-sha256 base16-bytestring
|
|
||||||
] ++ lib.optionals (lib.versionAtLeast ghcVersion "9.9") [
|
|
||||||
ghc-platform ghc-toolchain
|
|
||||||
];
|
|
||||||
passthru = {
|
|
||||||
# Expose »private« dependencies if any
|
|
||||||
inherit ghc-platform ghc-toolchain;
|
|
||||||
};
|
|
||||||
description = "GHC build system";
|
|
||||||
license = lib.licenses.bsd3;
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
# Hadrian is the build system used to (exclusively) build GHC. It can
|
|
||||||
# (theoretically) be used starting with GHC 9.4 and is required since 9.6. It is
|
|
||||||
# developed in the GHC source tree and specific to the GHC version it is released
|
|
||||||
# with, i.e. Hadrian always needs to be built from the same GHC source tree as
|
|
||||||
# the GHC we want to build.
|
|
||||||
#
|
|
||||||
# This fact makes it impossible to integrate Hadrian into our Haskell package
|
|
||||||
# sets which are also used to bootstrap GHC, since a package set can bootstrap
|
|
||||||
# multiple GHC versions (usually two major versions). A bootstrap set would need
|
|
||||||
# knowledge of the GHC it would eventually bootstrap which would make the logic
|
|
||||||
# unnecessarily complicated.
|
|
||||||
#
|
|
||||||
# Luckily Hadrian is, while annoying to bootstrap, relatively simple. Specifically
|
|
||||||
# all it requires to build is (relative to the GHC we are trying to build) a
|
|
||||||
# build->build GHC and build->build Haskell packages. We can get all of this
|
|
||||||
# from bootPkgs which is already passed to the GHC expression.
|
|
||||||
#
|
|
||||||
# The solution is the following: The GHC expression passes its source tree and
|
|
||||||
# version along with some parameters to this function (./make-hadrian.nix)
|
|
||||||
# which acts as a common expression builder for all Hadrian version as well as
|
|
||||||
# related packages that are managed in the GHC source tree. Its main job is to
|
|
||||||
# expose all possible compile time customization in a common interface and
|
|
||||||
# take care of all differences between Hadrian versions.
|
|
||||||
{ bootPkgs
|
|
||||||
, lib
|
|
||||||
}:
|
|
||||||
|
|
||||||
{ # GHC source tree and version to build hadrian & friends from.
|
|
||||||
# These are passed on to the actual package expressions.
|
|
||||||
ghcSrc
|
|
||||||
, ghcVersion
|
|
||||||
# Contents of a non-default UserSettings.hs to use when building hadrian, if any.
|
|
||||||
# Should be a string or null.
|
|
||||||
, userSettings ? null
|
|
||||||
# Whether to pass --hyperlinked-source to haddock or not. This is a custom
|
|
||||||
# workaround as we wait for this to be configurable via userSettings or similar.
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/23625
|
|
||||||
, enableHyperlinkedSource ? false
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
callPackage' = f: args: bootPkgs.callPackage f ({
|
|
||||||
inherit ghcSrc ghcVersion;
|
|
||||||
} // args);
|
|
||||||
|
|
||||||
ghc-platform = callPackage' ./ghc-platform.nix { };
|
|
||||||
ghc-toolchain = callPackage' ./ghc-toolchain.nix {
|
|
||||||
inherit ghc-platform;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
|
|
||||||
callPackage' ./hadrian.nix ({
|
|
||||||
inherit userSettings enableHyperlinkedSource;
|
|
||||||
} // lib.optionalAttrs (lib.versionAtLeast ghcVersion "9.9") {
|
|
||||||
# Starting with GHC 9.9 development, additional in tree packages are required
|
|
||||||
# to build hadrian. (Hackage-released conditional dependencies are handled
|
|
||||||
# in ./hadrian.nix without requiring intervention here.)
|
|
||||||
inherit ghc-platform ghc-toolchain;
|
|
||||||
})
|
|
|
@ -1,355 +0,0 @@
|
||||||
|
|
||||||
# Maintainer Workflow
|
|
||||||
|
|
||||||
The goal of the [@NixOS/haskell](https://github.com/orgs/NixOS/teams/haskell)
|
|
||||||
team is to keep the Haskell packages in Nixpkgs up-to-date, while making sure
|
|
||||||
there are no Haskell-related evaluation errors or build errors that get into
|
|
||||||
the Nixpkgs `master` branch.
|
|
||||||
|
|
||||||
We do this by periodically merging an updated set of Haskell packages on the
|
|
||||||
`haskell-updates` branch into the `master` branch. Each member of the team
|
|
||||||
takes a two week period where they are in charge of merging the
|
|
||||||
`haskell-updates` branch into `master`. This is the documentation for this
|
|
||||||
workflow.
|
|
||||||
|
|
||||||
The workflow generally proceeds in three main steps:
|
|
||||||
|
|
||||||
1. create the initial `haskell-updates` PR, and update Stackage and Hackage snapshots
|
|
||||||
1. wait for contributors to fix newly broken Haskell packages
|
|
||||||
1. merge `haskell-updates` into `master`
|
|
||||||
|
|
||||||
Each of these steps is described in a separate section.
|
|
||||||
|
|
||||||
There is a script that automates the workflow for merging the currently open
|
|
||||||
`haskell-updates` PR into `master` and opening the next PR. It is described
|
|
||||||
at the end of this document.
|
|
||||||
|
|
||||||
## Initial `haskell-updates` PR
|
|
||||||
|
|
||||||
In this section we create the PR for merging `haskell-updates` into `master`.
|
|
||||||
|
|
||||||
1. Make sure the `haskell-updates` branch is up-to-date with `master`.
|
|
||||||
|
|
||||||
1. Update the Stackage Nightly resolver used by Nixpkgs and create a commit:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ ./maintainers/scripts/haskell/update-stackage.sh --do-commit
|
|
||||||
```
|
|
||||||
|
|
||||||
1. Update the Hackage package set used by Nixpkgs and create a commit:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ ./maintainers/scripts/haskell/update-hackage.sh --do-commit
|
|
||||||
```
|
|
||||||
|
|
||||||
1. Regenerate the Haskell package set used in Nixpkgs and create a commit:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ ./maintainers/scripts/haskell/regenerate-hackage-packages.sh --do-commit
|
|
||||||
```
|
|
||||||
|
|
||||||
1. Push these commits to the `haskell-updates` branch of the NixOS/nixpkgs repository.
|
|
||||||
|
|
||||||
1. Open a PR on Nixpkgs for merging `haskell-updates` into `master`. The recommended
|
|
||||||
PR title and body text are described in the `merge-and-open-pr.sh` section.
|
|
||||||
|
|
||||||
## Notify Maintainers and Fix Broken Packages
|
|
||||||
|
|
||||||
After you've done the previous steps, Hydra will start building the new and
|
|
||||||
updated Haskell packages. You can see the progress Hydra is making at
|
|
||||||
https://hydra.nixos.org/jobset/nixpkgs/haskell-updates. This Hydra jobset is
|
|
||||||
defined in the file [release-haskell.nix](../../top-level/release-haskell.nix).
|
|
||||||
|
|
||||||
### Notify Maintainers
|
|
||||||
|
|
||||||
When Hydra finishes building all the updated packages for the `haskell-updates`
|
|
||||||
jobset, you should generate a build report to notify maintainers of their
|
|
||||||
newly broken packages. You can do that with the following commands:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ ./maintainers/scripts/haskell/hydra-report.hs get-report
|
|
||||||
$ ./maintainers/scripts/haskell/hydra-report.hs ping-maintainers
|
|
||||||
```
|
|
||||||
|
|
||||||
The `hydra-report.hs ping-maintainers` command generates a Markdown document
|
|
||||||
that you can paste in a GitHub comment on the PR opened above. This
|
|
||||||
comment describes which Haskell packages are now failing to build. It also
|
|
||||||
pings the maintainers so that they know to fix up their packages.
|
|
||||||
|
|
||||||
It may be helpful to pipe `hydra-report.hs ping-maintainers` into `xclip`
|
|
||||||
(XOrg) or `wl-copy` (Wayland) in order to post on GitHub.
|
|
||||||
|
|
||||||
This build report can be fetched and re-generated for new Hydra evaluations.
|
|
||||||
It may help contributors to try to keep the GitHub comment updated with the
|
|
||||||
most recent build report.
|
|
||||||
|
|
||||||
Maintainers should be given at least 7 days to fix up their packages when they
|
|
||||||
break. If maintainers don't fix up their packages within 7 days, then they
|
|
||||||
may be marked broken before merging `haskell-updates` into `master`.
|
|
||||||
|
|
||||||
### Fix Broken Packages
|
|
||||||
|
|
||||||
After getting the build report, you can see which packages and Hydra jobs are
|
|
||||||
failing to build. The most important jobs are the
|
|
||||||
[`maintained`](https://hydra.nixos.org/job/nixpkgs/haskell-updates/maintained) and
|
|
||||||
[`mergeable`](https://hydra.nixos.org/job/nixpkgs/haskell-updates/mergeable)
|
|
||||||
jobs. These are both defined in
|
|
||||||
[`release-haskell.nix`](../../top-level/release-haskell.nix).
|
|
||||||
|
|
||||||
`mergeable` is a set of the most important Haskell packages, including things
|
|
||||||
like Pandoc and XMonad. These packages are widely used. We would like to
|
|
||||||
always keep these building.
|
|
||||||
|
|
||||||
`maintained` is a set of Haskell packages that have maintainers in Nixpkgs.
|
|
||||||
We should be proactive in working with maintainers to keep their packages
|
|
||||||
building.
|
|
||||||
|
|
||||||
Steps to fix Haskell packages that are failing to build is out of scope for
|
|
||||||
this document, but it usually requires fixing up dependencies that are now
|
|
||||||
out-of-bounds.
|
|
||||||
|
|
||||||
### Mark Broken Packages
|
|
||||||
|
|
||||||
Packages that do not get fixed can be marked broken with the following
|
|
||||||
commands. First check which packages are broken:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ ./maintainers/scripts/haskell/hydra-report.hs get-report
|
|
||||||
$ ./maintainers/scripts/haskell/hydra-report.hs mark-broken-list
|
|
||||||
```
|
|
||||||
|
|
||||||
This shows a list of packages that reported a build failure on `x86_64-linux` on Hydra.
|
|
||||||
|
|
||||||
Next, run the following command:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ ./maintainers/scripts/haskell/mark-broken.sh --do-commit
|
|
||||||
```
|
|
||||||
|
|
||||||
This first opens up an editor with the broken package list. Some of these
|
|
||||||
packages may have a maintainer in Nixpkgs. If these maintainers have not been
|
|
||||||
given 7 days to fix up their package, then make sure to remove those packages
|
|
||||||
from the list before continuing. After saving and exiting the editor, the
|
|
||||||
following will happen:
|
|
||||||
|
|
||||||
- Packages from the list will be added to
|
|
||||||
[`configuration-hackage2nix/broken.yaml`](configuration-hackage2nix/broken.yaml).
|
|
||||||
This is a list of Haskell packages that are known to be broken.
|
|
||||||
|
|
||||||
- [`hackage-packages.nix`](hackage-packages.nix) will be regenerated. This
|
|
||||||
will mark all Haskell packages in `configuration-hackage2nix/broken.yaml`
|
|
||||||
as `broken`.
|
|
||||||
|
|
||||||
- The
|
|
||||||
[`configuration-hackage2nix/transitive-broken.yaml`](configuration-hackage2nix/transitive-broken.yaml)
|
|
||||||
file will be updated. This is a list of Haskell packages that
|
|
||||||
depend on a package in `configuration-hackage2nix/broken.yaml` or
|
|
||||||
`configuration-hackage2nix/transitive-broken.yaml`
|
|
||||||
|
|
||||||
- `hackage-packages.nix` will be regenerated again. This will set
|
|
||||||
`hydraPlatforms = none` for all the packages in
|
|
||||||
`configuration-hackage2nix/transitive-broken.yaml`. This makes
|
|
||||||
sure that Hydra does not try to build any of these packages.
|
|
||||||
|
|
||||||
- All updated files will be committed.
|
|
||||||
|
|
||||||
## Merge `haskell-updates` into `master`
|
|
||||||
|
|
||||||
Now it is time to merge the `haskell-updates` PR you opened above.
|
|
||||||
|
|
||||||
Before doing this, make sure of the following:
|
|
||||||
|
|
||||||
- All Haskell packages that fail to build are correctly marked broken or
|
|
||||||
transitively broken.
|
|
||||||
|
|
||||||
- The `maintained` and `mergeable` jobs are passing on Hydra.
|
|
||||||
|
|
||||||
- The maintainers for any maintained Haskell packages that are newly broken
|
|
||||||
have been pinged on GitHub and given at least a week to fix their packages.
|
|
||||||
This is especially important for widely-used packages like `cachix`.
|
|
||||||
|
|
||||||
- Make sure you first merge the `master` branch into `haskell-updates`. Wait
|
|
||||||
for Hydra to evaluate the new `haskell-updates` jobset. Make sure you only
|
|
||||||
merge `haskell-updates` into `master` when there are no evaluation errors.
|
|
||||||
|
|
||||||
- Due to Hydra having only a small number of Darwin build machines, the
|
|
||||||
`haskell-updates` jobset on Hydra often has many queued Darwin jobs.
|
|
||||||
In order to not have these queued Darwin jobs prevent the `haskell-updates`
|
|
||||||
branch from being merged to `master` in a timely manner, we have special
|
|
||||||
rules for Darwin jobs.
|
|
||||||
|
|
||||||
- It is alright to merge the `haskell-updates` branch to `master` if
|
|
||||||
there are remaining queued Darwin jobs on Hydra.
|
|
||||||
|
|
||||||
- We would like to keep GHC and the `mergeable` job building on Darwin.
|
|
||||||
Do not merge the `haskell-updates` branch to `master` if GHC is failing
|
|
||||||
to build, or the `mergeable` job has failing Darwin constituent jobs.
|
|
||||||
|
|
||||||
If GHC and the `mergeable` job are not failing, but merely queued,
|
|
||||||
it is alright to merge the `haskell-updates` branch to `master`.
|
|
||||||
|
|
||||||
- We do not need to keep the `maintained` job building on Darwin.
|
|
||||||
If `maintained` packages are failing on Darwin, it is helpful to
|
|
||||||
mark them as broken on that platform.
|
|
||||||
|
|
||||||
When you've double-checked these points, go ahead and merge the `haskell-updates` PR.
|
|
||||||
After merging, **make sure not to delete the `haskell-updates` branch**, since it
|
|
||||||
causes all currently open Haskell-related pull-requests to be automatically closed on GitHub.
|
|
||||||
|
|
||||||
## Script for Merging `haskell-updates` and Opening a New PR
|
|
||||||
|
|
||||||
There is a script that automates merging the current `haskell-updates` PR and
|
|
||||||
opening the next one. When you want to merge the currently open
|
|
||||||
`haskell-updates` PR, you can run the script with the following steps:
|
|
||||||
|
|
||||||
1. Make sure you have previously authenticated with the `gh` command. The
|
|
||||||
script uses the `gh` command to merge the current PR and open a new one.
|
|
||||||
You should only need to do this once.
|
|
||||||
|
|
||||||
This command can be used to authenticate:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ gh auth login
|
|
||||||
```
|
|
||||||
|
|
||||||
This command can be used to confirm that you have already authenticated:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ gh auth status
|
|
||||||
```
|
|
||||||
|
|
||||||
1. Make sure you have setup your `~/.cabal/config` file for authentication
|
|
||||||
for uploading the NixOS package versions to Hackage. See the following
|
|
||||||
section for details on how to do this.
|
|
||||||
|
|
||||||
1. Make sure you have correctly marked packages broken. One of the previous
|
|
||||||
sections explains how to do this.
|
|
||||||
|
|
||||||
In short:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ ./maintainers/scripts/haskell/hydra-report.hs get-report
|
|
||||||
$ ./maintainers/scripts/haskell/hydra-report.hs mark-broken-list
|
|
||||||
$ ./maintainers/scripts/haskell/mark-broken.sh --do-commit
|
|
||||||
```
|
|
||||||
|
|
||||||
1. Merge `master` into `haskell-updates` and make sure to push to the
|
|
||||||
`haskell-updates` branch. (This can be skipped if `master` has recently
|
|
||||||
been merged into `haskell-updates`.)
|
|
||||||
|
|
||||||
1. Go to https://hydra.nixos.org/jobset/nixpkgs/haskell-updates and force an
|
|
||||||
evaluation of the `haskell-updates` jobset. See one of the following
|
|
||||||
sections for how to do this. Make sure there are no evaluation errors. If
|
|
||||||
there are remaining evaluation errors, fix them before continuing with this
|
|
||||||
merge.
|
|
||||||
|
|
||||||
1. Run the script to merge `haskell-updates`:
|
|
||||||
|
|
||||||
```console
|
|
||||||
$ ./maintainers/scripts/haskell/merge-and-open-pr.sh PR_NUM_OF_CURRENT_HASKELL_UPDATES_PR
|
|
||||||
```
|
|
||||||
|
|
||||||
Find the PR number easily [here](https://github.com/nixos/nixpkgs/pulls?q=is%3Apr+is%3Aopen+head%3Ahaskell-updates)
|
|
||||||
|
|
||||||
This does the following things:
|
|
||||||
|
|
||||||
1. Fetches `origin`, makes sure you currently have the `haskell-updates`
|
|
||||||
branch checked out, and makes sure your currently checked-out
|
|
||||||
`haskell-updates` branch is on the same commit as
|
|
||||||
`origin/haskell-updates`.
|
|
||||||
|
|
||||||
1. Merges the currently open `haskell-updates` PR.
|
|
||||||
|
|
||||||
1. Updates the version of Haskell packages in NixOS on Hackage.
|
|
||||||
|
|
||||||
1. Updates Stackage and Hackage snapshots. Regenerates the Haskell package set.
|
|
||||||
|
|
||||||
1. Pushes the commits updating Stackage and Hackage and opens a new
|
|
||||||
`haskell-updates` PR on Nixpkgs. If you'd like to do this by hand,
|
|
||||||
look in the script for the recommended PR title and body text.
|
|
||||||
|
|
||||||
## Update Hackage Version Information
|
|
||||||
|
|
||||||
After merging into `master` you can update what Hackage displays as the current
|
|
||||||
version in NixOS for every individual package. To do this you run
|
|
||||||
`maintainers/scripts/haskell/upload-nixos-package-list-to-hackage.sh`. See the
|
|
||||||
script for how to provide credentials. Once you have configured credentials,
|
|
||||||
running this takes only a few seconds.
|
|
||||||
|
|
||||||
## Additional Info
|
|
||||||
|
|
||||||
Here are some additional tips that didn't fit in above.
|
|
||||||
|
|
||||||
- Hydra tries to evaluate the `haskell-updates` branch (in the
|
|
||||||
[`nixpkgs:haskell-updates`](https://hydra.nixos.org/jobset/nixpkgs/haskell-updates)
|
|
||||||
jobset) every 4 hours. It is possible to force a new Hydra evaluation without
|
|
||||||
waiting 4 hours by the following steps:
|
|
||||||
|
|
||||||
1. Log into Hydra with your GitHub or Google account.
|
|
||||||
1. Go to the [nixpkgs:haskell-updates](https://hydra.nixos.org/jobset/nixpkgs/haskell-updates) jobset.
|
|
||||||
1. Click the `Actions` button.
|
|
||||||
1. Select `Evaluate this jobset`.
|
|
||||||
1. If you refresh the page, there should be a new `Evaluation running since:` line.
|
|
||||||
1. Evaluations take about 10 minutes to finish.
|
|
||||||
|
|
||||||
- It is sometimes helpful to update the version of
|
|
||||||
[`cabal2nix` / `hackage2nix`](https://github.com/NixOS/cabal2nix) that our
|
|
||||||
maintainer scripts use. This can be done with the
|
|
||||||
[`maintainers/scripts/haskell/update-cabal2nix-unstable.sh`](../../../maintainers/scripts/haskell/update-cabal2nix-unstable.sh)
|
|
||||||
script.
|
|
||||||
|
|
||||||
You might want to do this if a user contributes a fix to `cabal2nix` that
|
|
||||||
will immediately fix a Haskell package in Nixpkgs. First, merge in
|
|
||||||
the PR to `cabal2nix`, then run `update-cabal2nix-upstable.sh`. Finally, run
|
|
||||||
[`regenerate-hackage-packages.sh`](../../../maintainers/scripts/haskell/regenerate-hackage-packages.sh)
|
|
||||||
to regenerate the Hackage package set with the updated version of `hackage2nix`.
|
|
||||||
|
|
||||||
- Make sure never to update the Hackage package hashes in
|
|
||||||
[`pkgs/data/misc/hackage/`](../../../pkgs/data/misc/hackage/), or the
|
|
||||||
pinned Stackage Nightly versions on the release branches (like
|
|
||||||
`release-21.05`).
|
|
||||||
|
|
||||||
This means that the
|
|
||||||
[`update-hackage.sh`](../../../maintainers/scripts/haskell/update-hackage.sh)
|
|
||||||
and
|
|
||||||
[`update-stackage.sh`](../../../maintainers/scripts/haskell/update-stackage.sh)
|
|
||||||
scripts should never be used on the release branches.
|
|
||||||
|
|
||||||
However, changing other files in `./.` and regenerating the package set is encouraged.
|
|
||||||
This can be done with
|
|
||||||
[`regenerate-hackage-packages.sh`](../../../maintainers/scripts/haskell/regenerate-hackage-packages.sh)
|
|
||||||
as described above.
|
|
||||||
|
|
||||||
- The Haskell team members generally hang out in the Matrix room
|
|
||||||
[#haskell:nixos.org](https://matrix.to/#/#haskell:nixos.org).
|
|
||||||
|
|
||||||
- This is a checklist for things that need to happen when a new
|
|
||||||
member is added to the Nixpkgs Haskell team.
|
|
||||||
|
|
||||||
1. Add the person to the
|
|
||||||
[@NixOS/haskell](https://github.com/orgs/NixOS/teams/haskell)
|
|
||||||
team. You may need to ask someone in the NixOS organization
|
|
||||||
to do this, like [@domenkozar](https://github.com/domenkozar).
|
|
||||||
This gives the new member access to the GitHub repos like
|
|
||||||
[cabal2nix](https://github.com/NixOS/cabal2nix).
|
|
||||||
|
|
||||||
1. Add the person as a maintainer for the following packages
|
|
||||||
on Hackage:
|
|
||||||
- https://hackage.haskell.org/package/cabal2nix
|
|
||||||
- https://hackage.haskell.org/package/distribution-nixpkgs
|
|
||||||
- https://hackage.haskell.org/package/hackage-db
|
|
||||||
- https://hackage.haskell.org/package/jailbreak-cabal
|
|
||||||
- https://hackage.haskell.org/package/language-nix
|
|
||||||
|
|
||||||
1. Add the person to the `haskell` team in
|
|
||||||
[`maintainers/team-list.nix`](../../../maintainers/team-list.nix).
|
|
||||||
This team is responsible for some important packages in
|
|
||||||
[release-haskell.nix](../../top-level/release-haskell.nix).
|
|
||||||
|
|
||||||
1. Update the
|
|
||||||
[Nextcloud Calendar](https://cloud.maralorn.de/apps/calendar/p/H6migHmKX7xHoTFa)
|
|
||||||
and work the new member into the `haskell-updates` rotation.
|
|
||||||
|
|
||||||
1. Optionally, have the new member add themselves to the Haskell
|
|
||||||
section in [`CODEOWNERS`](../../../.github/CODEOWNERS). This
|
|
||||||
will cause them to get pinged on most Haskell-related PRs.
|
|
|
@ -1,41 +0,0 @@
|
||||||
# This file defines cabal2nix-unstable, used by maintainers/scripts/haskell/regenerate-hackage-packages.sh.
|
|
||||||
{ mkDerivation, aeson, ansi-wl-pprint, base, bytestring, Cabal
|
|
||||||
, containers, deepseq, directory, distribution-nixpkgs, fetchzip
|
|
||||||
, filepath, hackage-db, hopenssl, hpack, language-nix, lens, lib
|
|
||||||
, monad-par, monad-par-extras, mtl, optparse-applicative, pretty
|
|
||||||
, process, split, tasty, tasty-golden, text, time, transformers
|
|
||||||
, yaml
|
|
||||||
}:
|
|
||||||
mkDerivation {
|
|
||||||
pname = "cabal2nix";
|
|
||||||
version = "unstable-2024-04-21";
|
|
||||||
src = fetchzip {
|
|
||||||
url = "https://github.com/NixOS/cabal2nix/archive/f8e6bf749a158a5ed866c57deee907b5f16c38e5.tar.gz";
|
|
||||||
sha256 = "0c73mvza65iy46fv8c8cadsy7klk4jzmimm1mfdavvm8i2cr5476";
|
|
||||||
};
|
|
||||||
postUnpack = "sourceRoot+=/cabal2nix; echo source root reset to $sourceRoot";
|
|
||||||
isLibrary = true;
|
|
||||||
isExecutable = true;
|
|
||||||
libraryHaskellDepends = [
|
|
||||||
aeson ansi-wl-pprint base bytestring Cabal containers deepseq
|
|
||||||
directory distribution-nixpkgs filepath hackage-db hopenssl hpack
|
|
||||||
language-nix lens optparse-applicative pretty process split text
|
|
||||||
time transformers yaml
|
|
||||||
];
|
|
||||||
executableHaskellDepends = [
|
|
||||||
aeson base bytestring Cabal containers directory
|
|
||||||
distribution-nixpkgs filepath hopenssl language-nix lens monad-par
|
|
||||||
monad-par-extras mtl optparse-applicative pretty
|
|
||||||
];
|
|
||||||
testHaskellDepends = [
|
|
||||||
base Cabal containers directory filepath language-nix lens pretty
|
|
||||||
process tasty tasty-golden
|
|
||||||
];
|
|
||||||
preCheck = ''
|
|
||||||
export PATH="$PWD/dist/build/cabal2nix:$PATH"
|
|
||||||
export HOME="$TMPDIR/home"
|
|
||||||
'';
|
|
||||||
homepage = "https://github.com/nixos/cabal2nix#readme";
|
|
||||||
description = "Convert Cabal files into Nix build instructions";
|
|
||||||
license = lib.licenses.bsd3;
|
|
||||||
}
|
|
|
@ -1,117 +0,0 @@
|
||||||
# ARM-SPECIFIC OVERRIDES FOR THE HASKELL PACKAGE SET IN NIXPKGS
|
|
||||||
#
|
|
||||||
# This extension is applied to all haskell package sets in nixpkgs if
|
|
||||||
# `stdenv.hostPlatform.isAarch` to apply arm specific workarounds or
|
|
||||||
# fixes.
|
|
||||||
#
|
|
||||||
# The file is split into three parts:
|
|
||||||
#
|
|
||||||
# * Overrides that are applied for all arm platforms
|
|
||||||
# * Overrides for aarch32 platforms
|
|
||||||
# * Overrides for aarch64 platforms
|
|
||||||
#
|
|
||||||
# This may be extended in the future to also include compiler-
|
|
||||||
# specific sections as compiler and linker related bugs may
|
|
||||||
# get fixed subsequently.
|
|
||||||
#
|
|
||||||
# When adding new overrides, try to research which section they
|
|
||||||
# belong into. Most likely we'll be favouring aarch64 overrides
|
|
||||||
# in practice since that is the only platform we can test on
|
|
||||||
# Hydra. Also take care to group overrides by the issue they
|
|
||||||
# solve, so refactors and updates to this file are less tedious.
|
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs) lib;
|
|
||||||
in
|
|
||||||
|
|
||||||
with haskellLib;
|
|
||||||
|
|
||||||
self: super: {
|
|
||||||
# COMMON ARM OVERRIDES
|
|
||||||
|
|
||||||
# moved here from configuration-common.nix, no reason given.
|
|
||||||
servant-docs = dontCheck super.servant-docs;
|
|
||||||
swagger2 = dontHaddock (dontCheck super.swagger2);
|
|
||||||
|
|
||||||
# Similar to https://ghc.haskell.org/trac/ghc/ticket/13062
|
|
||||||
happy = dontCheck super.happy;
|
|
||||||
happy_1_19_12 = doDistribute (dontCheck super.happy_1_19_12);
|
|
||||||
|
|
||||||
# add arm specific library
|
|
||||||
wiringPi = overrideCabal ({librarySystemDepends ? [], ...}: {
|
|
||||||
librarySystemDepends = librarySystemDepends ++ [pkgs.wiringpi];
|
|
||||||
}) super.wiringPi;
|
|
||||||
|
|
||||||
} // lib.optionalAttrs pkgs.stdenv.hostPlatform.isAarch64 {
|
|
||||||
# AARCH64-SPECIFIC OVERRIDES
|
|
||||||
|
|
||||||
# Corrupted store path https://github.com/NixOS/nixpkgs/pull/272097#issuecomment-1848414265
|
|
||||||
cachix = triggerRebuild 1 super.cachix;
|
|
||||||
|
|
||||||
# Doctests fail on aarch64 due to a GHCi linking bug
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/15275#note_295437
|
|
||||||
# TODO: figure out if needed on aarch32 as well
|
|
||||||
BNFC = dontCheck super.BNFC;
|
|
||||||
C-structs = dontCheck super.C-structs;
|
|
||||||
Chart-tests = dontCheck super.Chart-tests;
|
|
||||||
Jikka = dontCheck super.Jikka;
|
|
||||||
accelerate = dontCheck super.accelerate;
|
|
||||||
ad = dontCheck super.ad;
|
|
||||||
autoapply = dontCheck super.autoapply;
|
|
||||||
construct = dontCheck super.construct;
|
|
||||||
exact-real = dontCheck super.exact-real;
|
|
||||||
flight-kml = dontCheck super.flight-kml;
|
|
||||||
focuslist = dontCheck super.focuslist;
|
|
||||||
grammatical-parsers = dontCheck super.grammatical-parsers;
|
|
||||||
greskell = dontCheck super.greskell;
|
|
||||||
groupBy = dontCheck super.groupBy;
|
|
||||||
haskell-time-range = dontCheck super.haskell-time-range;
|
|
||||||
headroom = dontCheck super.headroom;
|
|
||||||
hgeometry = dontCheck super.hgeometry;
|
|
||||||
hhp = dontCheck super.hhp;
|
|
||||||
hsakamai = dontCheck super.hsakamai;
|
|
||||||
hsemail-ns = dontCheck super.hsemail-ns;
|
|
||||||
html-validator-cli = dontCheck super.html-validator-cli;
|
|
||||||
hw-fingertree-strict = dontCheck super.hw-fingertree-strict;
|
|
||||||
hw-packed-vector = dontCheck super.hw-packed-vector;
|
|
||||||
hw-prim = dontCheck super.hw-prim;
|
|
||||||
hw-xml = dontCheck super.hw-xml;
|
|
||||||
language-nix = dontCheck super.language-nix;
|
|
||||||
lens-regex = dontCheck super.lens-regex;
|
|
||||||
meep = dontCheck super.meep;
|
|
||||||
openapi3 = dontCheck super.openapi3;
|
|
||||||
orbits = dontCheck super.orbits;
|
|
||||||
ranged-list = dontCheck super.ranged-list;
|
|
||||||
rank2classes = dontCheck super.rank2classes;
|
|
||||||
schedule = dontCheck super.schedule;
|
|
||||||
static = dontCheck super.static;
|
|
||||||
strict-writer = dontCheck super.strict-writer;
|
|
||||||
termonad = dontCheck super.termonad;
|
|
||||||
trifecta = dontCheck super.trifecta;
|
|
||||||
twiml = dontCheck super.twiml;
|
|
||||||
twitter-conduit = dontCheck super.twitter-conduit;
|
|
||||||
validationt = dontCheck super.validationt;
|
|
||||||
vgrep = dontCheck super.vgrep;
|
|
||||||
vinyl = dontCheck super.vinyl;
|
|
||||||
vulkan-utils = dontCheck super.vulkan-utils;
|
|
||||||
xml-html-qq = dontCheck super.xml-html-qq;
|
|
||||||
yaml-combinators = dontCheck super.yaml-combinators;
|
|
||||||
yesod-paginator = dontCheck super.yesod-paginator;
|
|
||||||
|
|
||||||
# https://github.com/ekmett/half/issues/35
|
|
||||||
half = dontCheck super.half;
|
|
||||||
|
|
||||||
# We disable profiling on aarch64, so tests naturally fail
|
|
||||||
ghc-prof = dontCheck super.ghc-prof;
|
|
||||||
|
|
||||||
# Similar RTS issue in test suite:
|
|
||||||
# rts/linker/elf_reloc_aarch64.c:98: encodeAddendAarch64: Assertion `isInt64(21+12, addend)' failed.
|
|
||||||
# These still fail sporadically on ghc 9.2
|
|
||||||
} // lib.optionalAttrs pkgs.stdenv.hostPlatform.isAarch32 {
|
|
||||||
# AARCH32-SPECIFIC OVERRIDES
|
|
||||||
|
|
||||||
# KAT/ECB/D2 test segfaults on armv7l
|
|
||||||
# https://github.com/haskell-crypto/cryptonite/issues/367
|
|
||||||
cryptonite = dontCheck super.cryptonite;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,357 +0,0 @@
|
||||||
# DARWIN-SPECIFIC OVERRIDES FOR THE HASKELL PACKAGE SET IN NIXPKGS
|
|
||||||
|
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs) lib darwin;
|
|
||||||
in
|
|
||||||
|
|
||||||
with haskellLib;
|
|
||||||
|
|
||||||
self: super: ({
|
|
||||||
|
|
||||||
# the tests for shell-conduit on Darwin illegitimatey assume non-GNU echo
|
|
||||||
# see: https://github.com/psibi/shell-conduit/issues/12
|
|
||||||
shell-conduit = dontCheck super.shell-conduit;
|
|
||||||
|
|
||||||
conduit-extra = super.conduit-extra.overrideAttrs (drv: {
|
|
||||||
__darwinAllowLocalNetworking = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
streaming-commons = super.streaming-commons.overrideAttrs (_: {
|
|
||||||
__darwinAllowLocalNetworking = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
halive = addBuildDepend darwin.apple_sdk.frameworks.AppKit super.halive;
|
|
||||||
|
|
||||||
# Hakyll's tests are broken on Darwin (3 failures); and they require util-linux
|
|
||||||
hakyll = overrideCabal {
|
|
||||||
testToolDepends = [];
|
|
||||||
doCheck = false;
|
|
||||||
} super.hakyll;
|
|
||||||
|
|
||||||
barbly = addBuildDepend darwin.apple_sdk.frameworks.AppKit super.barbly;
|
|
||||||
|
|
||||||
double-conversion = addExtraLibrary pkgs.libcxx super.double-conversion;
|
|
||||||
|
|
||||||
streamly = addBuildDepend darwin.apple_sdk.frameworks.Cocoa super.streamly;
|
|
||||||
|
|
||||||
apecs-physics = addPkgconfigDepends [
|
|
||||||
darwin.apple_sdk.frameworks.ApplicationServices
|
|
||||||
] super.apecs-physics;
|
|
||||||
|
|
||||||
# Framework deps are hidden behind a flag
|
|
||||||
hmidi = addExtraLibraries [
|
|
||||||
darwin.apple_sdk.frameworks.CoreFoundation
|
|
||||||
darwin.apple_sdk.frameworks.CoreAudio
|
|
||||||
darwin.apple_sdk.frameworks.CoreMIDI
|
|
||||||
] super.hmidi;
|
|
||||||
|
|
||||||
# "erf table" test fails on Darwin
|
|
||||||
# https://github.com/bos/math-functions/issues/63
|
|
||||||
math-functions = dontCheck super.math-functions;
|
|
||||||
|
|
||||||
# darwin doesn't have sub-second resolution
|
|
||||||
# https://github.com/hspec/mockery/issues/11
|
|
||||||
mockery = overrideCabal (drv: {
|
|
||||||
preCheck = ''
|
|
||||||
export TRAVIS=true
|
|
||||||
'' + (drv.preCheck or "");
|
|
||||||
}) super.mockery;
|
|
||||||
|
|
||||||
# https://github.com/ndmitchell/shake/issues/206
|
|
||||||
shake = dontCheck super.shake;
|
|
||||||
|
|
||||||
filecache = dontCheck super.filecache;
|
|
||||||
|
|
||||||
# gtk/gtk3 needs to be told on Darwin to use the Quartz
|
|
||||||
# rather than X11 backend (see eg https://github.com/gtk2hs/gtk2hs/issues/249).
|
|
||||||
gtk3 = appendConfigureFlag "-f have-quartz-gtk" super.gtk3;
|
|
||||||
gtk = appendConfigureFlag "-f have-quartz-gtk" super.gtk;
|
|
||||||
|
|
||||||
OpenAL = addExtraLibrary darwin.apple_sdk.frameworks.OpenAL super.OpenAL;
|
|
||||||
|
|
||||||
al = overrideCabal (drv: {
|
|
||||||
libraryFrameworkDepends = [
|
|
||||||
darwin.apple_sdk.frameworks.OpenAL
|
|
||||||
] ++ (drv.libraryFrameworkDepends or []);
|
|
||||||
}) super.al;
|
|
||||||
|
|
||||||
proteaaudio = addExtraLibrary darwin.apple_sdk.frameworks.AudioToolbox super.proteaaudio;
|
|
||||||
|
|
||||||
# the system-fileio tests use canonicalizePath, which fails in the sandbox
|
|
||||||
system-fileio = dontCheck super.system-fileio;
|
|
||||||
|
|
||||||
git-annex = overrideCabal (drv: {
|
|
||||||
# We can't use testFlags since git-annex side steps the Cabal test mechanism
|
|
||||||
preCheck = drv.preCheck or "" + ''
|
|
||||||
checkFlagsArray+=(
|
|
||||||
# The addurl test cases require security(1) to be in PATH which we can't
|
|
||||||
# provide from nixpkgs to my (@sternenseemann) knowledge.
|
|
||||||
"-p" "!/addurl/"
|
|
||||||
)
|
|
||||||
'';
|
|
||||||
}) super.git-annex;
|
|
||||||
|
|
||||||
# Prevents needing to add `security_tool` as a run-time dependency for
|
|
||||||
# everything using x509-system to give access to the `security` executable.
|
|
||||||
#
|
|
||||||
# darwin.security_tool is broken in Mojave (#45042)
|
|
||||||
#
|
|
||||||
# We will use the system provided security for now.
|
|
||||||
# Beware this WILL break in sandboxes!
|
|
||||||
#
|
|
||||||
# TODO(matthewbauer): If someone really needs this to work in sandboxes,
|
|
||||||
# I think we can add a propagatedImpureHost dep here, but I’m hoping to
|
|
||||||
# get a proper fix available soonish.
|
|
||||||
x509-system = overrideCabal (drv:
|
|
||||||
lib.optionalAttrs (!pkgs.stdenv.cc.nativeLibc) {
|
|
||||||
postPatch = ''
|
|
||||||
substituteInPlace System/X509/MacOS.hs --replace security /usr/bin/security
|
|
||||||
'' + (drv.postPatch or "");
|
|
||||||
}) super.x509-system;
|
|
||||||
|
|
||||||
# https://github.com/haskell-foundation/foundation/pull/412
|
|
||||||
foundation = dontCheck super.foundation;
|
|
||||||
|
|
||||||
llvm-hs = overrideCabal (oldAttrs: {
|
|
||||||
# One test fails on darwin.
|
|
||||||
doCheck = false;
|
|
||||||
# llvm-hs's Setup.hs file tries to add the lib/ directory from LLVM8 to
|
|
||||||
# the DYLD_LIBRARY_PATH environment variable. This messes up clang
|
|
||||||
# when called from GHC, probably because clang is version 7, but we are
|
|
||||||
# using LLVM8.
|
|
||||||
preCompileBuildDriver = ''
|
|
||||||
substituteInPlace Setup.hs --replace "addToLdLibraryPath libDir" "pure ()"
|
|
||||||
'' + (oldAttrs.preCompileBuildDriver or "");
|
|
||||||
}) super.llvm-hs;
|
|
||||||
|
|
||||||
yesod-bin = addBuildDepend darwin.apple_sdk.frameworks.Cocoa super.yesod-bin;
|
|
||||||
|
|
||||||
yesod-core = super.yesod-core.overrideAttrs (drv: {
|
|
||||||
# Allow access to local networking when the Darwin sandbox is enabled, so yesod-core can
|
|
||||||
# run tests that access localhost.
|
|
||||||
__darwinAllowLocalNetworking = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
hidapi =
|
|
||||||
addExtraLibraries [
|
|
||||||
darwin.apple_sdk.frameworks.AppKit
|
|
||||||
darwin.apple_sdk.frameworks.IOKit
|
|
||||||
darwin.apple_sdk.frameworks.CoreFoundation
|
|
||||||
]
|
|
||||||
(super.hidapi.override { systemd = null; });
|
|
||||||
|
|
||||||
hmatrix = addBuildDepend darwin.apple_sdk.frameworks.Accelerate super.hmatrix;
|
|
||||||
|
|
||||||
blas-hs = overrideCabal (drv: {
|
|
||||||
libraryFrameworkDepends = [
|
|
||||||
darwin.apple_sdk.frameworks.Accelerate
|
|
||||||
] ++ (drv.libraryFrameworkDepends or []);
|
|
||||||
}) super.blas-hs;
|
|
||||||
|
|
||||||
# Ensure the necessary frameworks are propagatedBuildInputs on darwin
|
|
||||||
OpenGLRaw = overrideCabal (drv: {
|
|
||||||
librarySystemDepends = [];
|
|
||||||
libraryHaskellDepends = drv.libraryHaskellDepends ++ [
|
|
||||||
darwin.apple_sdk.frameworks.OpenGL
|
|
||||||
];
|
|
||||||
preConfigure = ''
|
|
||||||
frameworkPaths=($(for i in $nativeBuildInputs; do if [ -d "$i"/Library/Frameworks ]; then echo "-F$i/Library/Frameworks"; fi done))
|
|
||||||
frameworkPaths=$(IFS=, ; echo "''${frameworkPaths[@]}")
|
|
||||||
configureFlags+=$(if [ -n "$frameworkPaths" ]; then echo -n "--ghc-options=-optl=$frameworkPaths"; fi)
|
|
||||||
'' + (drv.preConfigure or "");
|
|
||||||
}) super.OpenGLRaw;
|
|
||||||
GLURaw = overrideCabal (drv: {
|
|
||||||
librarySystemDepends = [];
|
|
||||||
libraryHaskellDepends = drv.libraryHaskellDepends ++ [
|
|
||||||
darwin.apple_sdk.frameworks.OpenGL
|
|
||||||
];
|
|
||||||
}) super.GLURaw;
|
|
||||||
bindings-GLFW = overrideCabal (drv: {
|
|
||||||
librarySystemDepends = [];
|
|
||||||
libraryHaskellDepends = drv.libraryHaskellDepends ++ [
|
|
||||||
darwin.apple_sdk.frameworks.AGL
|
|
||||||
darwin.apple_sdk.frameworks.Cocoa
|
|
||||||
darwin.apple_sdk.frameworks.OpenGL
|
|
||||||
darwin.apple_sdk.frameworks.IOKit
|
|
||||||
darwin.apple_sdk.frameworks.Kernel
|
|
||||||
darwin.apple_sdk.frameworks.CoreVideo
|
|
||||||
darwin.CF
|
|
||||||
];
|
|
||||||
}) super.bindings-GLFW;
|
|
||||||
OpenCL = overrideCabal (drv: {
|
|
||||||
librarySystemDepends = [];
|
|
||||||
libraryHaskellDepends = drv.libraryHaskellDepends ++ [
|
|
||||||
darwin.apple_sdk.frameworks.OpenCL
|
|
||||||
];
|
|
||||||
}) super.OpenCL;
|
|
||||||
|
|
||||||
# cabal2nix likes to generate dependencies on hinotify when hfsevents is
|
|
||||||
# really required on darwin: https://github.com/NixOS/cabal2nix/issues/146.
|
|
||||||
hinotify = self.hfsevents;
|
|
||||||
|
|
||||||
# FSEvents API is very buggy and tests are unreliable. See
|
|
||||||
# http://openradar.appspot.com/10207999 and similar issues.
|
|
||||||
fsnotify = addBuildDepend darwin.apple_sdk.frameworks.Cocoa
|
|
||||||
(dontCheck super.fsnotify);
|
|
||||||
|
|
||||||
FractalArt = overrideCabal (drv: {
|
|
||||||
librarySystemDepends = [
|
|
||||||
darwin.libobjc
|
|
||||||
darwin.apple_sdk.frameworks.AppKit
|
|
||||||
] ++ (drv.librarySystemDepends or []);
|
|
||||||
}) super.FractalArt;
|
|
||||||
|
|
||||||
arbtt = overrideCabal (drv: {
|
|
||||||
librarySystemDepends = [
|
|
||||||
darwin.apple_sdk.frameworks.Foundation
|
|
||||||
darwin.apple_sdk.frameworks.Carbon
|
|
||||||
darwin.apple_sdk.frameworks.IOKit
|
|
||||||
] ++ (drv.librarySystemDepends or []);
|
|
||||||
}) super.arbtt;
|
|
||||||
|
|
||||||
HTF = overrideCabal (drv: {
|
|
||||||
# GNU find is not prefixed in stdenv
|
|
||||||
postPatch = ''
|
|
||||||
substituteInPlace scripts/local-htfpp --replace "find=gfind" "find=find"
|
|
||||||
'' + (drv.postPatch or "");
|
|
||||||
}) super.HTF;
|
|
||||||
|
|
||||||
# conditional dependency via a cabal flag
|
|
||||||
cas-store = overrideCabal (drv: {
|
|
||||||
libraryHaskellDepends = [
|
|
||||||
self.kqueue
|
|
||||||
] ++ (drv.libraryHaskellDepends or []);
|
|
||||||
}) super.cas-store;
|
|
||||||
|
|
||||||
# We are lacking pure pgrep at the moment for tests to work
|
|
||||||
tmp-postgres = dontCheck super.tmp-postgres;
|
|
||||||
|
|
||||||
# On darwin librt doesn't exist and will fail to link against,
|
|
||||||
# however linking against it is also not necessary there
|
|
||||||
GLHUI = overrideCabal (drv: {
|
|
||||||
postPatch = ''
|
|
||||||
substituteInPlace GLHUI.cabal --replace " rt" ""
|
|
||||||
'' + (drv.postPatch or "");
|
|
||||||
}) super.GLHUI;
|
|
||||||
|
|
||||||
SDL-image = overrideCabal (drv: {
|
|
||||||
# Prevent darwin-specific configuration code path being taken
|
|
||||||
# which doesn't work with nixpkgs' SDL libraries
|
|
||||||
postPatch = ''
|
|
||||||
substituteInPlace configure --replace xDarwin noDarwinSpecialCasing
|
|
||||||
'' + (drv.postPatch or "");
|
|
||||||
patches = [
|
|
||||||
# Work around SDL_main.h redefining main to SDL_main
|
|
||||||
./patches/SDL-image-darwin-hsc.patch
|
|
||||||
];
|
|
||||||
}) super.SDL-image;
|
|
||||||
|
|
||||||
# Prevent darwin-specific configuration code path being taken which
|
|
||||||
# doesn't work with nixpkgs' SDL libraries
|
|
||||||
SDL-mixer = overrideCabal (drv: {
|
|
||||||
postPatch = ''
|
|
||||||
substituteInPlace configure --replace xDarwin noDarwinSpecialCasing
|
|
||||||
'' + (drv.postPatch or "");
|
|
||||||
}) super.SDL-mixer;
|
|
||||||
|
|
||||||
# Work around SDL_main.h redefining main to SDL_main
|
|
||||||
SDL-ttf = appendPatch ./patches/SDL-ttf-darwin-hsc.patch super.SDL-ttf;
|
|
||||||
|
|
||||||
# Disable a bunch of test suites that fail because of darwin's case insensitive
|
|
||||||
# file system: When a test suite has a test suite file that has the same name
|
|
||||||
# as a module in scope, but in different case (e. g. hedgehog.hs and Hedgehog
|
|
||||||
# in scope), GHC will complain that the file name and module name differ (in
|
|
||||||
# the example hedgehog.hs would be Main).
|
|
||||||
# These failures can easily be fixed by upstream by renaming files, so we
|
|
||||||
# should create issues for them.
|
|
||||||
# https://github.com/typeclasses/aws-cloudfront-signed-cookies/issues/2
|
|
||||||
aws-cloudfront-signed-cookies = dontCheck super.aws-cloudfront-signed-cookies;
|
|
||||||
|
|
||||||
# https://github.com/acid-state/acid-state/issues/133
|
|
||||||
acid-state = dontCheck super.acid-state;
|
|
||||||
|
|
||||||
# Otherwise impure gcc is used, which is Apple's weird wrapper
|
|
||||||
c2hsc = addTestToolDepends [ pkgs.gcc ] super.c2hsc;
|
|
||||||
|
|
||||||
http-client-tls = overrideCabal (drv: {
|
|
||||||
postPatch = ''
|
|
||||||
# This comment has been inserted, so the derivation hash changes, forcing
|
|
||||||
# a rebuild of this derivation which has succeeded to build on Hydra before,
|
|
||||||
# but apparently been corrupted, causing reverse dependencies to fail.
|
|
||||||
#
|
|
||||||
# This workaround can be removed upon the next darwin stdenv rebuild,
|
|
||||||
# presumably https://github.com/NixOS/nixpkgs/pull/152850 or the next
|
|
||||||
# full haskellPackages rebuild.
|
|
||||||
'' + drv.postPatch or "";
|
|
||||||
}) super.http-client-tls;
|
|
||||||
|
|
||||||
http2 = super.http2.overrideAttrs (drv: {
|
|
||||||
# Allow access to local networking when the Darwin sandbox is enabled, so http2 can run tests
|
|
||||||
# that access localhost.
|
|
||||||
__darwinAllowLocalNetworking = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
foldl = overrideCabal (drv: {
|
|
||||||
postPatch = ''
|
|
||||||
# This comment has been inserted, so the derivation hash changes, forcing
|
|
||||||
# a rebuild of this derivation which has succeeded to build on Hydra before,
|
|
||||||
# but apparently been corrupted, causing reverse dependencies to fail.
|
|
||||||
#
|
|
||||||
# This workaround can be removed upon the next darwin stdenv rebuild,
|
|
||||||
# presumably https://github.com/NixOS/nixpkgs/pull/152850 or the next
|
|
||||||
# full haskellPackages rebuild.
|
|
||||||
'' + drv.postPatch or "";
|
|
||||||
}) super.foldl;
|
|
||||||
|
|
||||||
# https://hydra.nixos.org/build/230964714/nixlog/1
|
|
||||||
inline-c-cpp = appendPatch (pkgs.fetchpatch {
|
|
||||||
url = "https://github.com/fpco/inline-c/commit/e8dc553b13bb847409fdced649a6a863323cff8a.patch";
|
|
||||||
name = "revert-use-system-cxx-std-lib.patch";
|
|
||||||
sha256 = "sha256-ql1/+8bvmWexyCdFR0VS4M4cY2lD0Px/9dHYLqlKyNA=";
|
|
||||||
revert = true;
|
|
||||||
stripLen = 1;
|
|
||||||
}) super.inline-c-cpp;
|
|
||||||
|
|
||||||
# Tests fail on macOS https://github.com/mrkkrp/zip/issues/112
|
|
||||||
zip = dontCheck super.zip;
|
|
||||||
} // lib.optionalAttrs pkgs.stdenv.isAarch64 { # aarch64-darwin
|
|
||||||
|
|
||||||
# https://github.com/fpco/unliftio/issues/87
|
|
||||||
unliftio = dontCheck super.unliftio;
|
|
||||||
# This is the same issue as above; the rio tests call functions in unliftio
|
|
||||||
# that have issues as tracked in the GitHub issue above. Once the unliftio
|
|
||||||
# tests are fixed, we can remove this as well.
|
|
||||||
#
|
|
||||||
# We skip just the problematic tests by replacing 'it' with 'xit'.
|
|
||||||
rio = overrideCabal (drv: {
|
|
||||||
preConfigure = ''
|
|
||||||
sed -i 's/\bit /xit /g' test/RIO/FileSpec.hs
|
|
||||||
'';
|
|
||||||
}) super.rio;
|
|
||||||
|
|
||||||
# https://github.com/haskell-crypto/cryptonite/issues/360
|
|
||||||
cryptonite = appendPatch ./patches/cryptonite-remove-argon2.patch super.cryptonite;
|
|
||||||
|
|
||||||
# Build segfaults unless `fixity-th` is disabled.
|
|
||||||
# https://github.com/tweag/ormolu/issues/927
|
|
||||||
ormolu = overrideCabal (drv: {
|
|
||||||
libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
|
|
||||||
}) (disableCabalFlag "fixity-th" super.ormolu);
|
|
||||||
fourmolu = overrideCabal (drv: {
|
|
||||||
libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
|
|
||||||
}) (disableCabalFlag "fixity-th" super.fourmolu);
|
|
||||||
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/149692
|
|
||||||
Agda = disableCabalFlag "optimise-heavily" super.Agda;
|
|
||||||
|
|
||||||
} // lib.optionalAttrs pkgs.stdenv.isx86_64 { # x86_64-darwin
|
|
||||||
|
|
||||||
# tests appear to be failing to link or something:
|
|
||||||
# https://hydra.nixos.org/build/174540882/nixlog/9
|
|
||||||
regex-rure = dontCheck super.regex-rure;
|
|
||||||
# same
|
|
||||||
# https://hydra.nixos.org/build/174540882/nixlog/9
|
|
||||||
jacinda = dontCheck super.jacinda;
|
|
||||||
})
|
|
|
@ -1,191 +0,0 @@
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
with haskellLib;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs.stdenv.hostPlatform) isDarwin;
|
|
||||||
inherit (pkgs) lib;
|
|
||||||
in
|
|
||||||
|
|
||||||
self: super: {
|
|
||||||
|
|
||||||
# ghcjs does not use `llvmPackages` and exposes `null` attribute.
|
|
||||||
llvmPackages =
|
|
||||||
if self.ghc.llvmPackages != null
|
|
||||||
then pkgs.lib.dontRecurseIntoAttrs self.ghc.llvmPackages
|
|
||||||
else null;
|
|
||||||
|
|
||||||
# Disable GHC 8.10.x core libraries.
|
|
||||||
array = null;
|
|
||||||
base = null;
|
|
||||||
binary = null;
|
|
||||||
bytestring = null;
|
|
||||||
Cabal = null;
|
|
||||||
containers = null;
|
|
||||||
deepseq = null;
|
|
||||||
directory = null;
|
|
||||||
exceptions = null;
|
|
||||||
filepath = null;
|
|
||||||
ghc-boot = null;
|
|
||||||
ghc-boot-th = null;
|
|
||||||
ghc-compact = null;
|
|
||||||
ghc-heap = null;
|
|
||||||
ghc-prim = null;
|
|
||||||
ghci = null;
|
|
||||||
haskeline = null;
|
|
||||||
hpc = null;
|
|
||||||
integer-gmp = null;
|
|
||||||
libiserv = null;
|
|
||||||
mtl = null;
|
|
||||||
parsec = null;
|
|
||||||
pretty = null;
|
|
||||||
process = null;
|
|
||||||
rts = null;
|
|
||||||
stm = null;
|
|
||||||
template-haskell = null;
|
|
||||||
# GHC only builds terminfo if it is a native compiler
|
|
||||||
terminfo = if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then null else doDistribute self.terminfo_0_4_1_6;
|
|
||||||
text = null;
|
|
||||||
time = null;
|
|
||||||
transformers = null;
|
|
||||||
unix = null;
|
|
||||||
# GHC only bundles the xhtml library if haddock is enabled, check if this is
|
|
||||||
# still the case when updating: https://gitlab.haskell.org/ghc/ghc/-/blob/0198841877f6f04269d6050892b98b5c3807ce4c/ghc.mk#L463
|
|
||||||
xhtml = if self.ghc.hasHaddock or true then null else doDistribute self.xhtml_3000_3_0_0;
|
|
||||||
|
|
||||||
# Need the Cabal-syntax-3.6.0.0 fake package for Cabal < 3.8 to allow callPackage and the constraint solver to work
|
|
||||||
Cabal-syntax = self.Cabal-syntax_3_6_0_0;
|
|
||||||
# These core package only exist for GHC >= 9.4. The best we can do is feign
|
|
||||||
# their existence to callPackages, but their is no shim for lower GHC versions.
|
|
||||||
system-cxx-std-lib = null;
|
|
||||||
|
|
||||||
# For GHC < 9.4, some packages need data-array-byte as an extra dependency
|
|
||||||
# For GHC < 9.2, os-string is not required.
|
|
||||||
primitive = addBuildDepends [ self.data-array-byte ] super.primitive;
|
|
||||||
hashable = addBuildDepends [
|
|
||||||
self.data-array-byte
|
|
||||||
self.base-orphans
|
|
||||||
] (super.hashable.override {
|
|
||||||
os-string = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
# Too strict lower bounds on base
|
|
||||||
primitive-addr = doJailbreak super.primitive-addr;
|
|
||||||
|
|
||||||
# Pick right versions for GHC-specific packages
|
|
||||||
ghc-api-compat = doDistribute (unmarkBroken self.ghc-api-compat_8_10_7);
|
|
||||||
|
|
||||||
# Needs to use ghc-lib due to incompatible GHC
|
|
||||||
ghc-tags = doDistribute (addBuildDepend self.ghc-lib self.ghc-tags_1_5);
|
|
||||||
|
|
||||||
# Jailbreak to fix the build.
|
|
||||||
base-noprelude = doJailbreak super.base-noprelude;
|
|
||||||
unliftio-core = doJailbreak super.unliftio-core;
|
|
||||||
|
|
||||||
# Jailbreaking because monoidal-containers hasn’t bumped it's base dependency for 8.10.
|
|
||||||
monoidal-containers = doJailbreak super.monoidal-containers;
|
|
||||||
|
|
||||||
# Jailbreak to fix the build.
|
|
||||||
brick = doJailbreak super.brick;
|
|
||||||
exact-pi = doJailbreak super.exact-pi;
|
|
||||||
serialise = doJailbreak super.serialise;
|
|
||||||
setlocale = doJailbreak super.setlocale;
|
|
||||||
shellmet = doJailbreak super.shellmet;
|
|
||||||
shower = doJailbreak super.shower;
|
|
||||||
|
|
||||||
# hnix 0.9.0 does not provide an executable for ghc < 8.10, so define completions here for now.
|
|
||||||
hnix = self.generateOptparseApplicativeCompletions [ "hnix" ]
|
|
||||||
(overrideCabal (drv: {
|
|
||||||
# executable is allowed for ghc >= 8.10 and needs repline
|
|
||||||
executableHaskellDepends = drv.executableToolDepends or [] ++ [ self.repline ];
|
|
||||||
}) super.hnix);
|
|
||||||
|
|
||||||
haskell-language-server = throw "haskell-language-server dropped support for ghc 8.10 in version 2.3.0.0 please use a newer ghc version or an older nixpkgs version";
|
|
||||||
|
|
||||||
ghc-lib-parser = doDistribute self.ghc-lib-parser_9_2_8_20230729;
|
|
||||||
ghc-lib-parser-ex = doDistribute self.ghc-lib-parser-ex_9_2_1_1;
|
|
||||||
ghc-lib = doDistribute self.ghc-lib_9_2_8_20230729;
|
|
||||||
|
|
||||||
path-io = doJailbreak super.path-io;
|
|
||||||
|
|
||||||
hlint = self.hlint_3_4_1;
|
|
||||||
|
|
||||||
mime-string = disableOptimization super.mime-string;
|
|
||||||
|
|
||||||
# weeder 2.3.* no longer supports GHC 8.10
|
|
||||||
weeder = doDistribute (doJailbreak self.weeder_2_2_0);
|
|
||||||
# Unnecessarily strict upper bound on lens
|
|
||||||
weeder_2_2_0 = doJailbreak (super.weeder_2_2_0.override {
|
|
||||||
# weeder < 2.6 only supports algebraic-graphs < 0.7
|
|
||||||
# We no longer have matching test deps for algebraic-graphs 0.6.1 in the set
|
|
||||||
algebraic-graphs = dontCheck self.algebraic-graphs_0_6_1;
|
|
||||||
});
|
|
||||||
|
|
||||||
# Overly-strict bounds introducted by a revision in version 0.3.2.
|
|
||||||
text-metrics = doJailbreak super.text-metrics;
|
|
||||||
|
|
||||||
# Doesn't build with 9.0, see https://github.com/yi-editor/yi/issues/1125
|
|
||||||
yi-core = doDistribute (markUnbroken super.yi-core);
|
|
||||||
|
|
||||||
# Temporarily disabled blaze-textual for GHC >= 9.0 causing hackage2nix ignoring it
|
|
||||||
# https://github.com/paul-rouse/mysql-simple/blob/872604f87044ff6d1a240d9819a16c2bdf4ed8f5/Database/MySQL/Internal/Blaze.hs#L4-L10
|
|
||||||
mysql-simple = addBuildDepends [
|
|
||||||
self.blaze-textual
|
|
||||||
] super.mysql-simple;
|
|
||||||
|
|
||||||
taffybar = markUnbroken (doDistribute super.taffybar);
|
|
||||||
|
|
||||||
# https://github.com/fpco/inline-c/issues/127 (recommend to upgrade to Nixpkgs GHC >=9.0)
|
|
||||||
inline-c-cpp = (if isDarwin then dontCheck else x: x) super.inline-c-cpp;
|
|
||||||
|
|
||||||
# Depends on OneTuple for GHC < 9.0
|
|
||||||
universe-base = addBuildDepends [ self.OneTuple ] super.universe-base;
|
|
||||||
|
|
||||||
# Not possible to build in the main GHC 9.0 package set
|
|
||||||
# https://github.com/awakesecurity/spectacle/issues/49
|
|
||||||
spectacle = doDistribute (markUnbroken super.spectacle);
|
|
||||||
|
|
||||||
# doctest-parallel dependency requires newer Cabal
|
|
||||||
regex-tdfa = dontCheck super.regex-tdfa;
|
|
||||||
|
|
||||||
# Unnecessarily strict lower bound on base
|
|
||||||
# https://github.com/mrkkrp/megaparsec/pull/485#issuecomment-1250051823
|
|
||||||
megaparsec = doJailbreak super.megaparsec;
|
|
||||||
|
|
||||||
retrie = dontCheck self.retrie_1_1_0_0;
|
|
||||||
|
|
||||||
# Later versions only support GHC >= 9.2
|
|
||||||
ghc-exactprint = self.ghc-exactprint_0_6_4;
|
|
||||||
|
|
||||||
apply-refact = self.apply-refact_0_9_3_0;
|
|
||||||
|
|
||||||
# Needs OneTuple for ghc < 9.2
|
|
||||||
binary-orphans = addBuildDepends [ self.OneTuple ] super.binary-orphans;
|
|
||||||
|
|
||||||
# Requires GHC < 9.4
|
|
||||||
ghc-source-gen = doDistribute (unmarkBroken super.ghc-source-gen);
|
|
||||||
|
|
||||||
# No instance for (Show B.Builder) arising from a use of ‘print’
|
|
||||||
http-types = dontCheck super.http-types;
|
|
||||||
|
|
||||||
# Packages which need compat library for GHC < 9.6
|
|
||||||
inherit
|
|
||||||
(lib.mapAttrs
|
|
||||||
(_: addBuildDepends [ self.foldable1-classes-compat ])
|
|
||||||
super)
|
|
||||||
indexed-traversable
|
|
||||||
these
|
|
||||||
;
|
|
||||||
base-compat-batteries = addBuildDepends [
|
|
||||||
self.foldable1-classes-compat
|
|
||||||
self.OneTuple
|
|
||||||
] super.base-compat-batteries;
|
|
||||||
|
|
||||||
# OneTuple needs hashable (instead of ghc-prim) and foldable1-classes-compat for GHC < 9
|
|
||||||
OneTuple = addBuildDepends [
|
|
||||||
self.foldable1-classes-compat
|
|
||||||
self.base-orphans
|
|
||||||
] (super.OneTuple.override {
|
|
||||||
ghc-prim = self.hashable;
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,112 +0,0 @@
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
with haskellLib;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs.stdenv.hostPlatform) isDarwin;
|
|
||||||
in
|
|
||||||
|
|
||||||
self: super: {
|
|
||||||
|
|
||||||
# Should be llvmPackages_6 which has been removed from nixpkgs
|
|
||||||
llvmPackages = null;
|
|
||||||
|
|
||||||
# Disable GHC 8.6.x core libraries.
|
|
||||||
array = null;
|
|
||||||
base = null;
|
|
||||||
binary = null;
|
|
||||||
bytestring = null;
|
|
||||||
Cabal = null;
|
|
||||||
containers = null;
|
|
||||||
deepseq = null;
|
|
||||||
directory = null;
|
|
||||||
filepath = null;
|
|
||||||
ghc-boot = null;
|
|
||||||
ghc-boot-th = null;
|
|
||||||
ghc-compact = null;
|
|
||||||
ghc-heap = null;
|
|
||||||
ghc-prim = null;
|
|
||||||
ghci = null;
|
|
||||||
haskeline = null;
|
|
||||||
hpc = null;
|
|
||||||
integer-gmp = null;
|
|
||||||
libiserv = null;
|
|
||||||
mtl = null;
|
|
||||||
parsec = null;
|
|
||||||
pretty = null;
|
|
||||||
process = null;
|
|
||||||
rts = null;
|
|
||||||
stm = null;
|
|
||||||
template-haskell = null;
|
|
||||||
# GHC only builds terminfo if it is a native compiler
|
|
||||||
terminfo = if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then null else doDistribute self.terminfo_0_4_1_6;
|
|
||||||
text = null;
|
|
||||||
time = null;
|
|
||||||
transformers = null;
|
|
||||||
unix = null;
|
|
||||||
# GHC only bundles the xhtml library if haddock is enabled, check if this is
|
|
||||||
# still the case when updating: https://gitlab.haskell.org/ghc/ghc/-/blob/0198841877f6f04269d6050892b98b5c3807ce4c/ghc.mk#L463
|
|
||||||
xhtml = if self.ghc.hasHaddock or true then null else doDistribute self.xhtml_3000_3_0_0;
|
|
||||||
|
|
||||||
# Need the Cabal-syntax-3.6.0.0 fake package for Cabal < 3.8 to allow callPackage and the constraint solver to work
|
|
||||||
Cabal-syntax = self.Cabal-syntax_3_6_0_0;
|
|
||||||
# These core package only exist for GHC >= 9.4. The best we can do is feign
|
|
||||||
# their existence to callPackages, but their is no shim for lower GHC versions.
|
|
||||||
system-cxx-std-lib = null;
|
|
||||||
|
|
||||||
# Needs Cabal 3.0.x.
|
|
||||||
jailbreak-cabal = super.jailbreak-cabal.overrideScope (cself: _: { Cabal = cself.Cabal_3_2_1_0; });
|
|
||||||
|
|
||||||
# https://github.com/tibbe/unordered-containers/issues/214
|
|
||||||
unordered-containers = dontCheck super.unordered-containers;
|
|
||||||
|
|
||||||
# Test suite does not compile.
|
|
||||||
data-clist = doJailbreak super.data-clist; # won't cope with QuickCheck 2.12.x
|
|
||||||
dates = doJailbreak super.dates; # base >=4.9 && <4.12
|
|
||||||
Diff = dontCheck super.Diff;
|
|
||||||
equivalence = dontCheck super.equivalence; # test suite doesn't compile https://github.com/pa-ba/equivalence/issues/5
|
|
||||||
HaTeX = doJailbreak super.HaTeX; # containers >=0.4 && <0.6 is too tight; https://github.com/Daniel-Diaz/HaTeX/issues/126
|
|
||||||
hpc-coveralls = doJailbreak super.hpc-coveralls; # https://github.com/guillaume-nargeot/hpc-coveralls/issues/82
|
|
||||||
http-api-data = doJailbreak super.http-api-data;
|
|
||||||
persistent-sqlite = dontCheck super.persistent-sqlite;
|
|
||||||
system-fileio = dontCheck super.system-fileio; # avoid dependency on broken "patience"
|
|
||||||
unicode-transforms = dontCheck super.unicode-transforms;
|
|
||||||
wl-pprint-extras = doJailbreak super.wl-pprint-extras; # containers >=0.4 && <0.6 is too tight; https://github.com/ekmett/wl-pprint-extras/issues/17
|
|
||||||
RSA = dontCheck super.RSA; # https://github.com/GaloisInc/RSA/issues/14
|
|
||||||
github = dontCheck super.github; # hspec upper bound exceeded; https://github.com/phadej/github/pull/341
|
|
||||||
binary-orphans = dontCheck super.binary-orphans; # tasty upper bound exceeded; https://github.com/phadej/binary-orphans/commit/8ce857226595dd520236ff4c51fa1a45d8387b33
|
|
||||||
rebase = doJailbreak super.rebase; # time ==1.9.* is too low
|
|
||||||
|
|
||||||
# https://github.com/jgm/skylighting/issues/55
|
|
||||||
skylighting-core = dontCheck super.skylighting-core;
|
|
||||||
|
|
||||||
# cabal2nix needs the latest version of Cabal, and the one
|
|
||||||
# hackage-db uses must match, so take the latest
|
|
||||||
cabal2nix = super.cabal2nix.overrideScope (self: super: { Cabal = self.Cabal_3_2_1_0; });
|
|
||||||
|
|
||||||
# cabal2spec needs a recent version of Cabal
|
|
||||||
cabal2spec = super.cabal2spec.overrideScope (self: super: { Cabal = self.Cabal_3_2_1_0; });
|
|
||||||
|
|
||||||
# https://github.com/pikajude/stylish-cabal/issues/12
|
|
||||||
stylish-cabal = doDistribute (markUnbroken (super.stylish-cabal.override { haddock-library = self.haddock-library_1_7_0; }));
|
|
||||||
haddock-library_1_7_0 = dontCheck super.haddock-library_1_7_0;
|
|
||||||
|
|
||||||
# ghc versions prior to 8.8.x needs additional dependency to compile successfully.
|
|
||||||
ghc-lib-parser-ex = addBuildDepend self.ghc-lib-parser super.ghc-lib-parser-ex;
|
|
||||||
|
|
||||||
# This became a core library in ghc 8.10., so we don’t have an "exception" attribute anymore.
|
|
||||||
exceptions = self.exceptions_0_10_7;
|
|
||||||
|
|
||||||
# vector 0.12.2 indroduced doctest checks that don’t work on older compilers
|
|
||||||
vector = dontCheck super.vector;
|
|
||||||
|
|
||||||
mmorph = super.mmorph_1_1_3;
|
|
||||||
|
|
||||||
# https://github.com/haskellari/time-compat/issues/23
|
|
||||||
time-compat = dontCheck super.time-compat;
|
|
||||||
|
|
||||||
mime-string = disableOptimization super.mime-string;
|
|
||||||
|
|
||||||
# https://github.com/fpco/inline-c/issues/127 (recommend to upgrade to Nixpkgs GHC >=9.0)
|
|
||||||
inline-c-cpp = (if isDarwin then dontCheck else x: x) super.inline-c-cpp;
|
|
||||||
}
|
|
|
@ -1,162 +0,0 @@
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
with haskellLib;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs.stdenv.hostPlatform) isDarwin;
|
|
||||||
inherit (pkgs) lib;
|
|
||||||
in
|
|
||||||
|
|
||||||
self: super: {
|
|
||||||
|
|
||||||
llvmPackages = pkgs.lib.dontRecurseIntoAttrs self.ghc.llvmPackages;
|
|
||||||
|
|
||||||
# Disable GHC 9.0.x core libraries.
|
|
||||||
array = null;
|
|
||||||
base = null;
|
|
||||||
binary = null;
|
|
||||||
bytestring = null;
|
|
||||||
Cabal = null;
|
|
||||||
containers = null;
|
|
||||||
deepseq = null;
|
|
||||||
directory = null;
|
|
||||||
exceptions = null;
|
|
||||||
filepath = null;
|
|
||||||
ghc-bignum = null;
|
|
||||||
ghc-boot = null;
|
|
||||||
ghc-boot-th = null;
|
|
||||||
ghc-compact = null;
|
|
||||||
ghc-heap = null;
|
|
||||||
ghc-prim = null;
|
|
||||||
ghci = null;
|
|
||||||
haskeline = null;
|
|
||||||
hpc = null;
|
|
||||||
integer-gmp = null;
|
|
||||||
libiserv = null;
|
|
||||||
mtl = null;
|
|
||||||
parsec = null;
|
|
||||||
pretty = null;
|
|
||||||
process = null;
|
|
||||||
rts = null;
|
|
||||||
stm = null;
|
|
||||||
template-haskell = null;
|
|
||||||
# GHC only builds terminfo if it is a native compiler
|
|
||||||
terminfo = if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then null else doDistribute self.terminfo_0_4_1_6;
|
|
||||||
text = null;
|
|
||||||
time = null;
|
|
||||||
transformers = null;
|
|
||||||
unix = null;
|
|
||||||
# GHC only bundles the xhtml library if haddock is enabled, check if this is
|
|
||||||
# still the case when updating: https://gitlab.haskell.org/ghc/ghc/-/blob/0198841877f6f04269d6050892b98b5c3807ce4c/ghc.mk#L463
|
|
||||||
xhtml = if self.ghc.hasHaddock or true then null else doDistribute self.xhtml_3000_3_0_0;
|
|
||||||
|
|
||||||
# Need the Cabal-syntax-3.6.0.0 fake package for Cabal < 3.8 to allow callPackage and the constraint solver to work
|
|
||||||
Cabal-syntax = self.Cabal-syntax_3_6_0_0;
|
|
||||||
# These core package only exist for GHC >= 9.4. The best we can do is feign
|
|
||||||
# their existence to callPackages, but their is no shim for lower GHC versions.
|
|
||||||
system-cxx-std-lib = null;
|
|
||||||
|
|
||||||
# Jailbreaks & Version Updates
|
|
||||||
|
|
||||||
# For GHC < 9.4, some packages need data-array-byte as an extra dependency
|
|
||||||
primitive = addBuildDepends [ self.data-array-byte ] super.primitive;
|
|
||||||
# For GHC < 9.2, os-string is not required.
|
|
||||||
hashable = addBuildDepends [
|
|
||||||
self.data-array-byte
|
|
||||||
self.base-orphans
|
|
||||||
] (super.hashable.override {
|
|
||||||
os-string = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
# Too strict lower bounds on base
|
|
||||||
primitive-addr = doJailbreak super.primitive-addr;
|
|
||||||
|
|
||||||
hashable-time = doJailbreak super.hashable-time;
|
|
||||||
tuple = addBuildDepend self.base-orphans super.tuple;
|
|
||||||
vector-th-unbox = doJailbreak super.vector-th-unbox;
|
|
||||||
|
|
||||||
ormolu = self.ormolu_0_5_2_0.override {
|
|
||||||
Cabal-syntax = self.Cabal-syntax_3_8_1_0;
|
|
||||||
};
|
|
||||||
|
|
||||||
stylish-haskell = doJailbreak super.stylish-haskell_0_14_4_0;
|
|
||||||
|
|
||||||
doctest = dontCheck super.doctest;
|
|
||||||
|
|
||||||
haskell-language-server = throw "haskell-language-server has dropped support for ghc 9.0 in version 2.4.0.0, please use a newer ghc version or an older nixpkgs version";
|
|
||||||
|
|
||||||
# Needs to use ghc-lib due to incompatible GHC
|
|
||||||
ghc-tags = doDistribute (addBuildDepend self.ghc-lib self.ghc-tags_1_6);
|
|
||||||
|
|
||||||
# Test suite sometimes segfaults with GHC 9.0.1 and 9.0.2
|
|
||||||
# https://github.com/ekmett/reflection/issues/51
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/21141
|
|
||||||
reflection = dontCheck super.reflection;
|
|
||||||
|
|
||||||
# Disable tests pending resolution of
|
|
||||||
# https://github.com/Soostone/retry/issues/71
|
|
||||||
retry = dontCheck super.retry;
|
|
||||||
|
|
||||||
ghc-api-compat = unmarkBroken super.ghc-api-compat;
|
|
||||||
|
|
||||||
# 2021-09-18: cabal2nix does not detect the need for ghc-api-compat.
|
|
||||||
hiedb = overrideCabal (old: {
|
|
||||||
libraryHaskellDepends = old.libraryHaskellDepends ++ [self.ghc-api-compat];
|
|
||||||
}) super.hiedb;
|
|
||||||
|
|
||||||
# https://github.com/lspitzner/butcher/issues/7
|
|
||||||
butcher = doJailbreak super.butcher;
|
|
||||||
|
|
||||||
# We use a GHC patch to support the fix for https://github.com/fpco/inline-c/issues/127
|
|
||||||
# which means that the upstream cabal file isn't allowed to add the flag.
|
|
||||||
inline-c-cpp =
|
|
||||||
(if isDarwin then appendConfigureFlags ["--ghc-option=-fcompact-unwind"] else x: x)
|
|
||||||
super.inline-c-cpp;
|
|
||||||
|
|
||||||
# 2022-05-31: weeder 2.4.* requires GHC 9.2
|
|
||||||
weeder = doDistribute self.weeder_2_3_1;
|
|
||||||
# Unnecessarily strict upper bound on lens
|
|
||||||
weeder_2_3_1 = doJailbreak (super.weeder_2_3_1.override {
|
|
||||||
# weeder < 2.6 only supports algebraic-graphs < 0.7
|
|
||||||
# We no longer have matching test deps for algebraic-graphs 0.6.1 in the set
|
|
||||||
algebraic-graphs = dontCheck self.algebraic-graphs_0_6_1;
|
|
||||||
});
|
|
||||||
|
|
||||||
# Restrictive upper bound on base and containers
|
|
||||||
sv2v = doJailbreak super.sv2v;
|
|
||||||
|
|
||||||
# Later versions only support GHC >= 9.2
|
|
||||||
ghc-exactprint = self.ghc-exactprint_0_6_4;
|
|
||||||
|
|
||||||
retrie = dontCheck self.retrie_1_1_0_0;
|
|
||||||
|
|
||||||
apply-refact = self.apply-refact_0_9_3_0;
|
|
||||||
|
|
||||||
# Needs OneTuple for ghc < 9.2
|
|
||||||
binary-orphans = addBuildDepends [ self.OneTuple ] super.binary-orphans;
|
|
||||||
|
|
||||||
# Requires GHC < 9.4
|
|
||||||
ghc-source-gen = doDistribute (unmarkBroken super.ghc-source-gen);
|
|
||||||
|
|
||||||
hspec-megaparsec = super.hspec-megaparsec_2_2_0;
|
|
||||||
|
|
||||||
# No instance for (Show B.Builder) arising from a use of ‘print’
|
|
||||||
http-types = dontCheck super.http-types;
|
|
||||||
|
|
||||||
# Packages which need compat library for GHC < 9.6
|
|
||||||
inherit
|
|
||||||
(lib.mapAttrs
|
|
||||||
(_: addBuildDepends [ self.foldable1-classes-compat ])
|
|
||||||
super)
|
|
||||||
indexed-traversable
|
|
||||||
these
|
|
||||||
;
|
|
||||||
base-compat-batteries = addBuildDepends [
|
|
||||||
self.foldable1-classes-compat
|
|
||||||
self.OneTuple
|
|
||||||
] super.base-compat-batteries;
|
|
||||||
OneTuple = addBuildDepends [
|
|
||||||
self.foldable1-classes-compat
|
|
||||||
self.base-orphans
|
|
||||||
] super.OneTuple;
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs) lib;
|
|
||||||
in
|
|
||||||
|
|
||||||
self: super: {
|
|
||||||
llvmPackages = lib.dontRecurseIntoAttrs self.ghc.llvmPackages;
|
|
||||||
|
|
||||||
# Disable GHC core libraries
|
|
||||||
array = null;
|
|
||||||
base = null;
|
|
||||||
binary = null;
|
|
||||||
bytestring = null;
|
|
||||||
Cabal = null;
|
|
||||||
Cabal-syntax = null;
|
|
||||||
containers = null;
|
|
||||||
deepseq = null;
|
|
||||||
directory = null;
|
|
||||||
exceptions = null;
|
|
||||||
filepath = null;
|
|
||||||
ghc-bignum = null;
|
|
||||||
ghc-boot = null;
|
|
||||||
ghc-boot-th = null;
|
|
||||||
ghc-compact = null;
|
|
||||||
ghc-experimental = null;
|
|
||||||
ghc-heap = null;
|
|
||||||
ghc-internal = null;
|
|
||||||
ghc-platform = null;
|
|
||||||
ghc-prim = null;
|
|
||||||
ghc-toolchain = null;
|
|
||||||
ghci = null;
|
|
||||||
haskeline = null;
|
|
||||||
hpc = null;
|
|
||||||
integer-gmp = null;
|
|
||||||
mtl = null;
|
|
||||||
parsec = null;
|
|
||||||
pretty = null;
|
|
||||||
process = null;
|
|
||||||
rts = null;
|
|
||||||
semaphore-compat = null;
|
|
||||||
stm = null;
|
|
||||||
system-cxx-std-lib = null;
|
|
||||||
template-haskell = null;
|
|
||||||
# GHC only builds terminfo if it is a native compiler
|
|
||||||
terminfo = if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then null else haskellLib.doDistribute self.terminfo_0_4_1_6;
|
|
||||||
text = null;
|
|
||||||
time = null;
|
|
||||||
transformers = null;
|
|
||||||
unix = null;
|
|
||||||
xhtml = null;
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs) lib;
|
|
||||||
in
|
|
||||||
|
|
||||||
self: super: {
|
|
||||||
llvmPackages = lib.dontRecurseIntoAttrs self.ghc.llvmPackages;
|
|
||||||
|
|
||||||
# Disable GHC core libraries
|
|
||||||
array = null;
|
|
||||||
base = null;
|
|
||||||
binary = null;
|
|
||||||
bytestring = null;
|
|
||||||
Cabal = null;
|
|
||||||
Cabal-syntax = null;
|
|
||||||
containers = null;
|
|
||||||
deepseq = null;
|
|
||||||
directory = null;
|
|
||||||
exceptions = null;
|
|
||||||
filepath = null;
|
|
||||||
ghc-bignum = null;
|
|
||||||
ghc-boot = null;
|
|
||||||
ghc-boot-th = null;
|
|
||||||
ghc-compact = null;
|
|
||||||
ghc-experimental = null;
|
|
||||||
ghc-heap = null;
|
|
||||||
ghc-internal = null;
|
|
||||||
ghc-platform = null;
|
|
||||||
ghc-prim = null;
|
|
||||||
ghc-toolchain = null;
|
|
||||||
ghci = null;
|
|
||||||
haskeline = null;
|
|
||||||
hpc = null;
|
|
||||||
integer-gmp = null;
|
|
||||||
mtl = null;
|
|
||||||
os-string = null;
|
|
||||||
parsec = null;
|
|
||||||
pretty = null;
|
|
||||||
process = null;
|
|
||||||
rts = null;
|
|
||||||
semaphore-compat = null;
|
|
||||||
stm = null;
|
|
||||||
system-cxx-std-lib = null;
|
|
||||||
template-haskell = null;
|
|
||||||
# GHC only builds terminfo if it is a native compiler
|
|
||||||
terminfo = if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then null else haskellLib.doDistribute self.terminfo_0_4_1_6;
|
|
||||||
text = null;
|
|
||||||
time = null;
|
|
||||||
transformers = null;
|
|
||||||
unix = null;
|
|
||||||
xhtml = null;
|
|
||||||
}
|
|
|
@ -1,151 +0,0 @@
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
with haskellLib;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs.stdenv.hostPlatform) isDarwin;
|
|
||||||
inherit (pkgs) lib;
|
|
||||||
in
|
|
||||||
|
|
||||||
self: super: {
|
|
||||||
|
|
||||||
llvmPackages = pkgs.lib.dontRecurseIntoAttrs self.ghc.llvmPackages;
|
|
||||||
|
|
||||||
# Disable GHC 9.2.x core libraries.
|
|
||||||
array = null;
|
|
||||||
base = null;
|
|
||||||
binary = null;
|
|
||||||
bytestring = null;
|
|
||||||
Cabal = null;
|
|
||||||
containers = null;
|
|
||||||
deepseq = null;
|
|
||||||
directory = null;
|
|
||||||
exceptions = null;
|
|
||||||
filepath = null;
|
|
||||||
ghc-bignum = null;
|
|
||||||
ghc-boot = null;
|
|
||||||
ghc-boot-th = null;
|
|
||||||
ghc-compact = null;
|
|
||||||
ghc-heap = null;
|
|
||||||
ghc-prim = null;
|
|
||||||
ghci = null;
|
|
||||||
haskeline = null;
|
|
||||||
hpc = null;
|
|
||||||
integer-gmp = null;
|
|
||||||
libiserv = null;
|
|
||||||
mtl = null;
|
|
||||||
parsec = null;
|
|
||||||
pretty = null;
|
|
||||||
process = null;
|
|
||||||
rts = null;
|
|
||||||
stm = null;
|
|
||||||
template-haskell = null;
|
|
||||||
# GHC only builds terminfo if it is a native compiler
|
|
||||||
terminfo = if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then null else doDistribute self.terminfo_0_4_1_6;
|
|
||||||
text = null;
|
|
||||||
time = null;
|
|
||||||
transformers = null;
|
|
||||||
unix = null;
|
|
||||||
# GHC only bundles the xhtml library if haddock is enabled, check if this is
|
|
||||||
# still the case when updating: https://gitlab.haskell.org/ghc/ghc/-/blob/0198841877f6f04269d6050892b98b5c3807ce4c/ghc.mk#L463
|
|
||||||
xhtml = if self.ghc.hasHaddock or true then null else doDistribute self.xhtml_3000_3_0_0;
|
|
||||||
|
|
||||||
# Need the Cabal-syntax-3.6.0.0 fake package for Cabal < 3.8 to allow callPackage and the constraint solver to work
|
|
||||||
Cabal-syntax = self.Cabal-syntax_3_6_0_0;
|
|
||||||
# These core package only exist for GHC >= 9.4. The best we can do is feign
|
|
||||||
# their existence to callPackages, but their is no shim for lower GHC versions.
|
|
||||||
system-cxx-std-lib = null;
|
|
||||||
|
|
||||||
# weeder >= 2.5 requires GHC 9.4
|
|
||||||
weeder = doDistribute self.weeder_2_4_1;
|
|
||||||
# Allow dhall 1.42.*
|
|
||||||
weeder_2_4_1 = doJailbreak (super.weeder_2_4_1.override {
|
|
||||||
# weeder < 2.6 only supports algebraic-graphs < 0.7
|
|
||||||
# We no longer have matching test deps for algebraic-graphs 0.6.1 in the set
|
|
||||||
algebraic-graphs = dontCheck self.algebraic-graphs_0_6_1;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
haskell-language-server = lib.pipe super.haskell-language-server [
|
|
||||||
(disableCabalFlag "fourmolu")
|
|
||||||
(disableCabalFlag "ormolu")
|
|
||||||
(disableCabalFlag "stylishHaskell")
|
|
||||||
(overrideCabal (drv: {
|
|
||||||
# Disabling the build flags isn't enough: `Setup configure` still configures
|
|
||||||
# every component for building and complains about missing dependencies.
|
|
||||||
# Thus we have to mark the undesired components as non-buildable.
|
|
||||||
postPatch = drv.postPatch or "" + ''
|
|
||||||
for lib in hls-ormolu-plugin hls-fourmolu-plugin; do
|
|
||||||
sed -i "/^library $lib/a\ buildable: False" haskell-language-server.cabal
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
}))
|
|
||||||
(d: d.override {
|
|
||||||
ormolu = null;
|
|
||||||
fourmolu = null;
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
# For GHC < 9.4, some packages need data-array-byte as an extra dependency
|
|
||||||
hashable = addBuildDepends [ self.data-array-byte ] super.hashable;
|
|
||||||
primitive = addBuildDepends [ self.data-array-byte ] super.primitive;
|
|
||||||
primitive-unlifted = super.primitive-unlifted_0_1_3_1;
|
|
||||||
# Too strict lower bound on base
|
|
||||||
primitive-addr = doJailbreak super.primitive-addr;
|
|
||||||
|
|
||||||
# Jailbreaks & Version Updates
|
|
||||||
hashable-time = doJailbreak super.hashable-time;
|
|
||||||
|
|
||||||
# Depends on utf8-light which isn't maintained / doesn't support base >= 4.16
|
|
||||||
# https://github.com/haskell-infra/hackage-trustees/issues/347
|
|
||||||
# https://mail.haskell.org/pipermail/haskell-cafe/2022-October/135613.html
|
|
||||||
language-javascript_0_7_0_0 = dontCheck super.language-javascript_0_7_0_0;
|
|
||||||
|
|
||||||
# Tests depend on `parseTime` which is no longer available
|
|
||||||
hourglass = dontCheck super.hourglass;
|
|
||||||
|
|
||||||
# Needs to match ghc version
|
|
||||||
ghc-tags = doDistribute self.ghc-tags_1_5;
|
|
||||||
|
|
||||||
# For "ghc-lib" flag see https://github.com/haskell/haskell-language-server/issues/3185#issuecomment-1250264515
|
|
||||||
hlint = enableCabalFlag "ghc-lib" super.hlint;
|
|
||||||
|
|
||||||
# 0.2.2.3 requires Cabal >= 3.8
|
|
||||||
shake-cabal = doDistribute self.shake-cabal_0_2_2_2;
|
|
||||||
|
|
||||||
# https://github.com/sjakobi/bsb-http-chunked/issues/38
|
|
||||||
bsb-http-chunked = dontCheck super.bsb-http-chunked;
|
|
||||||
|
|
||||||
# https://github.com/NixOS/cabal2nix/issues/554
|
|
||||||
# https://github.com/clash-lang/clash-compiler/blob/f0f6275e19b8c672f042026c478484c5fd45191d/README.md#ghc-compatibility
|
|
||||||
clash-prelude = dontDistribute (markBroken super.clash-prelude);
|
|
||||||
|
|
||||||
# Too strict upper bound on bytestring, relevant for GHC 9.2.6 specifically
|
|
||||||
# https://github.com/protolude/protolude/issues/127#issuecomment-1428807874
|
|
||||||
protolude = doJailbreak super.protolude;
|
|
||||||
|
|
||||||
# https://github.com/fpco/inline-c/pull/131
|
|
||||||
inline-c-cpp =
|
|
||||||
(if isDarwin then appendConfigureFlags ["--ghc-option=-fcompact-unwind"] else x: x)
|
|
||||||
super.inline-c-cpp;
|
|
||||||
|
|
||||||
# A given major version of ghc-exactprint only supports one version of GHC.
|
|
||||||
ghc-exactprint = super.ghc-exactprint_1_5_0;
|
|
||||||
|
|
||||||
# Requires GHC < 9.4
|
|
||||||
ghc-source-gen = doDistribute (unmarkBroken super.ghc-source-gen);
|
|
||||||
|
|
||||||
# Packages which need compat library for GHC < 9.6
|
|
||||||
inherit
|
|
||||||
(lib.mapAttrs
|
|
||||||
(_: addBuildDepends [ self.foldable1-classes-compat ])
|
|
||||||
super)
|
|
||||||
indexed-traversable
|
|
||||||
OneTuple
|
|
||||||
these
|
|
||||||
;
|
|
||||||
base-compat-batteries = addBuildDepends [
|
|
||||||
self.foldable1-classes-compat
|
|
||||||
self.OneTuple
|
|
||||||
] super.base-compat-batteries;
|
|
||||||
}
|
|
|
@ -1,143 +0,0 @@
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs) fetchpatch lib;
|
|
||||||
checkAgainAfter = pkg: ver: msg: act:
|
|
||||||
if builtins.compareVersions pkg.version ver <= 0 then act
|
|
||||||
else
|
|
||||||
builtins.throw "Check if '${msg}' was resolved in ${pkg.pname} ${pkg.version} and update or remove this";
|
|
||||||
in
|
|
||||||
|
|
||||||
with haskellLib;
|
|
||||||
self: super: let
|
|
||||||
jailbreakForCurrentVersion = p: v: checkAgainAfter p v "bad bounds" (doJailbreak p);
|
|
||||||
in {
|
|
||||||
llvmPackages = lib.dontRecurseIntoAttrs self.ghc.llvmPackages;
|
|
||||||
|
|
||||||
# Disable GHC core libraries.
|
|
||||||
array = null;
|
|
||||||
base = null;
|
|
||||||
binary = null;
|
|
||||||
bytestring = null;
|
|
||||||
Cabal = null;
|
|
||||||
Cabal-syntax = null;
|
|
||||||
containers = null;
|
|
||||||
deepseq = null;
|
|
||||||
directory = null;
|
|
||||||
exceptions = null;
|
|
||||||
filepath = null;
|
|
||||||
ghc-bignum = null;
|
|
||||||
ghc-boot = null;
|
|
||||||
ghc-boot-th = null;
|
|
||||||
ghc-compact = null;
|
|
||||||
ghc-heap = null;
|
|
||||||
ghc-prim = null;
|
|
||||||
ghci = null;
|
|
||||||
haskeline = null;
|
|
||||||
hpc = null;
|
|
||||||
integer-gmp = null;
|
|
||||||
libiserv = null;
|
|
||||||
mtl = null;
|
|
||||||
parsec = null;
|
|
||||||
pretty = null;
|
|
||||||
process = null;
|
|
||||||
rts = null;
|
|
||||||
stm = null;
|
|
||||||
system-cxx-std-lib = null;
|
|
||||||
template-haskell = null;
|
|
||||||
# GHC only builds terminfo if it is a native compiler
|
|
||||||
terminfo = if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then null else doDistribute self.terminfo_0_4_1_6;
|
|
||||||
text = null;
|
|
||||||
time = null;
|
|
||||||
transformers = null;
|
|
||||||
unix = null;
|
|
||||||
# GHC only bundles the xhtml library if haddock is enabled, check if this is
|
|
||||||
# still the case when updating: https://gitlab.haskell.org/ghc/ghc/-/blob/0198841877f6f04269d6050892b98b5c3807ce4c/ghc.mk#L463
|
|
||||||
xhtml = if self.ghc.hasHaddock or true then null else doDistribute self.xhtml_3000_3_0_0;
|
|
||||||
|
|
||||||
# Jailbreaks & Version Updates
|
|
||||||
|
|
||||||
hashable-time = doJailbreak super.hashable-time;
|
|
||||||
libmpd = doJailbreak super.libmpd;
|
|
||||||
|
|
||||||
# generically needs base-orphans for 9.4 only
|
|
||||||
base-orphans = dontCheck (doDistribute super.base-orphans);
|
|
||||||
generically = addBuildDepends [
|
|
||||||
self.base-orphans
|
|
||||||
] super.generically;
|
|
||||||
|
|
||||||
# the dontHaddock is due to a GHC panic. might be this bug, not sure.
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/21619
|
|
||||||
hedgehog = dontHaddock super.hedgehog;
|
|
||||||
|
|
||||||
hpack = overrideCabal (drv: {
|
|
||||||
# Cabal 3.6 seems to preserve comments when reading, which makes this test fail
|
|
||||||
# 2021-10-10: 9.2.1 is not yet supported (also no issue)
|
|
||||||
testFlags = [
|
|
||||||
"--skip=/Hpack/renderCabalFile/is inverse to readCabalFile/"
|
|
||||||
] ++ drv.testFlags or [];
|
|
||||||
}) (doJailbreak super.hpack);
|
|
||||||
|
|
||||||
# Tests depend on `parseTime` which is no longer available
|
|
||||||
hourglass = dontCheck super.hourglass;
|
|
||||||
|
|
||||||
# https://github.com/sjakobi/bsb-http-chunked/issues/38
|
|
||||||
bsb-http-chunked = dontCheck super.bsb-http-chunked;
|
|
||||||
|
|
||||||
# 2022-08-01: Tests are broken on ghc 9.2.4: https://github.com/wz1000/HieDb/issues/46
|
|
||||||
hiedb = dontCheck super.hiedb;
|
|
||||||
|
|
||||||
# 2022-10-06: https://gitlab.haskell.org/ghc/ghc/-/issues/22260
|
|
||||||
ghc-check = dontHaddock super.ghc-check;
|
|
||||||
|
|
||||||
ghc-tags = self.ghc-tags_1_6;
|
|
||||||
|
|
||||||
# A given major version of ghc-exactprint only supports one version of GHC.
|
|
||||||
ghc-exactprint = super.ghc-exactprint_1_6_1_3;
|
|
||||||
|
|
||||||
# Too strict upper bound on template-haskell
|
|
||||||
# https://github.com/mokus0/th-extras/issues/18
|
|
||||||
th-extras = doJailbreak super.th-extras;
|
|
||||||
|
|
||||||
# https://github.com/kowainik/relude/issues/436
|
|
||||||
relude = dontCheck super.relude;
|
|
||||||
|
|
||||||
inherit
|
|
||||||
(
|
|
||||||
let
|
|
||||||
hls_overlay = lself: lsuper: {
|
|
||||||
Cabal-syntax = lself.Cabal-syntax_3_10_3_0;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
lib.mapAttrs (_: pkg: doDistribute (pkg.overrideScope hls_overlay)) {
|
|
||||||
haskell-language-server = allowInconsistentDependencies super.haskell-language-server;
|
|
||||||
fourmolu = super.fourmolu;
|
|
||||||
ormolu = super.ormolu;
|
|
||||||
hlint = super.hlint;
|
|
||||||
stylish-haskell = super.stylish-haskell;
|
|
||||||
}
|
|
||||||
)
|
|
||||||
haskell-language-server
|
|
||||||
fourmolu
|
|
||||||
ormolu
|
|
||||||
hlint
|
|
||||||
stylish-haskell
|
|
||||||
;
|
|
||||||
|
|
||||||
# Packages which need compat library for GHC < 9.6
|
|
||||||
inherit
|
|
||||||
(lib.mapAttrs
|
|
||||||
(_: addBuildDepends [ self.foldable1-classes-compat ])
|
|
||||||
super)
|
|
||||||
indexed-traversable
|
|
||||||
OneTuple
|
|
||||||
these
|
|
||||||
;
|
|
||||||
base-compat-batteries = addBuildDepends [
|
|
||||||
self.foldable1-classes-compat
|
|
||||||
self.OneTuple
|
|
||||||
] super.base-compat-batteries;
|
|
||||||
|
|
||||||
# Too strict lower bound on base
|
|
||||||
primitive-addr = doJailbreak super.primitive-addr;
|
|
||||||
}
|
|
|
@ -1,194 +0,0 @@
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
with haskellLib;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs) lib;
|
|
||||||
|
|
||||||
jailbreakWhileRevision = rev:
|
|
||||||
overrideCabal (old: {
|
|
||||||
jailbreak = assert old.revision or "0" == toString rev; true;
|
|
||||||
});
|
|
||||||
checkAgainAfter = pkg: ver: msg: act:
|
|
||||||
if builtins.compareVersions pkg.version ver <= 0 then act
|
|
||||||
else
|
|
||||||
builtins.throw "Check if '${msg}' was resolved in ${pkg.pname} ${pkg.version} and update or remove this";
|
|
||||||
jailbreakForCurrentVersion = p: v: checkAgainAfter p v "bad bounds" (doJailbreak p);
|
|
||||||
|
|
||||||
# Workaround for a ghc-9.6 issue: https://gitlab.haskell.org/ghc/ghc/-/issues/23392
|
|
||||||
disableParallelBuilding = overrideCabal (drv: { enableParallelBuilding = false; });
|
|
||||||
in
|
|
||||||
|
|
||||||
self: super: {
|
|
||||||
llvmPackages = lib.dontRecurseIntoAttrs self.ghc.llvmPackages;
|
|
||||||
|
|
||||||
# Disable GHC core libraries
|
|
||||||
array = null;
|
|
||||||
base = null;
|
|
||||||
binary = null;
|
|
||||||
bytestring = null;
|
|
||||||
Cabal = null;
|
|
||||||
Cabal-syntax = null;
|
|
||||||
containers = null;
|
|
||||||
deepseq = null;
|
|
||||||
directory = null;
|
|
||||||
exceptions = null;
|
|
||||||
filepath = null;
|
|
||||||
ghc-bignum = null;
|
|
||||||
ghc-boot = null;
|
|
||||||
ghc-boot-th = null;
|
|
||||||
ghc-compact = null;
|
|
||||||
ghc-heap = null;
|
|
||||||
ghc-prim = null;
|
|
||||||
ghci = null;
|
|
||||||
haskeline = null;
|
|
||||||
hpc = null;
|
|
||||||
integer-gmp = null;
|
|
||||||
libiserv = null;
|
|
||||||
mtl = null;
|
|
||||||
parsec = null;
|
|
||||||
pretty = null;
|
|
||||||
process = null;
|
|
||||||
rts = null;
|
|
||||||
stm = null;
|
|
||||||
system-cxx-std-lib = null;
|
|
||||||
template-haskell = null;
|
|
||||||
# terminfo is not built if GHC is a cross compiler
|
|
||||||
terminfo = if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then null else doDistribute self.terminfo_0_4_1_6;
|
|
||||||
text = null;
|
|
||||||
time = null;
|
|
||||||
transformers = null;
|
|
||||||
unix = null;
|
|
||||||
xhtml = null;
|
|
||||||
|
|
||||||
#
|
|
||||||
# Version deviations from Stackage LTS
|
|
||||||
#
|
|
||||||
|
|
||||||
# Too strict upper bound on template-haskell
|
|
||||||
# https://github.com/mokus0/th-extras/pull/21
|
|
||||||
th-extras = doJailbreak super.th-extras;
|
|
||||||
|
|
||||||
#
|
|
||||||
# Too strict bounds without upstream fix
|
|
||||||
#
|
|
||||||
|
|
||||||
# Forbids transformers >= 0.6
|
|
||||||
quickcheck-classes-base = doJailbreak super.quickcheck-classes-base;
|
|
||||||
# https://github.com/Gabriella439/Haskell-Break-Library/pull/3
|
|
||||||
break = doJailbreak super.break;
|
|
||||||
# Forbids mtl >= 2.3
|
|
||||||
ChasingBottoms = doJailbreak super.ChasingBottoms;
|
|
||||||
# Forbids base >= 4.18
|
|
||||||
cabal-install-solver = doJailbreak super.cabal-install-solver;
|
|
||||||
cabal-install = doJailbreak super.cabal-install;
|
|
||||||
|
|
||||||
# Forbids base >= 4.18, fix proposed: https://github.com/sjakobi/newtype-generics/pull/25
|
|
||||||
newtype-generics = jailbreakForCurrentVersion super.newtype-generics "0.6.2";
|
|
||||||
|
|
||||||
#
|
|
||||||
# Too strict bounds, waiting on Hackage release in nixpkgs
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# Compilation failure workarounds
|
|
||||||
#
|
|
||||||
|
|
||||||
# Add support for time 1.10
|
|
||||||
# https://github.com/vincenthz/hs-hourglass/pull/56
|
|
||||||
hourglass = appendPatches [
|
|
||||||
(pkgs.fetchpatch {
|
|
||||||
name = "hourglass-pr-56.patch";
|
|
||||||
url =
|
|
||||||
"https://github.com/vincenthz/hs-hourglass/commit/cfc2a4b01f9993b1b51432f0a95fa6730d9a558a.patch";
|
|
||||||
sha256 = "sha256-gntZf7RkaR4qzrhjrXSC69jE44SknPDBmfs4z9rVa5Q=";
|
|
||||||
})
|
|
||||||
] (super.hourglass);
|
|
||||||
|
|
||||||
# Jailbreaks for servant <0.20
|
|
||||||
servant-lucid = doJailbreak super.servant-lucid;
|
|
||||||
|
|
||||||
lifted-base = dontCheck super.lifted-base;
|
|
||||||
hw-prim = dontCheck (doJailbreak super.hw-prim);
|
|
||||||
stm-containers = dontCheck super.stm-containers;
|
|
||||||
regex-tdfa = dontCheck super.regex-tdfa;
|
|
||||||
hiedb = dontCheck super.hiedb;
|
|
||||||
retrie = dontCheck super.retrie;
|
|
||||||
# https://github.com/kowainik/relude/issues/436
|
|
||||||
relude = dontCheck (doJailbreak super.relude);
|
|
||||||
|
|
||||||
inherit (pkgs.lib.mapAttrs (_: doJailbreak ) super)
|
|
||||||
ghc-trace-events
|
|
||||||
gi-cairo-connector # mtl <2.3
|
|
||||||
ghc-prof # base <4.18
|
|
||||||
env-guard # doctest <0.21
|
|
||||||
package-version # doctest <0.21, tasty-hedgehog <1.4
|
|
||||||
;
|
|
||||||
|
|
||||||
# Avoid triggering an issue in ghc-9.6.2
|
|
||||||
gi-gtk = disableParallelBuilding super.gi-gtk;
|
|
||||||
|
|
||||||
# Pending text-2.0 support https://github.com/gtk2hs/gtk2hs/issues/327
|
|
||||||
gtk = doJailbreak super.gtk;
|
|
||||||
|
|
||||||
# 2023-12-23: It needs this to build under ghc-9.6.3.
|
|
||||||
# A factor of 100 is insufficent, 200 seems seems to work.
|
|
||||||
hip = appendConfigureFlag "--ghc-options=-fsimpl-tick-factor=200" super.hip;
|
|
||||||
|
|
||||||
# Doctest comments have bogus imports.
|
|
||||||
bsb-http-chunked = dontCheck super.bsb-http-chunked;
|
|
||||||
|
|
||||||
# This can be removed once https://github.com/typeclasses/ascii-predicates/pull/1
|
|
||||||
# is merged and in a release that's being tracked.
|
|
||||||
ascii-predicates = appendPatch
|
|
||||||
(pkgs.fetchpatch
|
|
||||||
{ url = "https://github.com/typeclasses/ascii-predicates/commit/2e6d9ed45987a8566f3a77eedf7836055c076d1a.patch";
|
|
||||||
name = "ascii-predicates-pull-1.patch";
|
|
||||||
relative = "ascii-predicates";
|
|
||||||
sha256 = "sha256-4JguQFZNRQpjZThLrAo13jNeypvLfqFp6o7c1bnkmZo=";
|
|
||||||
})
|
|
||||||
super.ascii-predicates;
|
|
||||||
|
|
||||||
# This can be removed once https://github.com/typeclasses/ascii-numbers/pull/1
|
|
||||||
# is merged and in a release that's being tracked.
|
|
||||||
ascii-numbers = appendPatch
|
|
||||||
(pkgs.fetchpatch
|
|
||||||
{ url = "https://github.com/typeclasses/ascii-numbers/commit/e9474ad91bc997891f1a46afd5d0bdf9b9f7d768.patch";
|
|
||||||
name = "ascii-numbers-pull-1.patch";
|
|
||||||
relative = "ascii-numbers";
|
|
||||||
sha256 = "sha256-buw1UeW57CFefEfqdDUraSyQ+H/NvCZOv6WF2ORiYQg=";
|
|
||||||
})
|
|
||||||
super.ascii-numbers;
|
|
||||||
|
|
||||||
# Fix ghc-9.6.x build errors.
|
|
||||||
libmpd = appendPatch
|
|
||||||
# https://github.com/vimus/libmpd-haskell/pull/138
|
|
||||||
(pkgs.fetchpatch { url = "https://github.com/vimus/libmpd-haskell/compare/95d3b3bab5858d6d1f0e079d0ab7c2d182336acb...5737096a339edc265a663f51ad9d29baee262694.patch";
|
|
||||||
name = "vimus-libmpd-haskell-pull-138.patch";
|
|
||||||
sha256 = "sha256-CvvylXyRmoCoRJP2MzRwL0SBbrEzDGqAjXS+4LsLutQ=";
|
|
||||||
})
|
|
||||||
super.libmpd;
|
|
||||||
|
|
||||||
# Apply patch from PR with mtl-2.3 fix.
|
|
||||||
ConfigFile = overrideCabal (drv: {
|
|
||||||
editedCabalFile = null;
|
|
||||||
buildDepends = drv.buildDepends or [] ++ [ self.HUnit ];
|
|
||||||
patches = [(pkgs.fetchpatch {
|
|
||||||
# https://github.com/jgoerzen/configfile/pull/12
|
|
||||||
name = "ConfigFile-pr-12.patch";
|
|
||||||
url = "https://github.com/jgoerzen/configfile/compare/d0a2e654be0b73eadbf2a50661d00574ad7b6f87...83ee30b43f74d2b6781269072cf5ed0f0e00012f.patch";
|
|
||||||
sha256 = "sha256-b7u9GiIAd2xpOrM0MfILHNb6Nt7070lNRIadn2l3DfQ=";
|
|
||||||
})];
|
|
||||||
}) super.ConfigFile;
|
|
||||||
}
|
|
||||||
# super.ghc is required to break infinite recursion as Nix is strict in the attrNames
|
|
||||||
// lib.optionalAttrs (pkgs.stdenv.hostPlatform.isAarch64 && lib.versionOlder super.ghc.version "9.6.4") {
|
|
||||||
# The NCG backend for aarch64 generates invalid jumps in some situations,
|
|
||||||
# the workaround on 9.6 is to revert to the LLVM backend (which is used
|
|
||||||
# for these sorts of situations even on 9.2 and 9.4).
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/23746#note_525318
|
|
||||||
inherit (lib.mapAttrs (_: self.forceLlvmCodegenBackend) super)
|
|
||||||
tls
|
|
||||||
mmark
|
|
||||||
;
|
|
||||||
}
|
|
|
@ -1,134 +0,0 @@
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
with haskellLib;
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs.stdenv.hostPlatform) isDarwin;
|
|
||||||
in
|
|
||||||
|
|
||||||
self: super: {
|
|
||||||
|
|
||||||
llvmPackages = pkgs.lib.dontRecurseIntoAttrs self.ghc.llvmPackages;
|
|
||||||
|
|
||||||
# Disable GHC core libraries.
|
|
||||||
array = null;
|
|
||||||
base = null;
|
|
||||||
binary = null;
|
|
||||||
bytestring = null;
|
|
||||||
Cabal = null;
|
|
||||||
Cabal-syntax = null;
|
|
||||||
containers = null;
|
|
||||||
deepseq = null;
|
|
||||||
directory = null;
|
|
||||||
exceptions = null;
|
|
||||||
filepath = null;
|
|
||||||
ghc-bignum = null;
|
|
||||||
ghc-boot = null;
|
|
||||||
ghc-boot-th = null;
|
|
||||||
ghc-compact = null;
|
|
||||||
ghc-heap = null;
|
|
||||||
ghc-prim = null;
|
|
||||||
ghci = null;
|
|
||||||
haskeline = null;
|
|
||||||
hpc = null;
|
|
||||||
integer-gmp = null;
|
|
||||||
libiserv = null;
|
|
||||||
mtl = null;
|
|
||||||
parsec = null;
|
|
||||||
pretty = null;
|
|
||||||
process = null;
|
|
||||||
rts = null;
|
|
||||||
stm = null;
|
|
||||||
system-cxx-std-lib = null;
|
|
||||||
template-haskell = null;
|
|
||||||
# GHC only builds terminfo if it is a native compiler
|
|
||||||
terminfo = if pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform then null else doDistribute self.terminfo_0_4_1_6;
|
|
||||||
text = null;
|
|
||||||
time = null;
|
|
||||||
transformers = null;
|
|
||||||
unix = null;
|
|
||||||
xhtml = null;
|
|
||||||
|
|
||||||
#
|
|
||||||
# Version upgrades
|
|
||||||
#
|
|
||||||
th-abstraction = doDistribute self.th-abstraction_0_7_0_0;
|
|
||||||
ghc-lib-parser = doDistribute self.ghc-lib-parser_9_8_2_20240223;
|
|
||||||
ghc-lib-parser-ex = doDistribute self.ghc-lib-parser-ex_9_8_0_2;
|
|
||||||
ghc-lib = doDistribute self.ghc-lib_9_8_2_20240223;
|
|
||||||
megaparsec = doDistribute self.megaparsec_9_6_1;
|
|
||||||
# TODO: remove when aeson updates or launches a revision
|
|
||||||
# see https://github.com/haskell/aeson/issues/1089 and https://github.com/haskell/aeson/pulls/1088
|
|
||||||
aeson = doJailbreak (doDistribute self.aeson_2_2_1_0);
|
|
||||||
attoparsec-aeson = doDistribute self.attoparsec-aeson_2_2_0_1;
|
|
||||||
xmonad = doDistribute self.xmonad_0_18_0;
|
|
||||||
apply-refact = self.apply-refact_0_14_0_0;
|
|
||||||
ormolu = self.ormolu_0_7_4_0;
|
|
||||||
fourmolu = self.fourmolu_0_15_0_0;
|
|
||||||
stylish-haskell = self.stylish-haskell_0_14_6_0;
|
|
||||||
hlint = self.hlint_3_8;
|
|
||||||
ghc-syntax-highlighter = self.ghc-syntax-highlighter_0_0_11_0;
|
|
||||||
|
|
||||||
# A given major version of ghc-exactprint only supports one version of GHC.
|
|
||||||
ghc-exactprint = self.ghc-exactprint_1_8_0_0;
|
|
||||||
ghc-exactprint_1_8_0_0 = addBuildDepends [
|
|
||||||
self.Diff
|
|
||||||
self.HUnit
|
|
||||||
self.data-default
|
|
||||||
self.extra
|
|
||||||
self.free
|
|
||||||
self.ghc-paths
|
|
||||||
self.ordered-containers
|
|
||||||
self.silently
|
|
||||||
self.syb
|
|
||||||
] super.ghc-exactprint_1_8_0_0;
|
|
||||||
|
|
||||||
#
|
|
||||||
# Jailbreaks
|
|
||||||
#
|
|
||||||
blaze-svg = doJailbreak super.blaze-svg; # base <4.19
|
|
||||||
commutative-semigroups = doJailbreak super.commutative-semigroups; # base < 4.19
|
|
||||||
diagrams-lib = doJailbreak super.diagrams-lib; # base <4.19, text <2.1
|
|
||||||
diagrams-postscript = doJailbreak super.diagrams-postscript; # base <4.19, bytestring <0.12
|
|
||||||
diagrams-svg = doJailbreak super.diagrams-svg; # base <4.19, text <2.1
|
|
||||||
ghc-trace-events = doJailbreak super.ghc-trace-events; # text < 2.1, bytestring < 0.12, base < 4.19
|
|
||||||
primitive-unlifted = doJailbreak super.primitive-unlifted; # bytestring < 0.12
|
|
||||||
statestack = doJailbreak super.statestack; # base < 4.19
|
|
||||||
newtype-generics = doJailbreak super.newtype-generics; # base < 4.19
|
|
||||||
hw-prim = doJailbreak super.hw-prim; # doctest < 0.22, ghc-prim < 0.11, hedgehog < 1.4
|
|
||||||
svg-builder = doJailbreak super.svg-builder; # base <4.19, bytestring <0.12, text <2.1
|
|
||||||
# Too strict bound on base, believe it or not.
|
|
||||||
# https://github.com/judah/terminfo/pull/55#issuecomment-1876894232
|
|
||||||
terminfo_0_4_1_6 = doJailbreak super.terminfo_0_4_1_6;
|
|
||||||
HaskellNet-SSL = doJailbreak super.HaskellNet-SSL; # bytestring >=0.9 && <0.12
|
|
||||||
raven-haskell = doJailbreak super.raven-haskell; # aeson <2.2
|
|
||||||
stripe-concepts = doJailbreak super.stripe-concepts; # text >=1.2.5 && <1.3 || >=2.0 && <2.1
|
|
||||||
stripe-signature = doJailbreak super.stripe-signature; # text >=1.2.5 && <1.3 || >=2.0 && <2.1
|
|
||||||
string-random = doJailbreak super.string-random; # text >=1.2.2.1 && <2.1
|
|
||||||
inflections = doJailbreak super.inflections; # text >=0.2 && <2.1
|
|
||||||
|
|
||||||
#
|
|
||||||
# Test suite issues
|
|
||||||
#
|
|
||||||
unordered-containers = dontCheck super.unordered-containers; # ChasingBottoms doesn't support base 4.20
|
|
||||||
lifted-base = dontCheck super.lifted-base; # doesn't compile with transformers == 0.6.*
|
|
||||||
hourglass = dontCheck super.hourglass; # umaintained, test suite doesn't compile anymore
|
|
||||||
bsb-http-chunked = dontCheck super.bsb-http-chunked; # umaintained, test suite doesn't compile anymore
|
|
||||||
pcre-heavy = dontCheck super.pcre-heavy; # GHC warnings cause the tests to fail
|
|
||||||
|
|
||||||
#
|
|
||||||
# Other build fixes
|
|
||||||
#
|
|
||||||
|
|
||||||
# 2023-12-23: It needs this to build under ghc-9.6.3.
|
|
||||||
# A factor of 100 is insufficent, 200 seems seems to work.
|
|
||||||
hip = appendConfigureFlag "--ghc-options=-fsimpl-tick-factor=200" super.hip;
|
|
||||||
|
|
||||||
# Fix build with text-2.x.
|
|
||||||
libmpd = appendPatch (pkgs.fetchpatch
|
|
||||||
{ url = "https://github.com/vimus/libmpd-haskell/pull/138.patch";
|
|
||||||
sha256 = "Q4fA2J/Tq+WernBo+UIMdj604ILOMlIYkG4Pr046DfM=";
|
|
||||||
})
|
|
||||||
super.libmpd;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,133 +0,0 @@
|
||||||
# GHCJS package fixes
|
|
||||||
#
|
|
||||||
# Please insert new packages *alphabetically*
|
|
||||||
# in the OTHER PACKAGES section.
|
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
let
|
|
||||||
removeLibraryHaskellDepends = pnames: depends:
|
|
||||||
builtins.filter (e: !(builtins.elem (e.pname or "") pnames)) depends;
|
|
||||||
in
|
|
||||||
|
|
||||||
with haskellLib;
|
|
||||||
|
|
||||||
self: super:
|
|
||||||
|
|
||||||
## GENERAL SETUP BASE PACKAGES
|
|
||||||
{
|
|
||||||
inherit (self.ghc.bootPkgs)
|
|
||||||
jailbreak-cabal alex happy gtk2hs-buildtools rehoo hoogle;
|
|
||||||
|
|
||||||
# Test suite fails; https://github.com/ghcjs/ghcjs-base/issues/133
|
|
||||||
ghcjs-base = dontCheck (self.callPackage ../compilers/ghcjs/ghcjs-base.nix {
|
|
||||||
fetchFromGitHub = pkgs.buildPackages.fetchFromGitHub;
|
|
||||||
aeson = self.aeson_1_5_6_0;
|
|
||||||
});
|
|
||||||
|
|
||||||
# GHCJS does not ship with the same core packages as GHC.
|
|
||||||
# https://github.com/ghcjs/ghcjs/issues/676
|
|
||||||
stm = doJailbreak self.stm_2_5_3_0;
|
|
||||||
exceptions = dontCheck self.exceptions_0_10_7;
|
|
||||||
|
|
||||||
## OTHER PACKAGES
|
|
||||||
|
|
||||||
# Runtime exception in tests, missing C API h$realloc
|
|
||||||
base-compat-batteries = dontCheck super.base-compat-batteries;
|
|
||||||
|
|
||||||
# nodejs crashes during test
|
|
||||||
ChasingBottoms = dontCheck super.ChasingBottoms;
|
|
||||||
|
|
||||||
# runs forever
|
|
||||||
text-short = dontCheck super.text-short;
|
|
||||||
|
|
||||||
# doctest doesn't work on ghcjs, but sometimes dontCheck doesn't seem to get rid of the dependency
|
|
||||||
doctest = pkgs.lib.warn "ignoring dependency on doctest" null;
|
|
||||||
|
|
||||||
ghcjs-dom = overrideCabal (drv: {
|
|
||||||
libraryHaskellDepends = with self; [
|
|
||||||
ghcjs-base ghcjs-dom-jsffi text transformers
|
|
||||||
];
|
|
||||||
configureFlags = [ "-fjsffi" "-f-webkit" ];
|
|
||||||
}) super.ghcjs-dom;
|
|
||||||
|
|
||||||
ghcjs-dom-jsffi = overrideCabal (drv: {
|
|
||||||
libraryHaskellDepends = (drv.libraryHaskellDepends or []) ++ [ self.ghcjs-base self.text ];
|
|
||||||
broken = false;
|
|
||||||
}) super.ghcjs-dom-jsffi;
|
|
||||||
|
|
||||||
# https://github.com/Deewiant/glob/issues/39
|
|
||||||
Glob = dontCheck super.Glob;
|
|
||||||
|
|
||||||
# Test fails to compile during the hsc2hs stage
|
|
||||||
hashable = dontCheck super.hashable;
|
|
||||||
|
|
||||||
# uses doctest
|
|
||||||
http-types = dontCheck super.http-types;
|
|
||||||
|
|
||||||
jsaddle = overrideCabal (drv: {
|
|
||||||
libraryHaskellDepends = (drv.libraryHaskellDepends or []) ++ [ self.ghcjs-base ];
|
|
||||||
}) super.jsaddle;
|
|
||||||
|
|
||||||
# Tests hang, possibly some issue with tasty and race(async) usage in the nonTerminating tests
|
|
||||||
logict = dontCheck super.logict;
|
|
||||||
|
|
||||||
patch = dontCheck super.patch;
|
|
||||||
|
|
||||||
# TODO: tests hang
|
|
||||||
pcre-light = dontCheck super.pcre-light;
|
|
||||||
|
|
||||||
# Terminal test not supported on ghcjs
|
|
||||||
QuickCheck = dontCheck super.QuickCheck;
|
|
||||||
|
|
||||||
reflex = overrideCabal (drv: {
|
|
||||||
libraryHaskellDepends = (drv.libraryHaskellDepends or []) ++ [ self.ghcjs-base ];
|
|
||||||
}) super.reflex;
|
|
||||||
|
|
||||||
reflex-dom = overrideCabal (drv: {
|
|
||||||
libraryHaskellDepends = removeLibraryHaskellDepends ["jsaddle-webkit2gtk"] (drv.libraryHaskellDepends or []);
|
|
||||||
}) super.reflex-dom;
|
|
||||||
|
|
||||||
# https://github.com/dreixel/syb/issues/21
|
|
||||||
syb = dontCheck super.syb;
|
|
||||||
|
|
||||||
# nodejs crashes during test
|
|
||||||
scientific = dontCheck super.scientific;
|
|
||||||
|
|
||||||
# Tests use TH which gives error
|
|
||||||
tasty-quickcheck = dontCheck super.tasty-quickcheck;
|
|
||||||
|
|
||||||
temporary = dontCheck super.temporary;
|
|
||||||
|
|
||||||
# 2 tests fail, related to time precision
|
|
||||||
time-compat = dontCheck super.time-compat;
|
|
||||||
|
|
||||||
# TODO: The tests have a TH error, which has been fixed in ghc
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/15481 but somehow the issue is
|
|
||||||
# still present here https://github.com/glguy/th-abstraction/issues/53
|
|
||||||
th-abstraction = dontCheck super.th-abstraction;
|
|
||||||
|
|
||||||
# Need hedgehog for tests, which fails to compile due to dep on concurrent-output
|
|
||||||
zenc = dontCheck super.zenc;
|
|
||||||
|
|
||||||
hspec = self.hspec_2_7_10;
|
|
||||||
hspec-core = self.hspec-core_2_7_10;
|
|
||||||
hspec-meta = self.hspec-meta_2_7_8;
|
|
||||||
hspec-discover = self.hspec-discover_2_7_10;
|
|
||||||
|
|
||||||
# ReferenceError: h$primop_ShrinkSmallMutableArrayOp_Char is not defined
|
|
||||||
unordered-containers = dontCheck super.unordered-containers;
|
|
||||||
|
|
||||||
# Without this revert, test suites using tasty fail with:
|
|
||||||
# ReferenceError: h$getMonotonicNSec is not defined
|
|
||||||
# https://github.com/UnkindPartition/tasty/pull/345#issuecomment-1538216407
|
|
||||||
tasty = appendPatch (pkgs.fetchpatch {
|
|
||||||
name = "tasty-ghcjs.patch";
|
|
||||||
url = "https://github.com/UnkindPartition/tasty/commit/e692065642fd09b82acccea610ad8f49edd207df.patch";
|
|
||||||
revert = true;
|
|
||||||
relative = "core";
|
|
||||||
hash = "sha256-ryABU2ywkVOEPC/jWv8humT3HaRpCwMYEk+Ux3hhi/M=";
|
|
||||||
}) super.tasty;
|
|
||||||
|
|
||||||
# Tests take unacceptably long.
|
|
||||||
vector = dontCheck super.vector;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,869 +0,0 @@
|
||||||
# pkgs/development/haskell-modules/configuration-hackage2nix/main.yaml
|
|
||||||
|
|
||||||
# This is a list of packages with versions from the latest Stackage LTS release.
|
|
||||||
#
|
|
||||||
# The packages and versions in this list cause the `hackage2nix` tool to
|
|
||||||
# generate the package at the given version.
|
|
||||||
#
|
|
||||||
# For instance, with a line like the following:
|
|
||||||
#
|
|
||||||
# - aeson ==1.4.6.0
|
|
||||||
#
|
|
||||||
# `hackage2nix` will generate the `aeson` package at version 1.4.6.0 in the
|
|
||||||
# ./hackage-packages.nix file.
|
|
||||||
#
|
|
||||||
# Since the packages in the LTS package set are sometimes older than the latest
|
|
||||||
# on Hackage, `hackage2nix` is smart enough to also generate the latest version
|
|
||||||
# of a given package.
|
|
||||||
#
|
|
||||||
# In the above example with aeson, if there was version 1.5.0.0 of aeson
|
|
||||||
# available on Hackage, `hackage2nix` would generate two packages, `aeson`
|
|
||||||
# at version 1.4.6.0 and `aeson_1_5_0_0` at version 1.5.0.0.
|
|
||||||
#
|
|
||||||
# WARNING: We import a list of default-package-overrides from stackage which is
|
|
||||||
# tracked in stackage.yaml. Adding conflicting overrides with stackage here will
|
|
||||||
# not work.
|
|
||||||
default-package-overrides:
|
|
||||||
# gi-gdkx11-4.x requires gtk-4.x, but stackage still restricts gi-gtk to 3.*
|
|
||||||
- gi-gdkx11 < 4
|
|
||||||
# 2021-11-09: ghc-bignum is bundled starting with 9.0.1; only 1.0 builds with GHCs prior to 9.2.1
|
|
||||||
- ghc-bignum == 1.0
|
|
||||||
|
|
||||||
extra-packages:
|
|
||||||
- Cabal-syntax == 3.6.* # Dummy package that ensures packages depending on Cabal-syntax can work for Cabal < 3.8
|
|
||||||
- Cabal == 3.2.* # Used for packages needing newer Cabal on ghc 8.6 and 8.8
|
|
||||||
- Cabal == 3.6.* # used for packages needing newer Cabal on ghc 8.10 and 9.0
|
|
||||||
- Cabal-syntax == 3.8.* # version required for ormolu and fourmolu on ghc 9.2 and 9.0
|
|
||||||
- Cabal-syntax == 3.10.* # newest version required for cabal-install and other packages
|
|
||||||
- directory == 1.3.7.* # required to build cabal-install 3.10.* with GHC 9.2
|
|
||||||
- Diff < 0.4 # required by liquidhaskell-0.8.10.2: https://github.com/ucsd-progsys/liquidhaskell/issues/1729
|
|
||||||
- aeson < 2 # required by pantry-0.5.2
|
|
||||||
- apply-refact == 0.9.* # 2022-12-12: needed for GHC < 9.2
|
|
||||||
- apply-refact == 0.11.* # 2023-02-02: needed for hls-hlint-plugin on GHC 9.2
|
|
||||||
- attoparsec == 0.13.* # 2022-02-23: Needed to compile elm for now
|
|
||||||
- base16-bytestring < 1 # required for cabal-install etc.
|
|
||||||
- basement < 0.0.15 # 2022-08-30: last version to support GHC < 8.10
|
|
||||||
- bower-json == 1.0.0.1 # 2022-05-21: Needed for spago 0.20.9
|
|
||||||
- brick == 0.70.* # 2022-08-13: needed by taskell
|
|
||||||
- brittany == 0.13.1.2 # 2022-09-20: needed for hls on ghc 8.8
|
|
||||||
- crackNum < 3.0 # 2021-05-21: 3.0 removed the lib which sbv 7.13 uses
|
|
||||||
- dependent-map == 0.2.4.0 # required by Hasura 1.3.1, 2020-08-20
|
|
||||||
- dependent-sum == 0.4 # required by Hasura 1.3.1, 2020-08-20
|
|
||||||
- doctest == 0.18.* # 2021-11-19: closest to stackage version for GHC 9.*
|
|
||||||
- foundation < 0.0.29 # 2022-08-30: last version to support GHC < 8.10
|
|
||||||
- ghc-api-compat == 8.10.7 # 2022-02-17: preserve for GHC 8.10.7
|
|
||||||
- ghc-api-compat == 8.6 # 2021-09-07: preserve for GHC 8.8.4
|
|
||||||
- ghc-exactprint == 0.6.* # 2022-12-12: needed for GHC < 9.2
|
|
||||||
- ghc-exactprint == 1.5.* # 2023-03-30: needed for GHC == 9.2
|
|
||||||
- ghc-exactprint == 1.6.* # 2023-03-30: needed for GHC == 9.4
|
|
||||||
- ghc-lib == 9.2.* # 2022-02-17: preserve for GHC 9.2
|
|
||||||
- ghc-lib-parser == 9.2.* # 2022-02-17: preserve for GHC 9.2
|
|
||||||
- ghc-lib-parser-ex == 9.2.* # 2022-07-13: preserve for GHC 9.2
|
|
||||||
- ghc-syntax-highlighter == 0.0.10.* # 2023-11-20:
|
|
||||||
- gi-soup == 2.4.28 # 2023-04-05: the last version to support libsoup-2.4 (and thus be compatible with our other gi- packages)
|
|
||||||
- haddock == 2.23.* # required on GHC < 8.10.x
|
|
||||||
- haddock-api == 2.23.* # required on GHC < 8.10.x
|
|
||||||
- haddock-library ==1.7.* # required by stylish-cabal-0.5.0.0
|
|
||||||
- happy == 1.19.12 # for ghcjs
|
|
||||||
- hinotify == 0.3.9 # for xmonad-0.26: https://github.com/kolmodin/hinotify/issues/29
|
|
||||||
- ansi-wl-pprint >= 0.6 && < 0.7 # 2024-03-23: required for ghcjs
|
|
||||||
- hlint == 3.2.8 # 2022-09-21: needed for hls on ghc 8.8
|
|
||||||
- hlint == 3.4.1 # 2022-09-21: needed for hls with ghc-lib-parser 9.2
|
|
||||||
- hnix-store-core < 0.7 # 2023-12-11: required by hnix-store-remote 0.6
|
|
||||||
- hspec < 2.8 # 2022-04-07: Needed for tasty-hspec 1.1.6
|
|
||||||
- hspec-core < 2.8 # 2022-04-07: Needed for tasty-hspec 1.1.6
|
|
||||||
- hspec-discover < 2.8 # 2022-04-07: Needed for tasty-hspec 1.1.6
|
|
||||||
- hspec-megaparsec == 2.2.0 # 2023-11-18: Latest version compatible with ghc 9.0, needed for HLS
|
|
||||||
- hspec-meta < 2.8 # 2022-12-07: Needed for elmPackages.elm / hspec-discover
|
|
||||||
- hspec-golden == 0.1.* # 2022-04-07: Needed for elm-format
|
|
||||||
- http2 < 3.3 # 2023-08-24: Needed for twain <https://github.com/alexmingoia/twain/issues/5>
|
|
||||||
- immortal == 0.2.2.1 # required by Hasura 1.3.1, 2020-08-20
|
|
||||||
- language-docker == 11.0.0 # required by hadolint 2.12.0, 2022-11-16
|
|
||||||
- language-javascript == 0.7.0.0 # required by purescript
|
|
||||||
- lens-aeson < 1.2 # 2022-12-17: For aeson < 2.0 compat
|
|
||||||
- lsp == 2.1.0.0 # 2024-02-28: need for dhall-lsp-server unstable
|
|
||||||
- lsp-types == 2.0.2.0 # 2024-02-28: need for dhall-lsp-server unstable
|
|
||||||
- mmorph == 1.1.3 # Newest working version of mmorph on ghc 8.6.5. needed for hls
|
|
||||||
- network == 2.6.3.1 # required by pkgs/games/hedgewars/default.nix, 2020-11-15
|
|
||||||
- optparse-applicative < 0.16 # needed for niv-0.2.19
|
|
||||||
- fourmolu == 0.11.* # 2023-10-22: for hls on ghc 9.0
|
|
||||||
- fourmolu == 0.14.0.0 # 2023-11-13: for ghc-lib-parser 9.6 compat
|
|
||||||
- ormolu == 0.5.2.0 # 2023-08-08: for hls on ghc 9.0 and 9.2
|
|
||||||
- ormolu == 0.7.2.0 # 2023-11-13: for ghc-lib-parser 9.6 compat
|
|
||||||
- primitive-unlifted == 0.1.3.1 # 2024-03-16: Needed for hls on ghc 9.2
|
|
||||||
- path == 0.9.0 # 2021-12-03: path version building with stackage genvalidity and GHC 9.0.2
|
|
||||||
- resolv < 0.2 # required to build cabal-install-3.10.1.0 with Stackage LTS 21
|
|
||||||
- sbv == 7.13 # required for pkgs.petrinizer
|
|
||||||
- stylish-haskell == 0.14.4.0 # 2022-09-19: needed for hls on ghc 9.2
|
|
||||||
- tasty-hspec == 1.1.6 # 2022-04-07: Needed for elm-format
|
|
||||||
- text == 2.0.2 # 2023-09-14: Needed for elm (which is currently on ghc-8.10)
|
|
||||||
- th-abstraction < 0.6 # 2023-09-11: needed for aeson-2.2.0.0
|
|
||||||
- vty == 5.35.1 # 2022-07-08: needed for glirc-2.39.0.1
|
|
||||||
- warp < 3.3.31 # 2024-03-20: for twain, which requires http2 3.0.3
|
|
||||||
- weeder == 2.2.* # 2022-02-21: preserve for GHC 8.10.7
|
|
||||||
- weeder == 2.3.* # 2022-05-31: preserve for GHC 9.0.2
|
|
||||||
- weeder == 2.4.* # 2023-02-02: preserve for GHC 9.2.*
|
|
||||||
- retrie < 1.2.0.0 # 2022-12-30: required for hls on ghc < 9.2
|
|
||||||
- ghc-tags == 1.5.* # 2023-02-18: preserve for ghc-lib == 9.2.*
|
|
||||||
- ghc-tags == 1.6.* # 2023-02-18: preserve for ghc-lib == 9.4.*
|
|
||||||
- shake-cabal < 0.2.2.3 # 2023-07-01: last version to support Cabal 3.6.*
|
|
||||||
- algebraic-graphs < 0.7 # 2023-08-14: Needed for building weeder < 2.6.0
|
|
||||||
- fuzzyset == 0.2.4 # 2023-12-20: Needed for building postgrest > 10
|
|
||||||
- ShellCheck == 0.9.0 # 2024-03-21: pinned by haskell-ci
|
|
||||||
|
|
||||||
package-maintainers:
|
|
||||||
abbradar:
|
|
||||||
- Agda
|
|
||||||
Anton-Latukha:
|
|
||||||
- hnix
|
|
||||||
- hnix-store-core
|
|
||||||
- hnix-store-remote
|
|
||||||
arturcygan:
|
|
||||||
- hevm
|
|
||||||
athas:
|
|
||||||
- futhark
|
|
||||||
berberman:
|
|
||||||
- nvfetcher
|
|
||||||
- arch-web
|
|
||||||
- uusi
|
|
||||||
bdesham:
|
|
||||||
- pinboard-notes-backup
|
|
||||||
cdepillabout:
|
|
||||||
- password
|
|
||||||
- password-instances
|
|
||||||
- pretty-simple
|
|
||||||
- stack
|
|
||||||
- termonad
|
|
||||||
centromere:
|
|
||||||
- nfc
|
|
||||||
dalpd:
|
|
||||||
- dhall-lsp-server
|
|
||||||
- espial
|
|
||||||
- ghc-vis
|
|
||||||
- patat
|
|
||||||
- svgcairo
|
|
||||||
danielrolls:
|
|
||||||
- byte-count-reader
|
|
||||||
- shellify
|
|
||||||
- specup
|
|
||||||
domenkozar:
|
|
||||||
- cachix
|
|
||||||
- cachix-api
|
|
||||||
dschrempf:
|
|
||||||
- circular
|
|
||||||
- covariance
|
|
||||||
- dirichlet
|
|
||||||
- elynx
|
|
||||||
- elynx-markov
|
|
||||||
- elynx-nexus
|
|
||||||
- elynx-seq
|
|
||||||
- elynx-tools
|
|
||||||
- elynx-tree
|
|
||||||
- glasso
|
|
||||||
- mcmc
|
|
||||||
- pava
|
|
||||||
- slynx
|
|
||||||
- tlynx
|
|
||||||
- xmonad
|
|
||||||
- xmonad-contrib
|
|
||||||
expipiplus1:
|
|
||||||
- VulkanMemoryAllocator
|
|
||||||
- autoapply
|
|
||||||
- exact-real
|
|
||||||
- language-c
|
|
||||||
- orbits
|
|
||||||
- update-nix-fetchgit
|
|
||||||
- vector-sized
|
|
||||||
- vulkan
|
|
||||||
- vulkan-utils
|
|
||||||
erictapen:
|
|
||||||
- hakyll
|
|
||||||
evenbrenden:
|
|
||||||
- unleash-client-haskell
|
|
||||||
- unleash-client-haskell-core
|
|
||||||
Gabriella439:
|
|
||||||
- annah
|
|
||||||
- bench
|
|
||||||
- break
|
|
||||||
- dhall-bash
|
|
||||||
- dhall-docs
|
|
||||||
- dhall-json
|
|
||||||
- dhall-lsp-server
|
|
||||||
- dhall-nix
|
|
||||||
- dhall-nixpkgs
|
|
||||||
- dhall-openapi
|
|
||||||
- dhall-text
|
|
||||||
- dhall-yaml
|
|
||||||
- dhall
|
|
||||||
- dirstream
|
|
||||||
- errors
|
|
||||||
- foldl
|
|
||||||
- index-core
|
|
||||||
- lens-tutorial
|
|
||||||
- list-transformer
|
|
||||||
- managed
|
|
||||||
- mmorph
|
|
||||||
- morte
|
|
||||||
- mvc-updates
|
|
||||||
- mvc
|
|
||||||
- nix-derivation
|
|
||||||
- nix-diff
|
|
||||||
- optional-args
|
|
||||||
- optparse-generic
|
|
||||||
- pipes-bytestring
|
|
||||||
- pipes-concurrency
|
|
||||||
- pipes-csv
|
|
||||||
- pipes-extras
|
|
||||||
- pipes-group
|
|
||||||
- pipes-http
|
|
||||||
- pipes-parse
|
|
||||||
- pipes-safe
|
|
||||||
- pipes
|
|
||||||
- server-generic
|
|
||||||
- total
|
|
||||||
- turtle
|
|
||||||
- typed-spreadsheet
|
|
||||||
gebner:
|
|
||||||
- wstunnel
|
|
||||||
gridaphobe:
|
|
||||||
- located-base
|
|
||||||
iblech:
|
|
||||||
- Agda
|
|
||||||
ivanbrennan:
|
|
||||||
- xmonad
|
|
||||||
- xmonad-contrib
|
|
||||||
jb55:
|
|
||||||
# - bson-lens
|
|
||||||
- cased
|
|
||||||
- elm-export-persistent
|
|
||||||
# - pipes-mongodb
|
|
||||||
- streaming-wai
|
|
||||||
kiwi:
|
|
||||||
- config-schema
|
|
||||||
- config-value
|
|
||||||
- glirc
|
|
||||||
- irc-core
|
|
||||||
- matterhorn
|
|
||||||
- mattermost-api
|
|
||||||
- mattermost-api-qc
|
|
||||||
- Unique
|
|
||||||
libjared:
|
|
||||||
- sensei
|
|
||||||
maralorn:
|
|
||||||
- bluefin
|
|
||||||
- cabal-fmt
|
|
||||||
- eventlog2html
|
|
||||||
- falsify
|
|
||||||
- generic-optics
|
|
||||||
- ghc-debug-brick
|
|
||||||
- ghc-debug-stub
|
|
||||||
- ghcid
|
|
||||||
- graphql-client
|
|
||||||
- haskell-language-server
|
|
||||||
- hledger
|
|
||||||
- hledger-ui
|
|
||||||
- hledger-web
|
|
||||||
- hlint
|
|
||||||
- hspec-discover
|
|
||||||
- jsaddle-warp
|
|
||||||
- matrix-client
|
|
||||||
- optics
|
|
||||||
- pandoc
|
|
||||||
- pandoc-cli
|
|
||||||
- pandoc-crossref
|
|
||||||
- postgresql-simple
|
|
||||||
- purebred-email
|
|
||||||
- reflex-dom
|
|
||||||
- replace-megaparsec
|
|
||||||
- req
|
|
||||||
- say
|
|
||||||
- shake-bench
|
|
||||||
- shh
|
|
||||||
- shh-extras
|
|
||||||
- snap
|
|
||||||
- stm-containers
|
|
||||||
- streamly
|
|
||||||
- streamly-bytestring
|
|
||||||
- string-interpolate
|
|
||||||
- taskwarrior
|
|
||||||
- tasty
|
|
||||||
- threadscope
|
|
||||||
- tz
|
|
||||||
- weeder
|
|
||||||
- witch
|
|
||||||
ncfavier:
|
|
||||||
- irc-client
|
|
||||||
- lambdabot
|
|
||||||
- shake
|
|
||||||
nomeata:
|
|
||||||
- cabal-plan-bounds
|
|
||||||
- candid
|
|
||||||
- leb128-cereal
|
|
||||||
- lhs2tex
|
|
||||||
- rec-def
|
|
||||||
- tasty-expected-failure
|
|
||||||
peti:
|
|
||||||
- cabal2spec
|
|
||||||
- funcmp
|
|
||||||
- git-annex
|
|
||||||
- hledger-interest
|
|
||||||
- hopenssl
|
|
||||||
- hsdns
|
|
||||||
- hsemail
|
|
||||||
- hsyslog
|
|
||||||
- logging-facade-syslog
|
|
||||||
- nix-paths
|
|
||||||
- structured-haskell-mode
|
|
||||||
- titlecase
|
|
||||||
- xmonad
|
|
||||||
- xmonad-contrib
|
|
||||||
poscat:
|
|
||||||
- hinit
|
|
||||||
psibi:
|
|
||||||
- path-pieces
|
|
||||||
- persistent
|
|
||||||
- persistent-sqlite
|
|
||||||
- persistent-template
|
|
||||||
- shakespeare
|
|
||||||
raehik:
|
|
||||||
- strongweak
|
|
||||||
- generic-data-functions
|
|
||||||
- binrep
|
|
||||||
- bytepatch
|
|
||||||
- heystone
|
|
||||||
- refined
|
|
||||||
- refined1
|
|
||||||
- flatparse
|
|
||||||
roberth:
|
|
||||||
- arion-compose
|
|
||||||
- cabal-pkg-config-version-hook
|
|
||||||
- hercules-ci-agent
|
|
||||||
- hercules-ci-api
|
|
||||||
- hercules-ci-api-agent
|
|
||||||
- hercules-ci-api-core
|
|
||||||
- hercules-ci-cli
|
|
||||||
- hercules-ci-cnix-expr
|
|
||||||
- hercules-ci-cnix-store
|
|
||||||
- inline-c
|
|
||||||
- inline-c-cpp
|
|
||||||
roosemberth:
|
|
||||||
- git-annex
|
|
||||||
rvl:
|
|
||||||
- taffybar
|
|
||||||
- arbtt
|
|
||||||
- lentil
|
|
||||||
sheepforce:
|
|
||||||
- mpi-hs
|
|
||||||
- mpi-hs-store
|
|
||||||
- mpi-hs-cereal
|
|
||||||
- mpi-hs-binary
|
|
||||||
- cpython
|
|
||||||
- massiv
|
|
||||||
- massiv-io
|
|
||||||
- massiv-test
|
|
||||||
shlok:
|
|
||||||
- streamly-archive
|
|
||||||
- streamly-lmdb
|
|
||||||
slotThe:
|
|
||||||
- X11
|
|
||||||
- X11-xft
|
|
||||||
- html-parse-util
|
|
||||||
- kmonad
|
|
||||||
- optparse-applicative-cmdline-util
|
|
||||||
- xmonad
|
|
||||||
- xmonad-contrib
|
|
||||||
- xmonad-extras
|
|
||||||
sorki:
|
|
||||||
- cayenne-lpp
|
|
||||||
- blockfrost-client
|
|
||||||
- data-lens-light
|
|
||||||
- data-stm32
|
|
||||||
- gcodehs
|
|
||||||
- hnix
|
|
||||||
- hnix-store-core
|
|
||||||
- hnix-store-remote
|
|
||||||
- implicit
|
|
||||||
- nix-derivation
|
|
||||||
- nix-diff
|
|
||||||
- nix-narinfo
|
|
||||||
- ttn
|
|
||||||
- ttn-client
|
|
||||||
- update-nix-fetchgit
|
|
||||||
- zre
|
|
||||||
srid:
|
|
||||||
- ema
|
|
||||||
- emanote
|
|
||||||
sternenseemann:
|
|
||||||
# also maintain upstream package
|
|
||||||
- cabal2nix
|
|
||||||
- distribution-nixpkgs
|
|
||||||
- hackage-db
|
|
||||||
- language-nix
|
|
||||||
- jailbreak-cabal
|
|
||||||
- spacecookie
|
|
||||||
- gopher-proxy
|
|
||||||
# other packages I can help out for
|
|
||||||
- cabal-install
|
|
||||||
- hledger
|
|
||||||
- pandoc
|
|
||||||
- systemd
|
|
||||||
- fast-logger
|
|
||||||
- flat
|
|
||||||
- Euterpea2
|
|
||||||
- utc
|
|
||||||
- socket
|
|
||||||
- gitit
|
|
||||||
- yarn-lock
|
|
||||||
- yarn2nix
|
|
||||||
- large-hashable
|
|
||||||
- haskell-ci
|
|
||||||
- diagrams
|
|
||||||
- rel8
|
|
||||||
- regex-rure
|
|
||||||
- jacinda
|
|
||||||
- citeproc
|
|
||||||
# owothia
|
|
||||||
- irc-client
|
|
||||||
- chatter
|
|
||||||
- envy
|
|
||||||
t4ccer:
|
|
||||||
- aeson-better-errors
|
|
||||||
- cheapskate
|
|
||||||
- containers-unicode-symbols
|
|
||||||
- numerals-base
|
|
||||||
- pattern-arrows
|
|
||||||
tbidne:
|
|
||||||
- rest-rewrite
|
|
||||||
terlar:
|
|
||||||
- nix-diff
|
|
||||||
turion:
|
|
||||||
- Agda
|
|
||||||
- cabal-gild
|
|
||||||
- dunai
|
|
||||||
- essence-of-live-coding
|
|
||||||
- essence-of-live-coding-gloss
|
|
||||||
- essence-of-live-coding-pulse
|
|
||||||
- essence-of-live-coding-quickcheck
|
|
||||||
- essence-of-live-coding-warp
|
|
||||||
- finite-typelits
|
|
||||||
- has-transformers
|
|
||||||
- monad-bayes
|
|
||||||
- monad-schedule
|
|
||||||
- pulse-simple
|
|
||||||
- rhine
|
|
||||||
- rhine-gloss
|
|
||||||
- simple-affine-space
|
|
||||||
- time-domain
|
|
||||||
thielema:
|
|
||||||
- accelerate-arithmetic
|
|
||||||
- accelerate-fftw
|
|
||||||
- accelerate-fourier
|
|
||||||
- accelerate-utility
|
|
||||||
- align-audio
|
|
||||||
- alsa-core
|
|
||||||
- alsa-pcm
|
|
||||||
- alsa-seq
|
|
||||||
- apportionment
|
|
||||||
- audacity
|
|
||||||
- battleship-combinatorics
|
|
||||||
- bibtex
|
|
||||||
- board-games
|
|
||||||
- buffer-pipe
|
|
||||||
- cabal-flatpak
|
|
||||||
- calendar-recycling
|
|
||||||
- checksum
|
|
||||||
- check-pvp
|
|
||||||
- coinor-clp
|
|
||||||
- combinatorial
|
|
||||||
- comfort-graph
|
|
||||||
- comfort-array
|
|
||||||
- comfort-array-shape
|
|
||||||
- comfort-fftw
|
|
||||||
- comfort-glpk
|
|
||||||
- concurrent-split
|
|
||||||
- cutter
|
|
||||||
- data-accessor
|
|
||||||
- data-accessor-mtl
|
|
||||||
- data-accessor-template
|
|
||||||
- data-accessor-transformers
|
|
||||||
- data-ref
|
|
||||||
- doctest-exitcode-stdio
|
|
||||||
- doctest-extract
|
|
||||||
- doctest-lib
|
|
||||||
- dsp
|
|
||||||
- enumset
|
|
||||||
- equal-files
|
|
||||||
- event-list
|
|
||||||
- explicit-exception
|
|
||||||
- fixed-length
|
|
||||||
- fftw-ffi
|
|
||||||
- gnuplot
|
|
||||||
- group-by-date
|
|
||||||
- guarded-allocation
|
|
||||||
- iff
|
|
||||||
- interpolation
|
|
||||||
- jack
|
|
||||||
- latex
|
|
||||||
- lazyio
|
|
||||||
- linear-programming
|
|
||||||
- llvm-ffi
|
|
||||||
- markov-chain
|
|
||||||
- midi
|
|
||||||
- midi-alsa
|
|
||||||
- midi-music-box
|
|
||||||
- mbox-utility
|
|
||||||
- med-module
|
|
||||||
- monoid-transformer
|
|
||||||
- non-empty
|
|
||||||
- non-negative
|
|
||||||
- numeric-prelude
|
|
||||||
- numeric-quest
|
|
||||||
- pathtype
|
|
||||||
- pooled-io
|
|
||||||
- probability
|
|
||||||
- quickcheck-transformer
|
|
||||||
- reactive-midyim
|
|
||||||
- reactive-balsa
|
|
||||||
- reactive-jack
|
|
||||||
- sample-frame
|
|
||||||
- sample-frame-np
|
|
||||||
- set-cover
|
|
||||||
- shell-utility
|
|
||||||
- sound-collage
|
|
||||||
- sox
|
|
||||||
- soxlib
|
|
||||||
- split-record
|
|
||||||
- spreadsheet
|
|
||||||
- stm-split
|
|
||||||
- storable-record
|
|
||||||
- storable-tuple
|
|
||||||
- storablevector
|
|
||||||
- synthesizer-core
|
|
||||||
- synthesizer-dimensional
|
|
||||||
- synthesizer-alsa
|
|
||||||
- synthesizer-midi
|
|
||||||
- tagchup
|
|
||||||
- tfp
|
|
||||||
- unicode
|
|
||||||
- unique-logic
|
|
||||||
- unique-logic-tf
|
|
||||||
- unsafe
|
|
||||||
- utility-ht
|
|
||||||
- wuerfelschlange
|
|
||||||
- xml-basic
|
|
||||||
- youtube
|
|
||||||
- prelude-compat
|
|
||||||
- fft
|
|
||||||
- carray
|
|
||||||
- lapack-ffi-tools
|
|
||||||
- netlib-ffi
|
|
||||||
- blas-ffi
|
|
||||||
- lapack-ffi
|
|
||||||
- netlib-carray
|
|
||||||
- blas-carray
|
|
||||||
- lapack-carray
|
|
||||||
- netlib-comfort-array
|
|
||||||
- blas-comfort-array
|
|
||||||
- lapack-comfort-array
|
|
||||||
- comfort-blas
|
|
||||||
- lapack
|
|
||||||
- lapack-hmatrix
|
|
||||||
- hmm-lapack
|
|
||||||
- magico
|
|
||||||
- resistor-cube
|
|
||||||
- linear-circuit
|
|
||||||
utdemir:
|
|
||||||
- nix-tree
|
|
||||||
zowoq:
|
|
||||||
- ShellCheck
|
|
||||||
|
|
||||||
unsupported-platforms:
|
|
||||||
Allure: [ platforms.darwin ]
|
|
||||||
bdcs-api: [ platforms.darwin ]
|
|
||||||
bindings-directfb: [ platforms.darwin ]
|
|
||||||
bindings-sane: [ platforms.darwin ]
|
|
||||||
bustle: [ platforms.darwin ] # uses glibc-specific ptsname_r
|
|
||||||
bytelog: [ platforms.darwin ] # due to posix-api
|
|
||||||
camfort: [ aarch64-linux ]
|
|
||||||
chalkboard: [ platforms.darwin ] # depends on Codec-Image-DevIL
|
|
||||||
chalkboard-viewer: [ platforms.darwin ] # depends on chalkboard
|
|
||||||
charsetdetect: [ aarch64-linux ] # not supported by vendored lib / not configured properly https://github.com/batterseapower/libcharsetdetect/issues/3
|
|
||||||
Codec-Image-DevIL: [ platforms.darwin ] # depends on mesa
|
|
||||||
coinor-clp: [ aarch64-linux ] # aarch64-linux is not supported by required system dependency clp
|
|
||||||
cut-the-crap: [ platforms.darwin ]
|
|
||||||
essence-of-live-coding-PortMidi: [ platforms.darwin ]
|
|
||||||
Euterpea: [ platforms.darwin ]
|
|
||||||
follow-file: [ platforms.darwin ]
|
|
||||||
freenect: [ platforms.darwin ]
|
|
||||||
FTGL: [ platforms.darwin ]
|
|
||||||
fuzzytime: [ platforms.darwin ] # https://github.com/kamwitsta/fuzzytime/issues/2
|
|
||||||
ghcjs-dom-hello: [ platforms.darwin ]
|
|
||||||
ghc-gc-hook: [ platforms.darwin ] # requires C11 threads which Apple doesn't support
|
|
||||||
gi-adwaita: [ platforms.darwin ]
|
|
||||||
gi-dbusmenugtk3: [ platforms.darwin ]
|
|
||||||
gi-dbusmenu: [ platforms.darwin ]
|
|
||||||
gi-ggit: [ platforms.darwin ]
|
|
||||||
gi-gtk-layer-shell: [ platforms.darwin ] # depends on gtk-layer-shell which is not supported on darwin
|
|
||||||
gi-ibus: [ platforms.darwin ]
|
|
||||||
gi-javascriptcore: [ platforms.darwin ] # webkitgtk marked broken on darwin
|
|
||||||
gi-ostree: [ platforms.darwin ]
|
|
||||||
gi-vte: [ platforms.darwin ]
|
|
||||||
gi-webkit2webextension: [ platforms.darwin ] # webkitgtk marked broken on darwin
|
|
||||||
gi-webkit2: [ platforms.darwin ] # webkitgtk marked broken on darwin
|
|
||||||
gi-wnck: [ platforms.darwin ]
|
|
||||||
gl: [ platforms.darwin ] # depends on mesa
|
|
||||||
GLHUI: [ platforms.darwin ] # depends on mesa
|
|
||||||
gnome-keyring: [ platforms.darwin ]
|
|
||||||
grid-proto: [ platforms.darwin ]
|
|
||||||
gtk-sni-tray: [ platforms.darwin ]
|
|
||||||
h-raylib: [ platforms.darwin ] # depends on mesa
|
|
||||||
haskell-snake: [ platforms.darwin ]
|
|
||||||
hcwiid: [ platforms.darwin ]
|
|
||||||
HDRUtils: [ platforms.darwin ]
|
|
||||||
hinotify-bytestring: [ platforms.darwin ]
|
|
||||||
honk: [ platforms.darwin ]
|
|
||||||
HSoM: [ platforms.darwin ]
|
|
||||||
intricacy: [ platforms.darwin ] # depends on mesa
|
|
||||||
iwlib: [ platforms.darwin ]
|
|
||||||
Jazzkell: [ platforms.darwin ] # depends on Euterpea
|
|
||||||
jsaddle-hello: [ platforms.darwin ] # depends on jsaddle-webkit2gtk
|
|
||||||
jsaddle-webkit2gtk: [ platforms.darwin ]
|
|
||||||
Kulitta: [ platforms.darwin ] # depends on Euterpea
|
|
||||||
LambdaHack: [ platforms.darwin ]
|
|
||||||
large-hashable: [ aarch64-linux ] # https://github.com/factisresearch/large-hashable/issues/17
|
|
||||||
libmodbus: [ platforms.darwin ]
|
|
||||||
libsystemd-journal: [ platforms.darwin ]
|
|
||||||
libtelnet: [ platforms.darwin ]
|
|
||||||
libvirt-hs: [ platforms.darwin ] # spidermonkey is not supported on darwin
|
|
||||||
libzfs: [ platforms.darwin ]
|
|
||||||
linearEqSolver: [ aarch64-linux ]
|
|
||||||
lio-fs: [ platforms.darwin ]
|
|
||||||
logging-facade-journald: [ platforms.darwin ]
|
|
||||||
longshot: [ aarch64-linux ]
|
|
||||||
mpi-hs: [ aarch64-linux, platforms.darwin ]
|
|
||||||
mpi-hs-binary: [ aarch64-linux, platforms.darwin ]
|
|
||||||
mpi-hs-cereal: [ aarch64-linux, platforms.darwin ]
|
|
||||||
mpi-hs-store: [ aarch64-linux, platforms.darwin ]
|
|
||||||
mplayer-spot: [ aarch64-linux, platforms.darwin ]
|
|
||||||
monomer: [ platforms.darwin ] # depends on mesa
|
|
||||||
monomer-hagrid: [ platforms.darwin ] # depends on mesa
|
|
||||||
mptcp-pm: [ platforms.darwin ]
|
|
||||||
mueval: [ aarch64-linux ] # https://hydra.nixos.org/build/257076117/nixlog/2 https://gitlab.haskell.org/ghc/ghc/-/issues/24432
|
|
||||||
nanovg: [ platforms.darwin ] # depends on mesa
|
|
||||||
netlink: [ platforms.darwin ]
|
|
||||||
notifications-tray-icon: [ platforms.darwin ] # depends on gi-dbusmenu
|
|
||||||
oculus: [ platforms.darwin ]
|
|
||||||
ostree-pin: [ platforms.darwin ] # depends on gi-ostree
|
|
||||||
pam: [ platforms.darwin ]
|
|
||||||
parport: [ platforms.darwin ]
|
|
||||||
persist-state: [ aarch64-linux, armv7l-linux ] # https://github.com/minad/persist-state/blob/6fd68c0b8b93dec78218f6d5a1f4fa06ced4e896/src/Data/PersistState.hs#L122-L128
|
|
||||||
piyo: [ platforms.darwin ]
|
|
||||||
PortMidi-simple: [ platforms.darwin ]
|
|
||||||
PortMidi: [ platforms.darwin ]
|
|
||||||
portmidi-utility: [ platforms.darwin ]
|
|
||||||
posix-api: [ platforms.darwin ]
|
|
||||||
Raincat: [ platforms.darwin ]
|
|
||||||
reactive-balsa: [ platforms.darwin ] # depends on alsa-core
|
|
||||||
reflex-dom-fragment-shader-canvas: [ platforms.darwin, aarch64-linux ]
|
|
||||||
reflex-dom: [ platforms.darwin ]
|
|
||||||
reflex-localize-dom: [ platforms.darwin, aarch64-linux ]
|
|
||||||
rsi-break: [ platforms.darwin ] # depends on monomer
|
|
||||||
rtlsdr: [ platforms.darwin ]
|
|
||||||
rubberband: [ platforms.darwin ]
|
|
||||||
SDL-mixer: [ platforms.darwin ] # depends on mesa
|
|
||||||
SDL-mpeg: [ platforms.darwin ] # depends on mesa
|
|
||||||
sdl2-mixer: [ platforms.darwin ]
|
|
||||||
sdl2-ttf: [ platforms.darwin ]
|
|
||||||
sdr: [ platforms.darwin ] # depends on rtlsdr
|
|
||||||
sensei: [ platforms.darwin ]
|
|
||||||
spade: [ platforms.darwin ] # depends on sdl2-mixer, which doesn't work on darwin
|
|
||||||
synthesizer-alsa: [ platforms.darwin ]
|
|
||||||
taffybar: [ platforms.darwin ]
|
|
||||||
twirl: [ platforms.darwin ] # depends on sdl2-mixer
|
|
||||||
emanote: [ x86_64-darwin ] # Depends on stork which is broken on macOS sdk < 10.14
|
|
||||||
termonad: [ platforms.darwin ]
|
|
||||||
tokyotyrant-haskell: [ platforms.darwin ]
|
|
||||||
Unixutils-shadow: [ platforms.darwin ]
|
|
||||||
verifiable-expressions: [ aarch64-linux ]
|
|
||||||
vrpn: [ platforms.darwin ]
|
|
||||||
vulkan: [ i686-linux, armv7l-linux, platforms.darwin ]
|
|
||||||
VulkanMemoryAllocator: [ i686-linux, armv7l-linux, platforms.darwin ]
|
|
||||||
vulkan-utils: [ platforms.darwin ]
|
|
||||||
webkit2gtk3-javascriptcore: [ platforms.darwin ]
|
|
||||||
wiringPi: [ aarch64-darwin ]
|
|
||||||
xattr: [ platforms.darwin ]
|
|
||||||
xgboost-haskell: [ aarch64-linux, armv7l-linux, platforms.darwin ]
|
|
||||||
xmobar: [ platforms.darwin ]
|
|
||||||
xmonad-extras: [ platforms.darwin ]
|
|
||||||
xmonad-volume: [ platforms.darwin ]
|
|
||||||
|
|
||||||
supported-platforms:
|
|
||||||
AWin32Console: [ platforms.windows ]
|
|
||||||
alsa-mixer: [ platforms.linux ]
|
|
||||||
alsa-pcm: [ platforms.linux ]
|
|
||||||
alsa-seq: [ platforms.linux ]
|
|
||||||
barbly: [ platforms.darwin ]
|
|
||||||
bindings-parport: [ platforms.linux ] # parport is a linux kernel component
|
|
||||||
blake3: [ platforms.x86 ] # uses x86 intrinsics
|
|
||||||
btrfs: [ platforms.linux ] # depends on linux
|
|
||||||
bytepatch: [ platforms.x86 ] # due to blake3
|
|
||||||
cpuid: [ platforms.x86 ] # needs to be i386 compatible (IA-32)
|
|
||||||
cpython: [ platforms.x86 ] # c2hs errors on glibc headers
|
|
||||||
crc32c: [ platforms.x86 ] # uses x86 intrinsics
|
|
||||||
d3d11binding: [ platforms.windows ]
|
|
||||||
DirectSound: [ platforms.windows ]
|
|
||||||
dx9base: [ platforms.windows ]
|
|
||||||
dx9d3d: [ platforms.windows ]
|
|
||||||
dx9d3dx: [ platforms.windows ]
|
|
||||||
evdev: [ platforms.linux ]
|
|
||||||
evdev-streamly: [ platforms.linux ]
|
|
||||||
geomancy: [ platforms.x86 ] # x86 intrinsics
|
|
||||||
geomancy-layout: [ platforms.x86 ] # x86 intrinsics
|
|
||||||
gi-gtkosxapplication: [ platforms.darwin ]
|
|
||||||
gtk-mac-integration: [ platforms.darwin ]
|
|
||||||
gtk3-mac-integration: [ platforms.darwin ]
|
|
||||||
halide-haskell: [ platforms.linux ]
|
|
||||||
halide-JuicyPixels: [ platforms.linux ]
|
|
||||||
hb3sum: [ platforms.x86 ] # due to blake3
|
|
||||||
hommage-ds: [ platforms.windows ]
|
|
||||||
hpapi: [ platforms.linux ] # limited by pkgs.papi
|
|
||||||
hsignal: [ platforms.x86 ] # -msse2
|
|
||||||
HFuse: [ platforms.linux ]
|
|
||||||
HQu: [ platforms.x86 ] # vendored C++ library needs i686/x86_64
|
|
||||||
hs-swisstable-hashtables-class: [ platforms.x86_64 ] # depends on swisstable, which Needs AVX2
|
|
||||||
htune: [ platforms.linux ] # depends on alsa-pcm
|
|
||||||
hw-prim-bits: [ platforms.x86 ] # x86 assembler
|
|
||||||
inline-asm: [ platforms.x86 ] # x86 assembler
|
|
||||||
keid-core: [ x86_64-linux ] # geomancy (only x86), vulkan (no i686, no darwin, …)
|
|
||||||
keid-frp-banana: [ x86_64-linux ] # geomancy (only x86), vulkan (no i686, no darwin, …)
|
|
||||||
keid-geometry: [ x86_64-linux ] # geomancy (only x86), vulkan (no i686, no darwin, …)
|
|
||||||
keid-render-basic: [ x86_64-linux ] # geomancy (only x86), vulkan (no i686, no darwin, …)
|
|
||||||
keid-resource-gltf: [ x86_64-linux ] # geomancy (only x86), vulkan (no i686, no darwin, …)
|
|
||||||
keid-sound-openal: [ x86_64-linux ] # geomancy (only x86), vulkan (no i686, no darwin, …)
|
|
||||||
keid-ui-dearimgui: [ x86_64-linux ] # geomancy (only x86), vulkan (no i686, no darwin, …)
|
|
||||||
kqueue: [ platforms.netbsd, platforms.freebsd, platforms.openbsd, platforms.darwin ]
|
|
||||||
libfuse3: [ platforms.linux ]
|
|
||||||
linux-evdev: [ platforms.linux ]
|
|
||||||
linux-file-extents: [ platforms.linux ]
|
|
||||||
linux-inotify: [ platforms.linux ]
|
|
||||||
linux-mount: [ platforms.linux ]
|
|
||||||
linux-namespaces: [ platforms.linux ]
|
|
||||||
lxc: [ platforms.linux ]
|
|
||||||
memfd: [ platforms.linux ]
|
|
||||||
midi-alsa: [ platforms.linux ] # alsa-core only supported on linux
|
|
||||||
midisurface: [ platforms.linux ] # alsa-core only supported on linux
|
|
||||||
OrderedBits: [ platforms.x86 ] # lacks implementations for non-x86: https://github.com/choener/OrderedBits/blob/401cbbe933b1635aa33e8e9b29a4a570b0a8f044/lib/Data/Bits/Ordered.hs#L316
|
|
||||||
password: [ platforms.x86 ] # uses scrypt, which requries x86
|
|
||||||
password-instances: [ platforms.x86 ] # uses scrypt, which requries x86
|
|
||||||
reactivity: [ platforms.windows ]
|
|
||||||
reflex-libtelnet: [ platforms.linux ] # pkgs.libtelnet only supports linux
|
|
||||||
scat: [ platforms.x86 ] # uses scrypt, which requries x86
|
|
||||||
scrypt: [ platforms.x86 ] # https://github.com/informatikr/scrypt/issues/8
|
|
||||||
seqalign: [ platforms.x86 ] # x86 intrinsics
|
|
||||||
streamed: [ platforms.linux] # alsa-core only supported on linux
|
|
||||||
swisstable: [ platforms.x86_64 ] # Needs AVX2
|
|
||||||
systemd-api: [ platforms.linux ]
|
|
||||||
tasty-papi: [ platforms.linux ] # limited by pkgs.papi
|
|
||||||
tcod-haskell: [ platforms.linux ] # limited by pkgs.libtcod
|
|
||||||
udev: [ platforms.linux ]
|
|
||||||
vty-windows: [ platforms.windows ] # depends on Win32
|
|
||||||
Win32-console: [ platforms.windows ]
|
|
||||||
Win32-dhcp-server: [ platforms.windows ]
|
|
||||||
Win32-errors: [ platforms.windows ]
|
|
||||||
Win32-extras: [ platforms.windows ]
|
|
||||||
Win32-junction-point: [ platforms.windows ]
|
|
||||||
Win32-notify: [ platforms.windows ]
|
|
||||||
Win32: [ platforms.windows ]
|
|
||||||
Win32-security: [ platforms.windows ]
|
|
||||||
Win32-services: [ platforms.windows ]
|
|
||||||
Win32-services-wrapper: [ platforms.windows ]
|
|
||||||
XInput: [ platforms.windows ]
|
|
||||||
yesod-auth-simple: [ platforms.x86 ] # requires scrypt which only supports x86
|
|
||||||
|
|
||||||
dont-distribute-packages:
|
|
||||||
# Depends on shine, which is a ghcjs project.
|
|
||||||
- shine-varying
|
|
||||||
|
|
||||||
# these packages depend on software with an unfree license
|
|
||||||
- accelerate-bignum
|
|
||||||
- accelerate-blas
|
|
||||||
- accelerate-cublas
|
|
||||||
- accelerate-cuda
|
|
||||||
- accelerate-cufft
|
|
||||||
- accelerate-examples
|
|
||||||
- accelerate-fft
|
|
||||||
- accelerate-fourier-benchmark
|
|
||||||
- accelerate-io-array
|
|
||||||
- accelerate-io-bmp
|
|
||||||
- accelerate-io-bytestring
|
|
||||||
- accelerate-io-cereal
|
|
||||||
- accelerate-io-JuicyPixels
|
|
||||||
- accelerate-io-repa
|
|
||||||
- accelerate-io-vector
|
|
||||||
- accelerate-kullback-liebler
|
|
||||||
- accelerate-llvm-ptx
|
|
||||||
- bindings-yices
|
|
||||||
- boolector
|
|
||||||
- ccelerate-cuda
|
|
||||||
- containers-accelerate
|
|
||||||
- cplex-hs
|
|
||||||
- cublas
|
|
||||||
- cuda # 2020-08-18 because of dependency nvidia-x11
|
|
||||||
- cufft
|
|
||||||
- cusolver
|
|
||||||
- cusparse
|
|
||||||
- gloss-raster-accelerate
|
|
||||||
- hashable-accelerate
|
|
||||||
- libnvvm
|
|
||||||
- matlab
|
|
||||||
- nvvm
|
|
||||||
- Obsidian
|
|
||||||
- odpic-raw
|
|
||||||
- patch-image
|
|
||||||
# license for input data unclear, dependency not on Hackage
|
|
||||||
# see https://github.com/NixOS/nixpkgs/pull/88604
|
|
||||||
- tensorflow-mnist
|
|
||||||
- yices-easy
|
|
||||||
- yices-painless
|
|
||||||
|
|
||||||
# These packages don’t build because they use deprecated webkit versions.
|
|
||||||
- diagrams-hsqml
|
|
||||||
- dialog
|
|
||||||
- ghcjs-dom-webkit
|
|
||||||
- gi-webkit
|
|
||||||
- hsqml
|
|
||||||
- hsqml-datamodel
|
|
||||||
- hsqml-datamodel-vinyl
|
|
||||||
- hsqml-demo-manic
|
|
||||||
- hsqml-demo-morris
|
|
||||||
- hsqml-demo-notes
|
|
||||||
- hsqml-demo-samples
|
|
||||||
- hsqml-morris
|
|
||||||
- hstorchat
|
|
||||||
- jsaddle-webkitgtk
|
|
||||||
- jsc
|
|
||||||
- lambdacat
|
|
||||||
- manatee-all
|
|
||||||
- manatee-browser
|
|
||||||
- manatee-reader
|
|
||||||
- markup-preview
|
|
||||||
- spike
|
|
||||||
- web-browser-in-haskell
|
|
||||||
- webkit
|
|
||||||
- webkitgtk3-javascriptcore
|
|
||||||
- websnap
|
|
||||||
|
|
||||||
# mesos was removed from nixpkgs
|
|
||||||
- hs-mesos
|
|
||||||
|
|
||||||
# Output exceeds Hydra's maximum allowable size
|
|
||||||
- stripeapi
|
|
||||||
|
|
||||||
# Packages that (transitively) depend on insecure packages
|
|
||||||
- distributed-process-zookeeper # depends on hzk
|
|
||||||
- HDRUtils # depends on pfstools, which depends on imagemagick
|
|
||||||
- hzk # depends on zookeeper_mt, which depends on openssl-1.1
|
|
||||||
- jobqueue # depends on hzk
|
|
||||||
- persistent-zookeeper # depends on hzk
|
|
||||||
- pocket-dns # depends on persistent-zookeeper
|
|
||||||
- zoovisitor # depends on zookeeper_mt, which depends on openssl-1.1
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,37 +0,0 @@
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
with haskellLib;
|
|
||||||
|
|
||||||
self: super:
|
|
||||||
let
|
|
||||||
# This contains updates to the dependencies, without which it would
|
|
||||||
# be even more work to get it to build.
|
|
||||||
# As of 2020-04, there's no new release in sight, which is why we're
|
|
||||||
# pulling from Github.
|
|
||||||
tensorflow-haskell = pkgs.fetchFromGitHub {
|
|
||||||
owner = "tensorflow";
|
|
||||||
repo = "haskell";
|
|
||||||
rev = "555d90c43202d5a3021893013bfc8e2ffff58c97";
|
|
||||||
sha256 = "uOuIeD4o+pcjvluTqyVU3GJUQ4e1+p3FhINJ9b6oK+k=";
|
|
||||||
fetchSubmodules = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
setTensorflowSourceRoot = dir: drv:
|
|
||||||
(overrideCabal (drv: { src = tensorflow-haskell; }) drv)
|
|
||||||
.overrideAttrs (_oldAttrs: { sourceRoot = "${tensorflow-haskell.name}/${dir}"; });
|
|
||||||
in
|
|
||||||
{
|
|
||||||
tensorflow-proto = doJailbreak (setTensorflowSourceRoot "tensorflow-proto" super.tensorflow-proto);
|
|
||||||
|
|
||||||
tensorflow = overrideCabal
|
|
||||||
(drv: { libraryHaskellDepends = drv.libraryHaskellDepends ++ [self.vector-split]; })
|
|
||||||
(setTensorflowSourceRoot "tensorflow" super.tensorflow);
|
|
||||||
|
|
||||||
tensorflow-core-ops = setTensorflowSourceRoot "tensorflow-core-ops" super.tensorflow-core-ops;
|
|
||||||
|
|
||||||
tensorflow-logging = setTensorflowSourceRoot "tensorflow-logging" super.tensorflow-logging;
|
|
||||||
|
|
||||||
tensorflow-opgen = setTensorflowSourceRoot "tensorflow-opgen" super.tensorflow-opgen;
|
|
||||||
|
|
||||||
tensorflow-ops = setTensorflowSourceRoot "tensorflow-ops" super.tensorflow-ops;
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
{ pkgs, stdenv, lib, haskellLib, ghc, all-cabal-hashes
|
|
||||||
, buildHaskellPackages
|
|
||||||
, compilerConfig ? (self: super: {})
|
|
||||||
, packageSetConfig ? (self: super: {})
|
|
||||||
, overrides ? (self: super: {})
|
|
||||||
, initialPackages ? import ./initial-packages.nix
|
|
||||||
, nonHackagePackages ? import ./non-hackage-packages.nix
|
|
||||||
, configurationCommon ? import ./configuration-common.nix
|
|
||||||
, configurationNix ? import ./configuration-nix.nix
|
|
||||||
, configurationArm ? import ./configuration-arm.nix
|
|
||||||
, configurationDarwin ? import ./configuration-darwin.nix
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
|
|
||||||
inherit (lib) extends makeExtensible;
|
|
||||||
inherit (haskellLib) makePackageSet;
|
|
||||||
|
|
||||||
haskellPackages = pkgs.callPackage makePackageSet {
|
|
||||||
package-set = initialPackages;
|
|
||||||
inherit stdenv haskellLib ghc extensible-self all-cabal-hashes;
|
|
||||||
buildHaskellPackages = buildHaskellPackages // { __attrsFailEvaluation = true; };
|
|
||||||
};
|
|
||||||
|
|
||||||
platformConfigurations = lib.optionals stdenv.hostPlatform.isAarch [
|
|
||||||
(configurationArm { inherit pkgs haskellLib; })
|
|
||||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
|
||||||
(configurationDarwin { inherit pkgs haskellLib; })
|
|
||||||
];
|
|
||||||
|
|
||||||
extensions = lib.composeManyExtensions ([
|
|
||||||
(nonHackagePackages { inherit pkgs haskellLib; })
|
|
||||||
(configurationNix { inherit pkgs haskellLib; })
|
|
||||||
(configurationCommon { inherit pkgs haskellLib; })
|
|
||||||
] ++ platformConfigurations ++ [
|
|
||||||
compilerConfig
|
|
||||||
packageSetConfig
|
|
||||||
overrides
|
|
||||||
]);
|
|
||||||
|
|
||||||
extensible-self = makeExtensible (extends extensions haskellPackages);
|
|
||||||
|
|
||||||
in
|
|
||||||
|
|
||||||
extensible-self
|
|
|
@ -1,818 +0,0 @@
|
||||||
{ lib, stdenv, buildPackages, buildHaskellPackages, ghc
|
|
||||||
, jailbreak-cabal, hscolour, cpphs
|
|
||||||
, ghcWithHoogle, ghcWithPackages
|
|
||||||
, nodejs
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
isCross = stdenv.buildPlatform != stdenv.hostPlatform;
|
|
||||||
|
|
||||||
# Pass the "wrong" C compiler rather than none at all so packages that just
|
|
||||||
# use the C preproccessor still work, see
|
|
||||||
# https://github.com/haskell/cabal/issues/6466 for details.
|
|
||||||
cc =
|
|
||||||
if stdenv.hasCC then "$CC"
|
|
||||||
else if stdenv.hostPlatform.isGhcjs then "${emscripten}/bin/emcc"
|
|
||||||
else "$CC_FOR_BUILD";
|
|
||||||
|
|
||||||
inherit (buildPackages)
|
|
||||||
fetchurl removeReferencesTo
|
|
||||||
pkg-config coreutils gnugrep glibcLocales
|
|
||||||
emscripten;
|
|
||||||
in
|
|
||||||
|
|
||||||
{ pname
|
|
||||||
# Note that ghc.isGhcjs != stdenv.hostPlatform.isGhcjs.
|
|
||||||
# ghc.isGhcjs implies that we are using ghcjs, a project separate from GHC.
|
|
||||||
# (mere) stdenv.hostPlatform.isGhcjs means that we are using GHC's JavaScript
|
|
||||||
# backend. The latter is a normal cross compilation backend and needs little
|
|
||||||
# special accommodation.
|
|
||||||
, dontStrip ? (ghc.isGhcjs or false || stdenv.hostPlatform.isGhcjs)
|
|
||||||
, version, revision ? null
|
|
||||||
, sha256 ? null
|
|
||||||
, src ? fetchurl { url = "mirror://hackage/${pname}-${version}.tar.gz"; inherit sha256; }
|
|
||||||
, buildDepends ? [], setupHaskellDepends ? [], libraryHaskellDepends ? [], executableHaskellDepends ? []
|
|
||||||
, buildTarget ? ""
|
|
||||||
, buildTools ? [], libraryToolDepends ? [], executableToolDepends ? [], testToolDepends ? [], benchmarkToolDepends ? []
|
|
||||||
, configureFlags ? []
|
|
||||||
, buildFlags ? []
|
|
||||||
, haddockFlags ? []
|
|
||||||
, description ? null
|
|
||||||
, doCheck ? !isCross
|
|
||||||
, doBenchmark ? false
|
|
||||||
, doHoogle ? true
|
|
||||||
, doHaddockQuickjump ? doHoogle
|
|
||||||
, doInstallIntermediates ? false
|
|
||||||
, editedCabalFile ? null
|
|
||||||
, enableLibraryProfiling ? !(ghc.isGhcjs or false)
|
|
||||||
, enableExecutableProfiling ? false
|
|
||||||
, profilingDetail ? "exported-functions"
|
|
||||||
# TODO enable shared libs for cross-compiling
|
|
||||||
, enableSharedExecutables ? false
|
|
||||||
, enableSharedLibraries ? !stdenv.hostPlatform.isStatic && (ghc.enableShared or false)
|
|
||||||
, enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin
|
|
||||||
# Disabling this for ghcjs prevents this crash: https://gitlab.haskell.org/ghc/ghc/-/issues/23235
|
|
||||||
, enableStaticLibraries ? !(stdenv.hostPlatform.isWindows || stdenv.hostPlatform.isWasm || stdenv.hostPlatform.isGhcjs)
|
|
||||||
, enableHsc2hsViaAsm ? stdenv.hostPlatform.isWindows
|
|
||||||
, extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? []
|
|
||||||
# On macOS, statically linking against system frameworks is not supported;
|
|
||||||
# see https://developer.apple.com/library/content/qa/qa1118/_index.html
|
|
||||||
# They must be propagated to the environment of any executable linking with the library
|
|
||||||
, libraryFrameworkDepends ? [], executableFrameworkDepends ? []
|
|
||||||
, homepage ? "https://hackage.haskell.org/package/${pname}"
|
|
||||||
, platforms ? with lib.platforms; all # GHC can cross-compile
|
|
||||||
, badPlatforms ? lib.platforms.none
|
|
||||||
, hydraPlatforms ? null
|
|
||||||
, hyperlinkSource ? true
|
|
||||||
, isExecutable ? false, isLibrary ? !isExecutable
|
|
||||||
, jailbreak ? false
|
|
||||||
, license
|
|
||||||
, enableParallelBuilding ? true
|
|
||||||
, maintainers ? null
|
|
||||||
, changelog ? null
|
|
||||||
, mainProgram ? null
|
|
||||||
, doCoverage ? false
|
|
||||||
, doHaddock ? !(ghc.isHaLVM or false) && (ghc.hasHaddock or true)
|
|
||||||
, doHaddockInterfaces ? doHaddock && lib.versionAtLeast ghc.version "9.0.1"
|
|
||||||
, passthru ? {}
|
|
||||||
, pkg-configDepends ? [], libraryPkgconfigDepends ? [], executablePkgconfigDepends ? [], testPkgconfigDepends ? [], benchmarkPkgconfigDepends ? []
|
|
||||||
, testDepends ? [], testHaskellDepends ? [], testSystemDepends ? [], testFrameworkDepends ? []
|
|
||||||
, benchmarkDepends ? [], benchmarkHaskellDepends ? [], benchmarkSystemDepends ? [], benchmarkFrameworkDepends ? []
|
|
||||||
, testTarget ? "", testFlags ? []
|
|
||||||
, broken ? false
|
|
||||||
, preCompileBuildDriver ? null, postCompileBuildDriver ? null
|
|
||||||
, preUnpack ? null, postUnpack ? null
|
|
||||||
, patches ? null, patchPhase ? null, prePatch ? "", postPatch ? ""
|
|
||||||
, preConfigure ? null, postConfigure ? null
|
|
||||||
, preBuild ? null, postBuild ? null
|
|
||||||
, preHaddock ? null, postHaddock ? null
|
|
||||||
, installPhase ? null, preInstall ? null, postInstall ? null
|
|
||||||
, checkPhase ? null, preCheck ? null, postCheck ? null
|
|
||||||
, preFixup ? null, postFixup ? null
|
|
||||||
, shellHook ? ""
|
|
||||||
, coreSetup ? false # Use only core packages to build Setup.hs.
|
|
||||||
, useCpphs ? false
|
|
||||||
, hardeningDisable ? null
|
|
||||||
, enableSeparateBinOutput ? false
|
|
||||||
, enableSeparateDataOutput ? false
|
|
||||||
, enableSeparateDocOutput ? doHaddock
|
|
||||||
, enableSeparateIntermediatesOutput ? false
|
|
||||||
, # Don't fail at configure time if there are multiple versions of the
|
|
||||||
# same package in the (recursive) dependencies of the package being
|
|
||||||
# built. Will delay failures, if any, to compile time.
|
|
||||||
allowInconsistentDependencies ? false
|
|
||||||
, maxBuildCores ? 16 # more cores usually don't improve performance: https://ghc.haskell.org/trac/ghc/ticket/9221
|
|
||||||
, # If set to true, this builds a pre-linked .o file for this Haskell library.
|
|
||||||
# This can make it slightly faster to load this library into GHCi, but takes
|
|
||||||
# extra disk space and compile time.
|
|
||||||
enableLibraryForGhci ? false
|
|
||||||
# Set this to a previous build of this same package to reuse the intermediate
|
|
||||||
# build products from that prior build as a starting point for accelerating
|
|
||||||
# this build
|
|
||||||
, previousIntermediates ? null
|
|
||||||
, # Cabal 3.8 which is shipped by default for GHC >= 9.3 always calls
|
|
||||||
# `pkg-config --libs --static` as part of the configure step. This requires
|
|
||||||
# Requires.private dependencies of pkg-config dependencies to be present in
|
|
||||||
# PKG_CONFIG_PATH which is normally not the case in nixpkgs (except in pkgsStatic).
|
|
||||||
# Since there is no patch or upstream patch yet, we replicate the automatic
|
|
||||||
# propagation of dependencies in pkgsStatic for allPkgConfigDepends for
|
|
||||||
# GHC >= 9.3 by default. This option allows overriding this behavior manually
|
|
||||||
# if mismatching Cabal and GHC versions are used.
|
|
||||||
# See also <https://github.com/haskell/cabal/issues/8455>.
|
|
||||||
__propagatePkgConfigDepends ? lib.versionAtLeast ghc.version "9.3"
|
|
||||||
, # Propagation can easily lead to the argv limit being exceeded in linker or C
|
|
||||||
# compiler invocations. To work around this we can only propagate derivations
|
|
||||||
# that are known to provide pkg-config modules, as indicated by the presence
|
|
||||||
# of `meta.pkgConfigModules`. This option defaults to false for now, since
|
|
||||||
# this metadata is far from complete in nixpkgs.
|
|
||||||
__onlyPropagateKnownPkgConfigModules ? false
|
|
||||||
} @ args:
|
|
||||||
|
|
||||||
assert editedCabalFile != null -> revision != null;
|
|
||||||
|
|
||||||
# --enable-static does not work on windows. This is a bug in GHC.
|
|
||||||
# --enable-static will pass -staticlib to ghc, which only works for mach-o and elf.
|
|
||||||
assert stdenv.hostPlatform.isWindows -> enableStaticLibraries == false;
|
|
||||||
assert stdenv.hostPlatform.isWasm -> enableStaticLibraries == false;
|
|
||||||
|
|
||||||
let
|
|
||||||
|
|
||||||
inherit (lib) optional optionals optionalString versionAtLeast
|
|
||||||
concatStringsSep enableFeature optionalAttrs;
|
|
||||||
|
|
||||||
isGhcjs = ghc.isGhcjs or false;
|
|
||||||
isHaLVM = ghc.isHaLVM or false;
|
|
||||||
|
|
||||||
# GHC used for building Setup.hs
|
|
||||||
#
|
|
||||||
# Same as our GHC, unless we're cross, in which case it is native GHC with the
|
|
||||||
# same version, or ghcjs, in which case its the ghc used to build ghcjs.
|
|
||||||
nativeGhc = buildHaskellPackages.ghc;
|
|
||||||
|
|
||||||
# the target dir for haddock documentation
|
|
||||||
docdir = docoutput: docoutput + "/share/doc/" + pname + "-" + version;
|
|
||||||
|
|
||||||
binDir = if enableSeparateBinOutput then "$bin/bin" else "$out/bin";
|
|
||||||
|
|
||||||
newCabalFileUrl = "mirror://hackage/${pname}-${version}/revision/${revision}.cabal";
|
|
||||||
newCabalFile = fetchurl {
|
|
||||||
url = newCabalFileUrl;
|
|
||||||
sha256 = editedCabalFile;
|
|
||||||
name = "${pname}-${version}-r${revision}.cabal";
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultSetupHs = builtins.toFile "Setup.hs" ''
|
|
||||||
import Distribution.Simple
|
|
||||||
main = defaultMain
|
|
||||||
'';
|
|
||||||
|
|
||||||
# This awk expression transforms a package conf file like
|
|
||||||
#
|
|
||||||
# author: John Doe <john-doe@example.com>
|
|
||||||
# description:
|
|
||||||
# The purpose of this library is to do
|
|
||||||
# foo and bar among other things
|
|
||||||
#
|
|
||||||
# into a more easily processeable form:
|
|
||||||
#
|
|
||||||
# author: John Doe <john-doe@example.com>
|
|
||||||
# description: The purpose of this library is to do foo and bar among other things
|
|
||||||
unprettyConf = builtins.toFile "unpretty-cabal-conf.awk" ''
|
|
||||||
/^[^ ]+:/ {
|
|
||||||
# When the line starts with a new field, terminate the previous one with a newline
|
|
||||||
if (started == 1) print ""
|
|
||||||
# to strip leading spaces
|
|
||||||
$1=$1
|
|
||||||
printf "%s", $0
|
|
||||||
started=1
|
|
||||||
}
|
|
||||||
|
|
||||||
/^ +/ {
|
|
||||||
# to strip leading spaces
|
|
||||||
$1=$1
|
|
||||||
printf " %s", $0
|
|
||||||
}
|
|
||||||
|
|
||||||
# Terminate the final field with a newline
|
|
||||||
END { print "" }
|
|
||||||
'';
|
|
||||||
|
|
||||||
crossCabalFlags = [
|
|
||||||
"--with-ghc=${ghcCommand}"
|
|
||||||
"--with-ghc-pkg=${ghc.targetPrefix}ghc-pkg"
|
|
||||||
"--with-gcc=${cc}"
|
|
||||||
] ++ optionals stdenv.hasCC [
|
|
||||||
"--with-ld=${stdenv.cc.bintools.targetPrefix}ld"
|
|
||||||
"--with-ar=${stdenv.cc.bintools.targetPrefix}ar"
|
|
||||||
# use the one that comes with the cross compiler.
|
|
||||||
"--with-hsc2hs=${ghc.targetPrefix}hsc2hs"
|
|
||||||
"--with-strip=${stdenv.cc.bintools.targetPrefix}strip"
|
|
||||||
] ++ optionals (!isHaLVM) [
|
|
||||||
"--hsc2hs-option=--cross-compile"
|
|
||||||
(optionalString enableHsc2hsViaAsm "--hsc2hs-option=--via-asm")
|
|
||||||
] ++ optional (allPkgconfigDepends != [])
|
|
||||||
"--with-pkg-config=${pkg-config.targetPrefix}pkg-config";
|
|
||||||
|
|
||||||
parallelBuildingFlags = "-j$NIX_BUILD_CORES" + optionalString stdenv.isLinux " +RTS -A64M -RTS";
|
|
||||||
|
|
||||||
crossCabalFlagsString =
|
|
||||||
lib.optionalString isCross (" " + lib.concatStringsSep " " crossCabalFlags);
|
|
||||||
|
|
||||||
buildFlagsString = optionalString (buildFlags != []) (" " + concatStringsSep " " buildFlags);
|
|
||||||
|
|
||||||
defaultConfigureFlags = [
|
|
||||||
"--verbose"
|
|
||||||
"--prefix=$out"
|
|
||||||
# Note: This must be kept in sync manually with mkGhcLibdir
|
|
||||||
("--libdir=\\$prefix/lib/\\$compiler" + lib.optionalString (ghc ? hadrian) "/lib")
|
|
||||||
"--libsubdir=\\$abi/\\$libname"
|
|
||||||
(optionalString enableSeparateDataOutput "--datadir=$data/share/${ghcNameWithPrefix}")
|
|
||||||
(optionalString enableSeparateDocOutput "--docdir=${docdir "$doc"}")
|
|
||||||
] ++ optionals stdenv.hasCC [
|
|
||||||
"--with-gcc=$CC" # Clang won't work without that extra information.
|
|
||||||
] ++ [
|
|
||||||
"--package-db=$packageConfDir"
|
|
||||||
(optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/${ghcLibdir}/${pname}-${version}")
|
|
||||||
(optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names")
|
|
||||||
(optionalString enableParallelBuilding "--ghc-options=${parallelBuildingFlags}")
|
|
||||||
(optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp")
|
|
||||||
(enableFeature enableLibraryProfiling "library-profiling")
|
|
||||||
(optionalString (enableExecutableProfiling || enableLibraryProfiling) "--profiling-detail=${profilingDetail}")
|
|
||||||
(enableFeature enableExecutableProfiling "profiling")
|
|
||||||
(enableFeature enableSharedLibraries "shared")
|
|
||||||
(enableFeature doCoverage "coverage")
|
|
||||||
(enableFeature enableStaticLibraries "static")
|
|
||||||
(enableFeature enableSharedExecutables "executable-dynamic")
|
|
||||||
(enableFeature doCheck "tests")
|
|
||||||
(enableFeature doBenchmark "benchmarks")
|
|
||||||
"--enable-library-vanilla" # TODO: Should this be configurable?
|
|
||||||
(enableFeature enableLibraryForGhci "library-for-ghci")
|
|
||||||
(enableFeature enableDeadCodeElimination "split-sections")
|
|
||||||
(enableFeature (!dontStrip) "library-stripping")
|
|
||||||
(enableFeature (!dontStrip) "executable-stripping")
|
|
||||||
] ++ optionals isGhcjs [
|
|
||||||
"--ghcjs"
|
|
||||||
] ++ optionals isCross ([
|
|
||||||
"--configure-option=--host=${stdenv.hostPlatform.config}"
|
|
||||||
] ++ crossCabalFlags
|
|
||||||
) ++ optionals enableSeparateBinOutput [
|
|
||||||
"--bindir=${binDir}"
|
|
||||||
] ++ optionals (doHaddockInterfaces && isLibrary) [
|
|
||||||
"--ghc-options=-haddock"
|
|
||||||
];
|
|
||||||
|
|
||||||
postPhases = optional doInstallIntermediates "installIntermediatesPhase";
|
|
||||||
|
|
||||||
setupCompileFlags = [
|
|
||||||
(optionalString (!coreSetup) "-package-db=$setupPackageConfDir")
|
|
||||||
(optionalString enableParallelBuilding parallelBuildingFlags)
|
|
||||||
"-threaded" # https://github.com/haskell/cabal/issues/2398
|
|
||||||
"-rtsopts" # allow us to pass RTS flags to the generated Setup executable
|
|
||||||
];
|
|
||||||
|
|
||||||
isHaskellPkg = x: x ? isHaskellLibrary;
|
|
||||||
|
|
||||||
# Work around a Cabal bug requiring pkg-config --static --libs to work even
|
|
||||||
# when linking dynamically, affecting Cabal 3.8 and 3.9.
|
|
||||||
# https://github.com/haskell/cabal/issues/8455
|
|
||||||
#
|
|
||||||
# For this, we treat the runtime system/pkg-config dependencies of a Haskell
|
|
||||||
# derivation as if they were propagated from their dependencies which allows
|
|
||||||
# pkg-config --static to work in most cases.
|
|
||||||
allPkgconfigDepends =
|
|
||||||
let
|
|
||||||
# If __onlyPropagateKnownPkgConfigModules is set, packages without
|
|
||||||
# meta.pkgConfigModules will be filtered out, otherwise all packages in
|
|
||||||
# buildInputs and propagatePlainBuildInputs are propagated.
|
|
||||||
propagateValue = drv:
|
|
||||||
lib.isDerivation drv
|
|
||||||
&& (__onlyPropagateKnownPkgConfigModules -> drv ? meta.pkgConfigModules);
|
|
||||||
|
|
||||||
# Take list of derivations and return list of the transitive dependency
|
|
||||||
# closure, only taking into account buildInputs. Loosely based on
|
|
||||||
# closePropagationFast.
|
|
||||||
propagatePlainBuildInputs = drvs:
|
|
||||||
builtins.map (i: i.val) (
|
|
||||||
builtins.genericClosure {
|
|
||||||
startSet = builtins.map (drv:
|
|
||||||
{ key = drv.outPath; val = drv; }
|
|
||||||
) (builtins.filter propagateValue drvs);
|
|
||||||
operator = { val, ... }:
|
|
||||||
builtins.concatMap (drv:
|
|
||||||
if propagateValue drv
|
|
||||||
then [ { key = drv.outPath; val = drv; } ]
|
|
||||||
else [ ]
|
|
||||||
) (val.buildInputs or [ ] ++ val.propagatedBuildInputs or [ ]);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
in
|
|
||||||
|
|
||||||
if __propagatePkgConfigDepends
|
|
||||||
then propagatePlainBuildInputs allPkgconfigDepends'
|
|
||||||
else allPkgconfigDepends';
|
|
||||||
allPkgconfigDepends' =
|
|
||||||
pkg-configDepends ++ libraryPkgconfigDepends ++ executablePkgconfigDepends ++
|
|
||||||
optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends;
|
|
||||||
|
|
||||||
depsBuildBuild = [ nativeGhc ]
|
|
||||||
# CC_FOR_BUILD may be necessary if we have no C preprocessor for the host
|
|
||||||
# platform. See crossCabalFlags above for more details.
|
|
||||||
++ lib.optionals (!stdenv.hasCC) [ buildPackages.stdenv.cc ];
|
|
||||||
collectedToolDepends =
|
|
||||||
buildTools ++ libraryToolDepends ++ executableToolDepends ++
|
|
||||||
optionals doCheck testToolDepends ++
|
|
||||||
optionals doBenchmark benchmarkToolDepends;
|
|
||||||
nativeBuildInputs =
|
|
||||||
[ ghc removeReferencesTo ] ++ optional (allPkgconfigDepends != []) (assert pkg-config != null; pkg-config) ++
|
|
||||||
setupHaskellDepends ++ collectedToolDepends ++ optional stdenv.hostPlatform.isGhcjs nodejs;
|
|
||||||
propagatedBuildInputs = buildDepends ++ libraryHaskellDepends ++ executableHaskellDepends ++ libraryFrameworkDepends;
|
|
||||||
otherBuildInputsHaskell =
|
|
||||||
optionals doCheck (testDepends ++ testHaskellDepends) ++
|
|
||||||
optionals doBenchmark (benchmarkDepends ++ benchmarkHaskellDepends);
|
|
||||||
otherBuildInputsSystem =
|
|
||||||
extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++ executableFrameworkDepends ++
|
|
||||||
allPkgconfigDepends ++
|
|
||||||
optionals doCheck (testSystemDepends ++ testFrameworkDepends) ++
|
|
||||||
optionals doBenchmark (benchmarkSystemDepends ++ benchmarkFrameworkDepends);
|
|
||||||
# TODO next rebuild just define as `otherBuildInputsHaskell ++ otherBuildInputsSystem`
|
|
||||||
otherBuildInputs =
|
|
||||||
extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++ executableFrameworkDepends ++
|
|
||||||
allPkgconfigDepends ++
|
|
||||||
optionals doCheck (testDepends ++ testHaskellDepends ++ testSystemDepends ++ testFrameworkDepends) ++
|
|
||||||
optionals doBenchmark (benchmarkDepends ++ benchmarkHaskellDepends ++ benchmarkSystemDepends ++ benchmarkFrameworkDepends);
|
|
||||||
|
|
||||||
setupCommand = "./Setup";
|
|
||||||
|
|
||||||
ghcCommand' = if isGhcjs then "ghcjs" else "ghc";
|
|
||||||
ghcCommand = "${ghc.targetPrefix}${ghcCommand'}";
|
|
||||||
|
|
||||||
ghcNameWithPrefix = "${ghc.targetPrefix}${ghc.haskellCompilerName}";
|
|
||||||
mkGhcLibdir = ghc: "lib/${ghc.targetPrefix}${ghc.haskellCompilerName}"
|
|
||||||
+ lib.optionalString (ghc ? hadrian) "/lib";
|
|
||||||
ghcLibdir = mkGhcLibdir ghc;
|
|
||||||
|
|
||||||
nativeGhcCommand = "${nativeGhc.targetPrefix}ghc";
|
|
||||||
|
|
||||||
buildPkgDb = thisGhc: packageConfDir: ''
|
|
||||||
# If this dependency has a package database, then copy the contents of it,
|
|
||||||
# unless it is one of our GHCs. These can appear in our dependencies when
|
|
||||||
# we are doing native builds, and they have package databases in them, but
|
|
||||||
# we do not want to copy them over.
|
|
||||||
#
|
|
||||||
# We don't need to, since those packages will be provided by the GHC when
|
|
||||||
# we compile with it, and doing so can result in having multiple copies of
|
|
||||||
# e.g. Cabal in the database with the same name and version, which is
|
|
||||||
# ambiguous.
|
|
||||||
if [ -d "$p/${mkGhcLibdir thisGhc}/package.conf.d" ] && [ "$p" != "${ghc}" ] && [ "$p" != "${nativeGhc}" ]; then
|
|
||||||
cp -f "$p/${mkGhcLibdir thisGhc}/package.conf.d/"*.conf ${packageConfDir}/
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
intermediatesDir = "share/haskell/${ghc.version}/${pname}-${version}/dist";
|
|
||||||
in lib.fix (drv:
|
|
||||||
|
|
||||||
stdenv.mkDerivation ({
|
|
||||||
inherit pname version;
|
|
||||||
|
|
||||||
outputs = [ "out" ]
|
|
||||||
++ (optional enableSeparateDataOutput "data")
|
|
||||||
++ (optional enableSeparateDocOutput "doc")
|
|
||||||
++ (optional enableSeparateBinOutput "bin")
|
|
||||||
++ (optional enableSeparateIntermediatesOutput "intermediates");
|
|
||||||
|
|
||||||
setOutputFlags = false;
|
|
||||||
|
|
||||||
pos = builtins.unsafeGetAttrPos "pname" args;
|
|
||||||
|
|
||||||
prePhases = ["setupCompilerEnvironmentPhase"];
|
|
||||||
preConfigurePhases = ["compileBuildDriverPhase"];
|
|
||||||
preInstallPhases = ["haddockPhase"];
|
|
||||||
|
|
||||||
inherit src;
|
|
||||||
|
|
||||||
inherit depsBuildBuild nativeBuildInputs;
|
|
||||||
buildInputs = otherBuildInputs ++ optionals (!isLibrary) propagatedBuildInputs
|
|
||||||
# For patchShebangsAuto in fixupPhase
|
|
||||||
++ optionals stdenv.hostPlatform.isGhcjs [ nodejs ];
|
|
||||||
propagatedBuildInputs = optionals isLibrary propagatedBuildInputs;
|
|
||||||
|
|
||||||
LANG = "en_US.UTF-8"; # GHC needs the locale configured during the Haddock phase.
|
|
||||||
|
|
||||||
prePatch = optionalString (editedCabalFile != null) ''
|
|
||||||
echo "Replace Cabal file with edited version from ${newCabalFileUrl}."
|
|
||||||
cp ${newCabalFile} ${pname}.cabal
|
|
||||||
'' + prePatch;
|
|
||||||
|
|
||||||
postPatch = optionalString jailbreak ''
|
|
||||||
echo "Run jailbreak-cabal to lift version restrictions on build inputs."
|
|
||||||
${jailbreak-cabal}/bin/jailbreak-cabal ${pname}.cabal
|
|
||||||
'' + postPatch;
|
|
||||||
|
|
||||||
setupCompilerEnvironmentPhase = ''
|
|
||||||
NIX_BUILD_CORES=$(( NIX_BUILD_CORES < ${toString maxBuildCores} ? NIX_BUILD_CORES : ${toString maxBuildCores} ))
|
|
||||||
runHook preSetupCompilerEnvironment
|
|
||||||
|
|
||||||
echo "Build with ${ghc}."
|
|
||||||
${optionalString (isLibrary && hyperlinkSource) "export PATH=${hscolour}/bin:$PATH"}
|
|
||||||
|
|
||||||
builddir="$(mktemp -d)"
|
|
||||||
setupPackageConfDir="$builddir/setup-package.conf.d"
|
|
||||||
mkdir -p $setupPackageConfDir
|
|
||||||
packageConfDir="$builddir/package.conf.d"
|
|
||||||
mkdir -p $packageConfDir
|
|
||||||
|
|
||||||
setupCompileFlags="${concatStringsSep " " setupCompileFlags}"
|
|
||||||
configureFlags="${concatStringsSep " " defaultConfigureFlags} $configureFlags"
|
|
||||||
''
|
|
||||||
# We build the Setup.hs on the *build* machine, and as such should only add
|
|
||||||
# dependencies for the build machine.
|
|
||||||
#
|
|
||||||
# pkgs* arrays defined in stdenv/setup.hs
|
|
||||||
+ ''
|
|
||||||
for p in "''${pkgsBuildBuild[@]}" "''${pkgsBuildHost[@]}" "''${pkgsBuildTarget[@]}"; do
|
|
||||||
${buildPkgDb nativeGhc "$setupPackageConfDir"}
|
|
||||||
done
|
|
||||||
${nativeGhcCommand}-pkg --package-db="$setupPackageConfDir" recache
|
|
||||||
''
|
|
||||||
# For normal components
|
|
||||||
+ ''
|
|
||||||
for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do
|
|
||||||
${buildPkgDb ghc "$packageConfDir"}
|
|
||||||
if [ -d "$p/include" ]; then
|
|
||||||
configureFlags+=" --extra-include-dirs=$p/include"
|
|
||||||
fi
|
|
||||||
if [ -d "$p/lib" ]; then
|
|
||||||
configureFlags+=" --extra-lib-dirs=$p/lib"
|
|
||||||
fi
|
|
||||||
if [[ -d "$p/Library/Frameworks" ]]; then
|
|
||||||
configureFlags+=" --extra-framework-dirs=$p/Library/Frameworks"
|
|
||||||
fi
|
|
||||||
'' + ''
|
|
||||||
done
|
|
||||||
''
|
|
||||||
+ (optionalString stdenv.hostPlatform.isGhcjs ''
|
|
||||||
export EM_CACHE="$(realpath "$(mktemp -d emcache.XXXXXXXXXX)")"
|
|
||||||
cp -Lr ${emscripten}/share/emscripten/cache/* "$EM_CACHE/"
|
|
||||||
chmod u+rwX -R "$EM_CACHE"
|
|
||||||
'')
|
|
||||||
# only use the links hack if we're actually building dylibs. otherwise, the
|
|
||||||
# "dynamic-library-dirs" point to nonexistent paths, and the ln command becomes
|
|
||||||
# "ln -s $out/lib/links", which tries to recreate the links dir and fails
|
|
||||||
#
|
|
||||||
# Note: We need to disable this work-around when using intermediate build
|
|
||||||
# products from a prior build because otherwise Nix will change permissions on
|
|
||||||
# the `$out/lib/links` directory to read-only when the build is done after the
|
|
||||||
# dist directory has already been exported, which triggers an unnecessary
|
|
||||||
# rebuild of modules included in the exported dist directory.
|
|
||||||
+ (optionalString (stdenv.isDarwin && (enableSharedLibraries || enableSharedExecutables) && !enableSeparateIntermediatesOutput) ''
|
|
||||||
# Work around a limit in the macOS Sierra linker on the number of paths
|
|
||||||
# referenced by any one dynamic library:
|
|
||||||
#
|
|
||||||
# Create a local directory with symlinks of the *.dylib (macOS shared
|
|
||||||
# libraries) from all the dependencies.
|
|
||||||
local dynamicLinksDir="$out/lib/links"
|
|
||||||
mkdir -p $dynamicLinksDir
|
|
||||||
|
|
||||||
# Unprettify all package conf files before reading/writing them
|
|
||||||
for d in "$packageConfDir/"*; do
|
|
||||||
# gawk -i inplace seems to strip the last newline
|
|
||||||
gawk -f ${unprettyConf} "$d" > tmp
|
|
||||||
mv tmp "$d"
|
|
||||||
done
|
|
||||||
|
|
||||||
for d in $(grep '^dynamic-library-dirs:' "$packageConfDir"/* | cut -d' ' -f2- | tr ' ' '\n' | sort -u); do
|
|
||||||
for lib in "$d/"*.{dylib,so}; do
|
|
||||||
# Allow overwriting because C libs can be pulled in multiple times.
|
|
||||||
ln -sf "$lib" "$dynamicLinksDir"
|
|
||||||
done
|
|
||||||
done
|
|
||||||
# Edit the local package DB to reference the links directory.
|
|
||||||
for f in "$packageConfDir/"*.conf; do
|
|
||||||
sed -i "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," "$f"
|
|
||||||
done
|
|
||||||
'') + ''
|
|
||||||
${ghcCommand}-pkg --package-db="$packageConfDir" recache
|
|
||||||
|
|
||||||
runHook postSetupCompilerEnvironment
|
|
||||||
'';
|
|
||||||
|
|
||||||
compileBuildDriverPhase = ''
|
|
||||||
runHook preCompileBuildDriver
|
|
||||||
|
|
||||||
for i in Setup.hs Setup.lhs ${defaultSetupHs}; do
|
|
||||||
test -f $i && break
|
|
||||||
done
|
|
||||||
|
|
||||||
echo setupCompileFlags: $setupCompileFlags
|
|
||||||
${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $builddir -hidir $builddir $i
|
|
||||||
|
|
||||||
runHook postCompileBuildDriver
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Cabal takes flags like `--configure-option=--host=...` instead
|
|
||||||
configurePlatforms = [];
|
|
||||||
inherit configureFlags;
|
|
||||||
|
|
||||||
# Note: the options here must be always added, regardless of whether the
|
|
||||||
# package specifies `hardeningDisable`.
|
|
||||||
hardeningDisable = lib.optionals (args ? hardeningDisable) hardeningDisable
|
|
||||||
++ lib.optional (ghc.isHaLVM or false) "all"
|
|
||||||
# Static libraries (ie. all of pkgsStatic.haskellPackages) fail to build
|
|
||||||
# because by default Nix adds `-pie` to the linker flags: this
|
|
||||||
# conflicts with the `-r` and `-no-pie` flags added by GHC (see
|
|
||||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/19580). hardeningDisable
|
|
||||||
# changes the default Nix behavior regarding adding "hardening" flags.
|
|
||||||
++ lib.optional enableStaticLibraries "pie";
|
|
||||||
|
|
||||||
configurePhase = ''
|
|
||||||
runHook preConfigure
|
|
||||||
|
|
||||||
unset GHC_PACKAGE_PATH # Cabal complains if this variable is set during configure.
|
|
||||||
|
|
||||||
echo configureFlags: $configureFlags
|
|
||||||
${setupCommand} configure $configureFlags 2>&1 | ${coreutils}/bin/tee "$NIX_BUILD_TOP/cabal-configure.log"
|
|
||||||
${lib.optionalString (!allowInconsistentDependencies) ''
|
|
||||||
if ${gnugrep}/bin/egrep -q -z 'Warning:.*depends on multiple versions' "$NIX_BUILD_TOP/cabal-configure.log"; then
|
|
||||||
echo >&2 "*** abort because of serious configure-time warning from Cabal"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
''}
|
|
||||||
export GHC_PACKAGE_PATH="$packageConfDir:"
|
|
||||||
|
|
||||||
runHook postConfigure
|
|
||||||
'';
|
|
||||||
|
|
||||||
buildPhase =
|
|
||||||
''
|
|
||||||
runHook preBuild
|
|
||||||
''
|
|
||||||
+ lib.optionalString (previousIntermediates != null)
|
|
||||||
''
|
|
||||||
mkdir -p dist;
|
|
||||||
rm -r dist/build
|
|
||||||
cp -r ${previousIntermediates}/${intermediatesDir}/build dist/build
|
|
||||||
find dist/build -exec chmod u+w {} +
|
|
||||||
find dist/build -exec touch -d '1970-01-01T00:00:00Z' {} +
|
|
||||||
''
|
|
||||||
+ ''
|
|
||||||
${setupCommand} build ${buildTarget}${crossCabalFlagsString}${buildFlagsString}
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
|
|
||||||
inherit doCheck;
|
|
||||||
|
|
||||||
# Run test suite(s) and pass `checkFlags` as well as `checkFlagsArray`.
|
|
||||||
# `testFlags` are added to `checkFlagsArray` each prefixed with
|
|
||||||
# `--test-option`, so Cabal passes it to the underlying test suite binary.
|
|
||||||
checkPhase = ''
|
|
||||||
runHook preCheck
|
|
||||||
checkFlagsArray+=(
|
|
||||||
"--show-details=streaming"
|
|
||||||
${lib.escapeShellArgs (builtins.map (opt: "--test-option=${opt}") testFlags)}
|
|
||||||
)
|
|
||||||
${setupCommand} test ${testTarget} $checkFlags ''${checkFlagsArray:+"''${checkFlagsArray[@]}"}
|
|
||||||
runHook postCheck
|
|
||||||
'';
|
|
||||||
|
|
||||||
haddockPhase = ''
|
|
||||||
runHook preHaddock
|
|
||||||
${optionalString (doHaddock && isLibrary) ''
|
|
||||||
${setupCommand} haddock --html \
|
|
||||||
${optionalString doHoogle "--hoogle"} \
|
|
||||||
${optionalString doHaddockQuickjump "--quickjump"} \
|
|
||||||
${optionalString (isLibrary && hyperlinkSource) "--hyperlink-source"} \
|
|
||||||
${lib.concatStringsSep " " haddockFlags}
|
|
||||||
''}
|
|
||||||
runHook postHaddock
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
|
|
||||||
${if !isLibrary && buildTarget == "" then "${setupCommand} install"
|
|
||||||
# ^^ if the project is not a library, and no build target is specified, we can just use "install".
|
|
||||||
else if !isLibrary then "${setupCommand} copy ${buildTarget}"
|
|
||||||
# ^^ if the project is not a library, and we have a build target, then use "copy" to install
|
|
||||||
# just the target specified; "install" will error here, since not all targets have been built.
|
|
||||||
else ''
|
|
||||||
${setupCommand} copy ${buildTarget}
|
|
||||||
local packageConfDir="$out/${ghcLibdir}/package.conf.d"
|
|
||||||
local packageConfFile="$packageConfDir/${pname}-${version}.conf"
|
|
||||||
mkdir -p "$packageConfDir"
|
|
||||||
${setupCommand} register --gen-pkg-config=$packageConfFile
|
|
||||||
if [ -d "$packageConfFile" ]; then
|
|
||||||
mv "$packageConfFile/"* "$packageConfDir"
|
|
||||||
rmdir "$packageConfFile"
|
|
||||||
fi
|
|
||||||
for packageConfFile in "$packageConfDir/"*; do
|
|
||||||
local pkgId=$(gawk -f ${unprettyConf} "$packageConfFile" \
|
|
||||||
| grep '^id:' | cut -d' ' -f2)
|
|
||||||
mv "$packageConfFile" "$packageConfDir/$pkgId.conf"
|
|
||||||
done
|
|
||||||
|
|
||||||
# delete confdir if there are no libraries
|
|
||||||
find $packageConfDir -maxdepth 0 -empty -delete;
|
|
||||||
''}
|
|
||||||
${optionalString isGhcjs ''
|
|
||||||
for exeDir in "${binDir}/"*.jsexe; do
|
|
||||||
exe="''${exeDir%.jsexe}"
|
|
||||||
printWords '#!${nodejs}/bin/node' > "$exe"
|
|
||||||
echo >> "$exe"
|
|
||||||
cat "$exeDir/all.js" >> "$exe"
|
|
||||||
chmod +x "$exe"
|
|
||||||
done
|
|
||||||
''}
|
|
||||||
${optionalString doCoverage "mkdir -p $out/share && cp -r dist/hpc $out/share"}
|
|
||||||
|
|
||||||
${optionalString enableSeparateDocOutput ''
|
|
||||||
for x in ${docdir "$doc"}"/html/src/"*.html; do
|
|
||||||
remove-references-to -t $out $x
|
|
||||||
done
|
|
||||||
mkdir -p $doc
|
|
||||||
''}
|
|
||||||
${optionalString enableSeparateDataOutput "mkdir -p $data"}
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
${if doInstallIntermediates then "installIntermediatesPhase" else null} = ''
|
|
||||||
runHook preInstallIntermediates
|
|
||||||
intermediatesOutput=${if enableSeparateIntermediatesOutput then "$intermediates" else "$out"}
|
|
||||||
installIntermediatesDir="$intermediatesOutput/${intermediatesDir}"
|
|
||||||
mkdir -p "$installIntermediatesDir"
|
|
||||||
cp -r dist/build "$installIntermediatesDir"
|
|
||||||
runHook postInstallIntermediates
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = passthru // rec {
|
|
||||||
|
|
||||||
inherit pname version;
|
|
||||||
|
|
||||||
compiler = ghc;
|
|
||||||
|
|
||||||
# All this information is intended just for `shellFor`. It should be
|
|
||||||
# considered unstable and indeed we knew how to keep it private we would.
|
|
||||||
getCabalDeps = {
|
|
||||||
inherit
|
|
||||||
buildDepends
|
|
||||||
buildTools
|
|
||||||
executableFrameworkDepends
|
|
||||||
executableHaskellDepends
|
|
||||||
executablePkgconfigDepends
|
|
||||||
executableSystemDepends
|
|
||||||
executableToolDepends
|
|
||||||
extraLibraries
|
|
||||||
libraryFrameworkDepends
|
|
||||||
libraryHaskellDepends
|
|
||||||
libraryPkgconfigDepends
|
|
||||||
librarySystemDepends
|
|
||||||
libraryToolDepends
|
|
||||||
pkg-configDepends
|
|
||||||
setupHaskellDepends
|
|
||||||
;
|
|
||||||
} // lib.optionalAttrs doCheck {
|
|
||||||
inherit
|
|
||||||
testDepends
|
|
||||||
testFrameworkDepends
|
|
||||||
testHaskellDepends
|
|
||||||
testPkgconfigDepends
|
|
||||||
testSystemDepends
|
|
||||||
testToolDepends
|
|
||||||
;
|
|
||||||
} // lib.optionalAttrs doBenchmark {
|
|
||||||
inherit
|
|
||||||
benchmarkDepends
|
|
||||||
benchmarkFrameworkDepends
|
|
||||||
benchmarkHaskellDepends
|
|
||||||
benchmarkPkgconfigDepends
|
|
||||||
benchmarkSystemDepends
|
|
||||||
benchmarkToolDepends
|
|
||||||
;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Attributes for the old definition of `shellFor`. Should be removed but
|
|
||||||
# this predates the warning at the top of `getCabalDeps`.
|
|
||||||
getBuildInputs = rec {
|
|
||||||
inherit propagatedBuildInputs otherBuildInputs allPkgconfigDepends;
|
|
||||||
haskellBuildInputs = isHaskellPartition.right;
|
|
||||||
systemBuildInputs = isHaskellPartition.wrong;
|
|
||||||
isHaskellPartition = lib.partition
|
|
||||||
isHaskellPkg
|
|
||||||
(propagatedBuildInputs ++ otherBuildInputs ++ depsBuildBuild ++ nativeBuildInputs);
|
|
||||||
};
|
|
||||||
|
|
||||||
isHaskellLibrary = isLibrary;
|
|
||||||
|
|
||||||
# TODO: ask why the split outputs are configurable at all?
|
|
||||||
# TODO: include tests for split if possible
|
|
||||||
# Given the haskell package, returns
|
|
||||||
# the directory containing the haddock documentation.
|
|
||||||
# `null' if no haddock documentation was built.
|
|
||||||
# TODO: fetch the self from the fixpoint instead
|
|
||||||
haddockDir = self: if doHaddock then "${docdir self.doc}/html" else null;
|
|
||||||
|
|
||||||
# Creates a derivation containing all of the necessary dependencies for building the
|
|
||||||
# parent derivation. The attribute set that it takes as input can be viewed as:
|
|
||||||
#
|
|
||||||
# { withHoogle }
|
|
||||||
#
|
|
||||||
# The derivation that it builds contains no outpaths because it is meant for use
|
|
||||||
# as an environment
|
|
||||||
#
|
|
||||||
# # Example use
|
|
||||||
# # Creates a shell with all of the dependencies required to build the "hello" package,
|
|
||||||
# # and with python:
|
|
||||||
#
|
|
||||||
# > nix-shell -E 'with (import <nixpkgs> {}); \
|
|
||||||
# > haskell.packages.ghc865.hello.envFunc { buildInputs = [ python ]; }'
|
|
||||||
envFunc = { withHoogle ? false }:
|
|
||||||
let
|
|
||||||
name = "ghc-shell-for-${drv.name}";
|
|
||||||
|
|
||||||
withPackages = if withHoogle then ghcWithHoogle else ghcWithPackages;
|
|
||||||
|
|
||||||
# We use the `ghcWithPackages` function from `buildHaskellPackages` if we
|
|
||||||
# want a shell for the sake of cross compiling a package. In the native case
|
|
||||||
# we don't use this at all, and instead put the setupDepends in the main
|
|
||||||
# `ghcWithPackages`. This way we don't have two wrapper scripts called `ghc`
|
|
||||||
# shadowing each other on the PATH.
|
|
||||||
ghcEnvForBuild =
|
|
||||||
assert isCross;
|
|
||||||
buildHaskellPackages.ghcWithPackages (_: setupHaskellDepends);
|
|
||||||
|
|
||||||
ghcEnv = withPackages (_:
|
|
||||||
otherBuildInputsHaskell ++
|
|
||||||
propagatedBuildInputs ++
|
|
||||||
lib.optionals (!isCross) setupHaskellDepends);
|
|
||||||
|
|
||||||
ghcCommandCaps = lib.toUpper ghcCommand';
|
|
||||||
in stdenv.mkDerivation {
|
|
||||||
inherit name shellHook;
|
|
||||||
|
|
||||||
depsBuildBuild = lib.optional isCross ghcEnvForBuild;
|
|
||||||
nativeBuildInputs =
|
|
||||||
[ ghcEnv ] ++ optional (allPkgconfigDepends != []) pkg-config ++
|
|
||||||
collectedToolDepends;
|
|
||||||
buildInputs =
|
|
||||||
otherBuildInputsSystem;
|
|
||||||
phases = ["installPhase"];
|
|
||||||
installPhase = "echo $nativeBuildInputs $buildInputs > $out";
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
LOCALE_ARCHIVE = lib.optionalString (stdenv.hostPlatform.libc == "glibc") "${buildPackages.glibcLocales}/lib/locale/locale-archive";
|
|
||||||
"NIX_${ghcCommandCaps}" = "${ghcEnv}/bin/${ghcCommand}";
|
|
||||||
"NIX_${ghcCommandCaps}PKG" = "${ghcEnv}/bin/${ghcCommand}-pkg";
|
|
||||||
# TODO: is this still valid?
|
|
||||||
"NIX_${ghcCommandCaps}_DOCDIR" = "${ghcEnv}/share/doc/ghc/html";
|
|
||||||
"NIX_${ghcCommandCaps}_LIBDIR" = if ghc.isHaLVM or false
|
|
||||||
then "${ghcEnv}/lib/HaLVM-${ghc.version}"
|
|
||||||
else "${ghcEnv}/${ghcLibdir}";
|
|
||||||
};
|
|
||||||
|
|
||||||
env = envFunc { };
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = { inherit homepage license platforms; }
|
|
||||||
// optionalAttrs (args ? broken) { inherit broken; }
|
|
||||||
// optionalAttrs (args ? description) { inherit description; }
|
|
||||||
// optionalAttrs (args ? maintainers) { inherit maintainers; }
|
|
||||||
// optionalAttrs (args ? hydraPlatforms) { inherit hydraPlatforms; }
|
|
||||||
// optionalAttrs (args ? badPlatforms) { inherit badPlatforms; }
|
|
||||||
// optionalAttrs (args ? changelog) { inherit changelog; }
|
|
||||||
// optionalAttrs (args ? mainProgram) { inherit mainProgram; }
|
|
||||||
;
|
|
||||||
|
|
||||||
}
|
|
||||||
// optionalAttrs (args ? preCompileBuildDriver) { inherit preCompileBuildDriver; }
|
|
||||||
// optionalAttrs (args ? postCompileBuildDriver) { inherit postCompileBuildDriver; }
|
|
||||||
// optionalAttrs (args ? preUnpack) { inherit preUnpack; }
|
|
||||||
// optionalAttrs (args ? postUnpack) { inherit postUnpack; }
|
|
||||||
// optionalAttrs (args ? patches) { inherit patches; }
|
|
||||||
// optionalAttrs (args ? patchPhase) { inherit patchPhase; }
|
|
||||||
// optionalAttrs (args ? preConfigure) { inherit preConfigure; }
|
|
||||||
// optionalAttrs (args ? postConfigure) { inherit postConfigure; }
|
|
||||||
// optionalAttrs (args ? preBuild) { inherit preBuild; }
|
|
||||||
// optionalAttrs (args ? postBuild) { inherit postBuild; }
|
|
||||||
// optionalAttrs (args ? doBenchmark) { inherit doBenchmark; }
|
|
||||||
// optionalAttrs (args ? checkPhase) { inherit checkPhase; }
|
|
||||||
// optionalAttrs (args ? preCheck) { inherit preCheck; }
|
|
||||||
// optionalAttrs (args ? postCheck) { inherit postCheck; }
|
|
||||||
// optionalAttrs (args ? preHaddock) { inherit preHaddock; }
|
|
||||||
// optionalAttrs (args ? postHaddock) { inherit postHaddock; }
|
|
||||||
// optionalAttrs (args ? preInstall) { inherit preInstall; }
|
|
||||||
// optionalAttrs (args ? installPhase) { inherit installPhase; }
|
|
||||||
// optionalAttrs (args ? postInstall) { inherit postInstall; }
|
|
||||||
// optionalAttrs (args ? preFixup) { inherit preFixup; }
|
|
||||||
// optionalAttrs (args ? postFixup) { inherit postFixup; }
|
|
||||||
// optionalAttrs (args ? dontStrip) { inherit dontStrip; }
|
|
||||||
// optionalAttrs (postPhases != []) { inherit postPhases; }
|
|
||||||
// optionalAttrs (stdenv.buildPlatform.libc == "glibc"){ LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; }
|
|
||||||
|
|
||||||
# Implicit pointer to integer conversions are errors by default since clang 15.
|
|
||||||
# Works around https://gitlab.haskell.org/ghc/ghc/-/issues/23456.
|
|
||||||
// lib.optionalAttrs (stdenv.hasCC && stdenv.cc.isClang) {
|
|
||||||
NIX_CFLAGS_COMPILE = "-Wno-error=int-conversion";
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
|
@ -1,80 +0,0 @@
|
||||||
{ stdenv, ghc, pkg-config, glibcLocales
|
|
||||||
, cacert, stack, makeSetupHook, lib }@depArgs:
|
|
||||||
|
|
||||||
{ buildInputs ? []
|
|
||||||
, nativeBuildInputs ? []
|
|
||||||
, extraArgs ? []
|
|
||||||
, LD_LIBRARY_PATH ? []
|
|
||||||
, ghc ? depArgs.ghc
|
|
||||||
, stack ? depArgs.stack
|
|
||||||
, ...
|
|
||||||
}@args:
|
|
||||||
|
|
||||||
let
|
|
||||||
|
|
||||||
stackCmd = "stack --internal-re-exec-version=${stack.version}";
|
|
||||||
|
|
||||||
# Add all dependencies in buildInputs including propagated ones to
|
|
||||||
# STACK_IN_NIX_EXTRA_ARGS.
|
|
||||||
stackHook = makeSetupHook {
|
|
||||||
name = "stack-hook";
|
|
||||||
} ./stack-hook.sh;
|
|
||||||
|
|
||||||
in stdenv.mkDerivation (args // {
|
|
||||||
|
|
||||||
# Doesn't work in the sandbox. Pass `--option sandbox relaxed` or
|
|
||||||
# `--option sandbox false` to be able to build this
|
|
||||||
__noChroot = true;
|
|
||||||
|
|
||||||
buildInputs = buildInputs
|
|
||||||
++ lib.optional (stdenv.hostPlatform.libc == "glibc") glibcLocales;
|
|
||||||
|
|
||||||
nativeBuildInputs = nativeBuildInputs
|
|
||||||
++ [ ghc pkg-config stack stackHook ];
|
|
||||||
|
|
||||||
STACK_PLATFORM_VARIANT = "nix";
|
|
||||||
STACK_IN_NIX_SHELL = 1;
|
|
||||||
STACK_IN_NIX_EXTRA_ARGS = extraArgs;
|
|
||||||
|
|
||||||
# XXX: workaround for https://ghc.haskell.org/trac/ghc/ticket/11042.
|
|
||||||
LD_LIBRARY_PATH = lib.makeLibraryPath (LD_LIBRARY_PATH ++ buildInputs);
|
|
||||||
# ^^^ Internally uses `getOutput "lib"` (equiv. to getLib)
|
|
||||||
|
|
||||||
# Non-NixOS git needs cert
|
|
||||||
GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
|
|
||||||
|
|
||||||
# Fixes https://github.com/commercialhaskell/stack/issues/2358
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
|
|
||||||
preferLocalBuild = true;
|
|
||||||
|
|
||||||
preConfigure = ''
|
|
||||||
export STACK_ROOT=$NIX_BUILD_TOP/.stack
|
|
||||||
'';
|
|
||||||
|
|
||||||
buildPhase = args.buildPhase or ''
|
|
||||||
runHook preBuild
|
|
||||||
|
|
||||||
${stackCmd} build
|
|
||||||
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
|
|
||||||
checkPhase = args.checkPhase or ''
|
|
||||||
runHook preCheck
|
|
||||||
|
|
||||||
${stackCmd} test
|
|
||||||
|
|
||||||
runHook postCheck
|
|
||||||
'';
|
|
||||||
|
|
||||||
doCheck = args.doCheck or true;
|
|
||||||
|
|
||||||
installPhase = args.installPhase or ''
|
|
||||||
runHook preInstall
|
|
||||||
|
|
||||||
${stackCmd} --local-bin-path=$out/bin build --copy-bins
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
})
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +0,0 @@
|
||||||
#! @shell@
|
|
||||||
|
|
||||||
COMMAND=$1
|
|
||||||
shift
|
|
||||||
exec @hoogle@/bin/hoogle "$COMMAND" --database @out@/share/doc/hoogle/default.hoo "$@"
|
|
|
@ -1,126 +0,0 @@
|
||||||
# Install not only the Hoogle library and executable, but also a local Hoogle
|
|
||||||
# database which provides "Source" links to all specified 'packages' -- or the
|
|
||||||
# current Haskell Platform if no custom package set is provided.
|
|
||||||
|
|
||||||
{ lib, stdenv, buildPackages, haskellPackages
|
|
||||||
, writeText
|
|
||||||
}:
|
|
||||||
|
|
||||||
# This argument is a function which selects a list of Haskell packages from any
|
|
||||||
# passed Haskell package set.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
# (hpkgs: [ hpkgs.mtl hpkgs.lens ])
|
|
||||||
selectPackages:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (haskellPackages) ghc hoogle;
|
|
||||||
packages = selectPackages haskellPackages;
|
|
||||||
|
|
||||||
wrapper = ./hoogle-local-wrapper.sh;
|
|
||||||
isGhcjs = ghc.isGhcjs or false;
|
|
||||||
opts = lib.optionalString;
|
|
||||||
haddockExe =
|
|
||||||
if !isGhcjs
|
|
||||||
then "haddock"
|
|
||||||
else "haddock-ghcjs";
|
|
||||||
ghcDocLibDir =
|
|
||||||
if !isGhcjs
|
|
||||||
then ghc.doc + "/share/doc/ghc*/html/libraries"
|
|
||||||
else ghc + "/doc/lib";
|
|
||||||
# On GHCJS, use a stripped down version of GHC's prologue.txt
|
|
||||||
prologue =
|
|
||||||
if !isGhcjs
|
|
||||||
then "${ghcDocLibDir}/prologue.txt"
|
|
||||||
else writeText "ghcjs-prologue.txt" ''
|
|
||||||
This index includes documentation for many Haskell modules.
|
|
||||||
'';
|
|
||||||
|
|
||||||
docPackages = lib.closePropagation
|
|
||||||
# we grab the doc outputs
|
|
||||||
(map (lib.getOutput "doc") packages);
|
|
||||||
|
|
||||||
in
|
|
||||||
buildPackages.stdenv.mkDerivation {
|
|
||||||
name = "hoogle-with-packages";
|
|
||||||
buildInputs = [ghc hoogle];
|
|
||||||
|
|
||||||
# compiling databases takes less time than copying the results
|
|
||||||
# between machines.
|
|
||||||
preferLocalBuild = true;
|
|
||||||
|
|
||||||
# we still allow substitutes because a database is relatively small and if it
|
|
||||||
# is already built downloading is probably faster. The substitution will only
|
|
||||||
# trigger for users who have already cached the database on a substituter and
|
|
||||||
# thus probably intend to substitute it.
|
|
||||||
allowSubstitutes = true;
|
|
||||||
|
|
||||||
inherit docPackages;
|
|
||||||
|
|
||||||
passAsFile = ["buildCommand"];
|
|
||||||
|
|
||||||
buildCommand = ''
|
|
||||||
${let # Filter out nulls here to work around https://github.com/NixOS/nixpkgs/issues/82245
|
|
||||||
# If we don't then grabbing `p.name` here will fail.
|
|
||||||
packages' = lib.filter (p: p != null) packages;
|
|
||||||
in lib.optionalString (packages' != [] -> docPackages == [])
|
|
||||||
("echo WARNING: localHoogle package list empty, even though"
|
|
||||||
+ " the following were specified: "
|
|
||||||
+ lib.concatMapStringsSep ", " (p: p.name) packages')}
|
|
||||||
mkdir -p $out/share/doc/hoogle
|
|
||||||
|
|
||||||
echo importing builtin packages
|
|
||||||
for docdir in ${ghcDocLibDir}"/"*; do
|
|
||||||
name="$(basename $docdir)"
|
|
||||||
${opts isGhcjs ''docdir="$docdir/html"''}
|
|
||||||
if [[ -d $docdir ]]; then
|
|
||||||
ln -sfn $docdir $out/share/doc/hoogle/$name
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo importing other packages
|
|
||||||
${lib.concatMapStringsSep "\n" (el: ''
|
|
||||||
ln -sfn ${el.haddockDir} "$out/share/doc/hoogle/${el.name}"
|
|
||||||
'')
|
|
||||||
(lib.filter (el: el.haddockDir != null)
|
|
||||||
(builtins.map (p: { haddockDir = if p ? haddockDir then p.haddockDir p else null;
|
|
||||||
name = p.pname; })
|
|
||||||
docPackages))}
|
|
||||||
|
|
||||||
echo building hoogle database
|
|
||||||
hoogle generate --database $out/share/doc/hoogle/default.hoo --local=$out/share/doc/hoogle
|
|
||||||
|
|
||||||
echo building haddock index
|
|
||||||
# adapted from GHC's gen_contents_index
|
|
||||||
cd $out/share/doc/hoogle
|
|
||||||
|
|
||||||
args=
|
|
||||||
for hdfile in $(ls -1 *"/"*.haddock | grep -v '/ghc\.haddock' | sort); do
|
|
||||||
name_version=`echo "$hdfile" | sed 's#/.*##'`
|
|
||||||
args="$args --read-interface=$name_version,$hdfile"
|
|
||||||
done
|
|
||||||
|
|
||||||
${ghc}/bin/${haddockExe} --gen-index --gen-contents -o . \
|
|
||||||
-t "Haskell Hierarchical Libraries" \
|
|
||||||
-p ${prologue} \
|
|
||||||
$args
|
|
||||||
|
|
||||||
echo finishing up
|
|
||||||
mkdir -p $out/bin
|
|
||||||
substitute ${wrapper} $out/bin/hoogle \
|
|
||||||
--subst-var out --subst-var-by shell ${stdenv.shell} \
|
|
||||||
--subst-var-by hoogle ${hoogle}
|
|
||||||
chmod +x $out/bin/hoogle
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
isHaskellLibrary = false; # for the filter in ./with-packages-wrapper.nix
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
description = "A local Hoogle database";
|
|
||||||
platforms = ghc.meta.platforms;
|
|
||||||
hydraPlatforms = with lib.platforms; none;
|
|
||||||
maintainers = with lib.maintainers; [ ttuegel ];
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,2 +0,0 @@
|
||||||
args@{ pkgs, lib, callPackage }: self:
|
|
||||||
(import ./hackage-packages.nix args self)
|
|
|
@ -1,519 +0,0 @@
|
||||||
# TODO(@Ericson2314): Remove `pkgs` param, which is only used for
|
|
||||||
# `buildStackProject`, `justStaticExecutables` and `checkUnusedPackages`
|
|
||||||
{ pkgs, lib }:
|
|
||||||
|
|
||||||
rec {
|
|
||||||
|
|
||||||
/* This function takes a file like `hackage-packages.nix` and constructs
|
|
||||||
a full package set out of that.
|
|
||||||
*/
|
|
||||||
makePackageSet = import ../make-package-set.nix;
|
|
||||||
|
|
||||||
/* The function overrideCabal lets you alter the arguments to the
|
|
||||||
mkDerivation function.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
First, note how the aeson package is constructed in hackage-packages.nix:
|
|
||||||
|
|
||||||
"aeson" = callPackage ({ mkDerivation, attoparsec, <snip>
|
|
||||||
}:
|
|
||||||
mkDerivation {
|
|
||||||
pname = "aeson";
|
|
||||||
<snip>
|
|
||||||
homepage = "https://github.com/bos/aeson";
|
|
||||||
})
|
|
||||||
|
|
||||||
The mkDerivation function of haskellPackages will take care of putting
|
|
||||||
the homepage in the right place, in meta.
|
|
||||||
|
|
||||||
> haskellPackages.aeson.meta.homepage
|
|
||||||
"https://github.com/bos/aeson"
|
|
||||||
|
|
||||||
> x = haskell.lib.compose.overrideCabal (old: { homepage = old.homepage + "#readme"; }) haskellPackages.aeson
|
|
||||||
> x.meta.homepage
|
|
||||||
"https://github.com/bos/aeson#readme"
|
|
||||||
|
|
||||||
*/
|
|
||||||
overrideCabal = f: drv: (drv.override (args: args // {
|
|
||||||
mkDerivation = drv: (args.mkDerivation drv).override f;
|
|
||||||
})) // {
|
|
||||||
overrideScope = scope: overrideCabal f (drv.overrideScope scope);
|
|
||||||
};
|
|
||||||
|
|
||||||
# : Map Name (Either Path VersionNumber) -> HaskellPackageOverrideSet
|
|
||||||
# Given a set whose values are either paths or version strings, produces
|
|
||||||
# a package override set (i.e. (self: super: { etc. })) that sets
|
|
||||||
# the packages named in the input set to the corresponding versions
|
|
||||||
packageSourceOverrides =
|
|
||||||
overrides: self: super: pkgs.lib.mapAttrs (name: src:
|
|
||||||
let isPath = x: builtins.substring 0 1 (toString x) == "/";
|
|
||||||
generateExprs = if isPath src
|
|
||||||
then self.callCabal2nix
|
|
||||||
else self.callHackage;
|
|
||||||
in generateExprs name src {}) overrides;
|
|
||||||
|
|
||||||
/* doCoverage modifies a haskell package to enable the generation
|
|
||||||
and installation of a coverage report.
|
|
||||||
|
|
||||||
See https://wiki.haskell.org/Haskell_program_coverage
|
|
||||||
*/
|
|
||||||
doCoverage = overrideCabal (drv: { doCoverage = true; });
|
|
||||||
|
|
||||||
/* dontCoverage modifies a haskell package to disable the generation
|
|
||||||
and installation of a coverage report.
|
|
||||||
*/
|
|
||||||
dontCoverage = overrideCabal (drv: { doCoverage = false; });
|
|
||||||
|
|
||||||
/* doHaddock modifies a haskell package to enable the generation and
|
|
||||||
installation of API documentation from code comments using the
|
|
||||||
haddock tool.
|
|
||||||
*/
|
|
||||||
doHaddock = overrideCabal (drv: { doHaddock = true; });
|
|
||||||
|
|
||||||
/* dontHaddock modifies a haskell package to disable the generation and
|
|
||||||
installation of API documentation from code comments using the
|
|
||||||
haddock tool.
|
|
||||||
*/
|
|
||||||
dontHaddock = overrideCabal (drv: { doHaddock = false; });
|
|
||||||
|
|
||||||
/* doJailbreak enables the removal of version bounds from the cabal
|
|
||||||
file. You may want to avoid this function.
|
|
||||||
|
|
||||||
This is useful when a package reports that it can not be built
|
|
||||||
due to version mismatches. In some cases, removing the version
|
|
||||||
bounds entirely is an easy way to make a package build, but at
|
|
||||||
the risk of breaking software in non-obvious ways now or in the
|
|
||||||
future.
|
|
||||||
|
|
||||||
Instead of jailbreaking, you can patch the cabal file.
|
|
||||||
|
|
||||||
Note that jailbreaking at this time, doesn't lift bounds on
|
|
||||||
conditional branches.
|
|
||||||
https://github.com/peti/jailbreak-cabal/issues/7 has further details.
|
|
||||||
|
|
||||||
*/
|
|
||||||
doJailbreak = overrideCabal (drv: { jailbreak = true; });
|
|
||||||
|
|
||||||
/* dontJailbreak restores the use of the version bounds the check
|
|
||||||
the use of dependencies in the package description.
|
|
||||||
*/
|
|
||||||
dontJailbreak = overrideCabal (drv: { jailbreak = false; });
|
|
||||||
|
|
||||||
/* doCheck enables dependency checking, compilation and execution
|
|
||||||
of test suites listed in the package description file.
|
|
||||||
*/
|
|
||||||
doCheck = overrideCabal (drv: { doCheck = true; });
|
|
||||||
/* dontCheck disables dependency checking, compilation and execution
|
|
||||||
of test suites listed in the package description file.
|
|
||||||
*/
|
|
||||||
dontCheck = overrideCabal (drv: { doCheck = false; });
|
|
||||||
/* The dontCheckIf variant sets doCheck = false if the condition
|
|
||||||
applies. In any other case the previously set/default value is used.
|
|
||||||
This prevents accidentally re-enabling tests in a later override.
|
|
||||||
*/
|
|
||||||
dontCheckIf = condition: if condition then dontCheck else lib.id;
|
|
||||||
|
|
||||||
/* doBenchmark enables dependency checking and compilation
|
|
||||||
for benchmarks listed in the package description file.
|
|
||||||
Benchmarks are, however, not executed at the moment.
|
|
||||||
*/
|
|
||||||
doBenchmark = overrideCabal (drv: { doBenchmark = true; });
|
|
||||||
/* dontBenchmark disables dependency checking, compilation and execution
|
|
||||||
for benchmarks listed in the package description file.
|
|
||||||
*/
|
|
||||||
dontBenchmark = overrideCabal (drv: { doBenchmark = false; });
|
|
||||||
|
|
||||||
/* doDistribute enables the distribution of binaries for the package
|
|
||||||
via hydra.
|
|
||||||
*/
|
|
||||||
doDistribute = overrideCabal (drv: {
|
|
||||||
# lib.platforms.all is the default value for platforms (since GHC can cross-compile)
|
|
||||||
hydraPlatforms = lib.subtractLists (drv.badPlatforms or [])
|
|
||||||
(drv.platforms or lib.platforms.all);
|
|
||||||
});
|
|
||||||
/* dontDistribute disables the distribution of binaries for the package
|
|
||||||
via hydra.
|
|
||||||
*/
|
|
||||||
dontDistribute = overrideCabal (drv: { hydraPlatforms = []; });
|
|
||||||
|
|
||||||
/* appendConfigureFlag adds a single argument that will be passed to the
|
|
||||||
cabal configure command, after the arguments that have been defined
|
|
||||||
in the initial declaration or previous overrides.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
> haskell.lib.compose.appendConfigureFlag "--profiling-detail=all-functions" haskellPackages.servant
|
|
||||||
*/
|
|
||||||
appendConfigureFlag = x: appendConfigureFlags [x];
|
|
||||||
appendConfigureFlags = xs: overrideCabal (drv: { configureFlags = (drv.configureFlags or []) ++ xs; });
|
|
||||||
|
|
||||||
appendBuildFlag = x: overrideCabal (drv: { buildFlags = (drv.buildFlags or []) ++ [x]; });
|
|
||||||
appendBuildFlags = xs: overrideCabal (drv: { buildFlags = (drv.buildFlags or []) ++ xs; });
|
|
||||||
|
|
||||||
/* removeConfigureFlag drv x is a Haskell package like drv, but with
|
|
||||||
all cabal configure arguments that are equal to x removed.
|
|
||||||
|
|
||||||
> haskell.lib.compose.removeConfigureFlag "--verbose" haskellPackages.servant
|
|
||||||
*/
|
|
||||||
removeConfigureFlag = x: overrideCabal (drv: { configureFlags = lib.remove x (drv.configureFlags or []); });
|
|
||||||
|
|
||||||
addBuildTool = x: addBuildTools [x];
|
|
||||||
addBuildTools = xs: overrideCabal (drv: { buildTools = (drv.buildTools or []) ++ xs; });
|
|
||||||
|
|
||||||
addExtraLibrary = x: addExtraLibraries [x];
|
|
||||||
addExtraLibraries = xs: overrideCabal (drv: { extraLibraries = (drv.extraLibraries or []) ++ xs; });
|
|
||||||
|
|
||||||
addBuildDepend = x: addBuildDepends [x];
|
|
||||||
addBuildDepends = xs: overrideCabal (drv: { buildDepends = (drv.buildDepends or []) ++ xs; });
|
|
||||||
|
|
||||||
addTestToolDepend = x: addTestToolDepends [x];
|
|
||||||
addTestToolDepends = xs: overrideCabal (drv: { testToolDepends = (drv.testToolDepends or []) ++ xs; });
|
|
||||||
|
|
||||||
addPkgconfigDepend = x: addPkgconfigDepends [x];
|
|
||||||
addPkgconfigDepends = xs: overrideCabal (drv: { pkg-configDepends = (drv.pkg-configDepends or []) ++ xs; });
|
|
||||||
|
|
||||||
addSetupDepend = x: addSetupDepends [x];
|
|
||||||
addSetupDepends = xs: overrideCabal (drv: { setupHaskellDepends = (drv.setupHaskellDepends or []) ++ xs; });
|
|
||||||
|
|
||||||
enableCabalFlag = x: drv: appendConfigureFlag "-f${x}" (removeConfigureFlag "-f-${x}" drv);
|
|
||||||
disableCabalFlag = x: drv: appendConfigureFlag "-f-${x}" (removeConfigureFlag "-f${x}" drv);
|
|
||||||
|
|
||||||
markBroken = overrideCabal (drv: { broken = true; hydraPlatforms = []; });
|
|
||||||
unmarkBroken = overrideCabal (drv: { broken = false; });
|
|
||||||
markBrokenVersion = version: drv: assert drv.version == version; markBroken drv;
|
|
||||||
markUnbroken = overrideCabal (drv: { broken = false; });
|
|
||||||
|
|
||||||
enableLibraryProfiling = overrideCabal (drv: { enableLibraryProfiling = true; });
|
|
||||||
disableLibraryProfiling = overrideCabal (drv: { enableLibraryProfiling = false; });
|
|
||||||
|
|
||||||
enableExecutableProfiling = overrideCabal (drv: { enableExecutableProfiling = true; });
|
|
||||||
disableExecutableProfiling = overrideCabal (drv: { enableExecutableProfiling = false; });
|
|
||||||
|
|
||||||
enableSharedExecutables = overrideCabal (drv: { enableSharedExecutables = true; });
|
|
||||||
disableSharedExecutables = overrideCabal (drv: { enableSharedExecutables = false; });
|
|
||||||
|
|
||||||
enableSharedLibraries = overrideCabal (drv: { enableSharedLibraries = true; });
|
|
||||||
disableSharedLibraries = overrideCabal (drv: { enableSharedLibraries = false; });
|
|
||||||
|
|
||||||
enableDeadCodeElimination = overrideCabal (drv: { enableDeadCodeElimination = true; });
|
|
||||||
disableDeadCodeElimination = overrideCabal (drv: { enableDeadCodeElimination = false; });
|
|
||||||
|
|
||||||
enableStaticLibraries = overrideCabal (drv: { enableStaticLibraries = true; });
|
|
||||||
disableStaticLibraries = overrideCabal (drv: { enableStaticLibraries = false; });
|
|
||||||
|
|
||||||
enableSeparateBinOutput = overrideCabal (drv: { enableSeparateBinOutput = true; });
|
|
||||||
|
|
||||||
appendPatch = x: appendPatches [x];
|
|
||||||
appendPatches = xs: overrideCabal (drv: { patches = (drv.patches or []) ++ xs; });
|
|
||||||
|
|
||||||
/* Set a specific build target instead of compiling all targets in the package.
|
|
||||||
* For example, imagine we have a .cabal file with a library, and 2 executables "dev" and "server".
|
|
||||||
* We can build only "server" and not wait on the compilation of "dev" by using setBuildTarget as follows:
|
|
||||||
*
|
|
||||||
* > setBuildTarget "server" (callCabal2nix "thePackageName" thePackageSrc {})
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
setBuildTargets = xs: overrideCabal (drv: { buildTarget = lib.concatStringsSep " " xs; });
|
|
||||||
setBuildTarget = x: setBuildTargets [x];
|
|
||||||
|
|
||||||
doHyperlinkSource = overrideCabal (drv: { hyperlinkSource = true; });
|
|
||||||
dontHyperlinkSource = overrideCabal (drv: { hyperlinkSource = false; });
|
|
||||||
|
|
||||||
disableHardening = flags: overrideCabal (drv: { hardeningDisable = flags; });
|
|
||||||
|
|
||||||
/* Let Nix strip the binary files.
|
|
||||||
* This removes debugging symbols.
|
|
||||||
*/
|
|
||||||
doStrip = overrideCabal (drv: { dontStrip = false; });
|
|
||||||
|
|
||||||
/* Stop Nix from stripping the binary files.
|
|
||||||
* This keeps debugging symbols.
|
|
||||||
*/
|
|
||||||
dontStrip = overrideCabal (drv: { dontStrip = true; });
|
|
||||||
|
|
||||||
/* Useful for debugging segfaults with gdb.
|
|
||||||
* This includes dontStrip.
|
|
||||||
*/
|
|
||||||
enableDWARFDebugging = drv:
|
|
||||||
# -g: enables debugging symbols
|
|
||||||
# --disable-*-stripping: tell GHC not to strip resulting binaries
|
|
||||||
# dontStrip: see above
|
|
||||||
appendConfigureFlag "--ghc-options=-g --disable-executable-stripping --disable-library-stripping" (dontStrip drv);
|
|
||||||
|
|
||||||
/* Create a source distribution tarball like those found on hackage,
|
|
||||||
instead of building the package.
|
|
||||||
*/
|
|
||||||
sdistTarball = pkg: lib.overrideDerivation pkg (drv: {
|
|
||||||
name = "${drv.pname}-source-${drv.version}";
|
|
||||||
# Since we disable the haddock phase, we also need to override the
|
|
||||||
# outputs since the separate doc output will not be produced.
|
|
||||||
outputs = ["out"];
|
|
||||||
buildPhase = "./Setup sdist";
|
|
||||||
haddockPhase = ":";
|
|
||||||
checkPhase = ":";
|
|
||||||
installPhase = "install -D dist/${drv.pname}-*.tar.gz $out/${drv.pname}-${drv.version}.tar.gz";
|
|
||||||
fixupPhase = ":";
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Create a documentation tarball suitable for uploading to Hackage instead
|
|
||||||
of building the package.
|
|
||||||
*/
|
|
||||||
documentationTarball = pkg:
|
|
||||||
pkgs.lib.overrideDerivation pkg (drv: {
|
|
||||||
name = "${drv.name}-docs";
|
|
||||||
# Like sdistTarball, disable the "doc" output here.
|
|
||||||
outputs = [ "out" ];
|
|
||||||
buildPhase = ''
|
|
||||||
runHook preHaddock
|
|
||||||
./Setup haddock --for-hackage
|
|
||||||
runHook postHaddock
|
|
||||||
'';
|
|
||||||
haddockPhase = ":";
|
|
||||||
checkPhase = ":";
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
mkdir -p "$out"
|
|
||||||
tar --format=ustar \
|
|
||||||
-czf "$out/${drv.name}-docs.tar.gz" \
|
|
||||||
-C dist/doc/html "${drv.name}-docs"
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Use the gold linker. It is a linker for ELF that is designed
|
|
||||||
"to run as fast as possible on modern systems"
|
|
||||||
*/
|
|
||||||
linkWithGold = appendConfigureFlag
|
|
||||||
"--ghc-option=-optl-fuse-ld=gold --ld-option=-fuse-ld=gold --with-ld=ld.gold";
|
|
||||||
|
|
||||||
/* link executables statically against haskell libs to reduce
|
|
||||||
closure size
|
|
||||||
*/
|
|
||||||
justStaticExecutables = overrideCabal (drv: {
|
|
||||||
enableSharedExecutables = false;
|
|
||||||
enableLibraryProfiling = false;
|
|
||||||
isLibrary = false;
|
|
||||||
doHaddock = false;
|
|
||||||
postFixup = drv.postFixup or "" + ''
|
|
||||||
|
|
||||||
# Remove every directory which could have links to other store paths.
|
|
||||||
rm -rf $out/lib $out/nix-support $out/share/doc
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Build a source distribution tarball instead of using the source files
|
|
||||||
directly. The effect is that the package is built as if it were published
|
|
||||||
on hackage. This can be used as a test for the source distribution,
|
|
||||||
assuming the build fails when packaging mistakes are in the cabal file.
|
|
||||||
|
|
||||||
A faster implementation using `cabal-install` is available as
|
|
||||||
`buildFromCabalSdist` in your Haskell package set.
|
|
||||||
*/
|
|
||||||
buildFromSdist = pkg: overrideCabal (drv: {
|
|
||||||
src = "${sdistTarball pkg}/${pkg.pname}-${pkg.version}.tar.gz";
|
|
||||||
|
|
||||||
# Revising and jailbreaking the cabal file has been handled in sdistTarball
|
|
||||||
revision = null;
|
|
||||||
editedCabalFile = null;
|
|
||||||
jailbreak = false;
|
|
||||||
}) pkg;
|
|
||||||
|
|
||||||
/* Build the package in a strict way to uncover potential problems.
|
|
||||||
This includes buildFromSdist and failOnAllWarnings.
|
|
||||||
*/
|
|
||||||
buildStrictly = pkg: buildFromSdist (failOnAllWarnings pkg);
|
|
||||||
|
|
||||||
/* Disable core optimizations, significantly speeds up build time */
|
|
||||||
disableOptimization = appendConfigureFlag "--disable-optimization";
|
|
||||||
|
|
||||||
/* Turn on most of the compiler warnings and fail the build if any
|
|
||||||
of them occur. */
|
|
||||||
failOnAllWarnings = appendConfigureFlag "--ghc-option=-Wall --ghc-option=-Werror";
|
|
||||||
|
|
||||||
/* Add a post-build check to verify that dependencies declared in
|
|
||||||
the cabal file are actually used.
|
|
||||||
|
|
||||||
The first attrset argument can be used to configure the strictness
|
|
||||||
of this check and a list of ignored package names that would otherwise
|
|
||||||
cause false alarms.
|
|
||||||
*/
|
|
||||||
checkUnusedPackages =
|
|
||||||
{ ignoreEmptyImports ? false
|
|
||||||
, ignoreMainModule ? false
|
|
||||||
, ignorePackages ? []
|
|
||||||
} : drv :
|
|
||||||
overrideCabal (_drv: {
|
|
||||||
postBuild = with lib;
|
|
||||||
let args = concatStringsSep " " (
|
|
||||||
optional ignoreEmptyImports "--ignore-empty-imports" ++
|
|
||||||
optional ignoreMainModule "--ignore-main-module" ++
|
|
||||||
map (pkg: "--ignore-package ${pkg}") ignorePackages
|
|
||||||
);
|
|
||||||
in "${pkgs.haskellPackages.packunused}/bin/packunused" +
|
|
||||||
optionalString (args != "") " ${args}";
|
|
||||||
}) (appendConfigureFlag "--ghc-option=-ddump-minimal-imports" drv);
|
|
||||||
|
|
||||||
buildStackProject = pkgs.callPackage ../generic-stack-builder.nix { };
|
|
||||||
|
|
||||||
/* Add a dummy command to trigger a build despite an equivalent
|
|
||||||
earlier build that is present in the store or cache.
|
|
||||||
*/
|
|
||||||
triggerRebuild = i: overrideCabal (drv: {
|
|
||||||
postUnpack = drv.postUnpack or "" + ''
|
|
||||||
|
|
||||||
# trigger rebuild ${toString i}
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Override the sources for the package and optionally the version.
|
|
||||||
This also takes of removing editedCabalFile.
|
|
||||||
*/
|
|
||||||
overrideSrc = { src, version ? null }: drv:
|
|
||||||
overrideCabal (_: { inherit src; version = if version == null then drv.version else version; editedCabalFile = null; }) drv;
|
|
||||||
|
|
||||||
# Get all of the build inputs of a haskell package, divided by category.
|
|
||||||
getBuildInputs = p: p.getBuildInputs;
|
|
||||||
|
|
||||||
# Extract the haskell build inputs of a haskell package.
|
|
||||||
# This is useful to build environments for developing on that
|
|
||||||
# package.
|
|
||||||
getHaskellBuildInputs = p: (getBuildInputs p).haskellBuildInputs;
|
|
||||||
|
|
||||||
# Under normal evaluation, simply return the original package. Under
|
|
||||||
# nix-shell evaluation, return a nix-shell optimized environment.
|
|
||||||
shellAware = p: if lib.inNixShell then p.env else p;
|
|
||||||
|
|
||||||
ghcInfo = ghc:
|
|
||||||
rec { isCross = (ghc.cross or null) != null;
|
|
||||||
isGhcjs = ghc.isGhcjs or false;
|
|
||||||
nativeGhc = if isCross || isGhcjs
|
|
||||||
then ghc.bootPkgs.ghc
|
|
||||||
else ghc;
|
|
||||||
};
|
|
||||||
|
|
||||||
### mkDerivation helpers
|
|
||||||
# These allow external users of a haskell package to extract
|
|
||||||
# information about how it is built in the same way that the
|
|
||||||
# generic haskell builder does, by reusing the same functions.
|
|
||||||
# Each function here has the same interface as mkDerivation and thus
|
|
||||||
# can be called for a given package simply by overriding the
|
|
||||||
# mkDerivation argument it used. See getHaskellBuildInputs above for
|
|
||||||
# an example of this.
|
|
||||||
|
|
||||||
# Some information about which phases should be run.
|
|
||||||
controlPhases = ghc: let inherit (ghcInfo ghc) isCross; in
|
|
||||||
{ doCheck ? !isCross
|
|
||||||
, doBenchmark ? false
|
|
||||||
, ...
|
|
||||||
}: { inherit doCheck doBenchmark; };
|
|
||||||
|
|
||||||
# Utility to convert a directory full of `cabal2nix`-generated files into a
|
|
||||||
# package override set
|
|
||||||
#
|
|
||||||
# packagesFromDirectory : { directory : Directory, ... } -> HaskellPackageOverrideSet
|
|
||||||
packagesFromDirectory =
|
|
||||||
{ directory, ... }:
|
|
||||||
|
|
||||||
self: super:
|
|
||||||
let
|
|
||||||
haskellPaths =
|
|
||||||
lib.filter (lib.hasSuffix ".nix")
|
|
||||||
(builtins.attrNames (builtins.readDir directory));
|
|
||||||
|
|
||||||
toKeyVal = file: {
|
|
||||||
name = builtins.replaceStrings [ ".nix" ] [ "" ] file;
|
|
||||||
|
|
||||||
value = self.callPackage (directory + "/${file}") { };
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
|
||||||
builtins.listToAttrs (map toKeyVal haskellPaths);
|
|
||||||
|
|
||||||
/*
|
|
||||||
INTERNAL function retained for backwards compatibility, use
|
|
||||||
haskell.packages.*.generateOptparseApplicativeCompletions instead!
|
|
||||||
*/
|
|
||||||
__generateOptparseApplicativeCompletion = exeName: overrideCabal (drv: {
|
|
||||||
postInstall = (drv.postInstall or "") + ''
|
|
||||||
bashCompDir="''${!outputBin}/share/bash-completion/completions"
|
|
||||||
zshCompDir="''${!outputBin}/share/zsh/vendor-completions"
|
|
||||||
fishCompDir="''${!outputBin}/share/fish/vendor_completions.d"
|
|
||||||
mkdir -p "$bashCompDir" "$zshCompDir" "$fishCompDir"
|
|
||||||
"''${!outputBin}/bin/${exeName}" --bash-completion-script "''${!outputBin}/bin/${exeName}" >"$bashCompDir/${exeName}"
|
|
||||||
"''${!outputBin}/bin/${exeName}" --zsh-completion-script "''${!outputBin}/bin/${exeName}" >"$zshCompDir/_${exeName}"
|
|
||||||
"''${!outputBin}/bin/${exeName}" --fish-completion-script "''${!outputBin}/bin/${exeName}" >"$fishCompDir/${exeName}.fish"
|
|
||||||
|
|
||||||
# Sanity check
|
|
||||||
grep -F ${exeName} <$bashCompDir/${exeName} >/dev/null || {
|
|
||||||
echo 'Could not find ${exeName} in completion script.'
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
Retained for backwards compatibility.
|
|
||||||
Use haskell.packages.*.generateOptparseApplicativeCompletions
|
|
||||||
which is cross aware instead.
|
|
||||||
*/
|
|
||||||
generateOptparseApplicativeCompletions = commands: pkg:
|
|
||||||
lib.warnIf (lib.isInOldestRelease 2211) "haskellLib.generateOptparseApplicativeCompletions is deprecated in favor of haskellPackages.generateOptparseApplicativeCompletions. Please change ${pkg.name} to use the latter and make sure it uses its matching haskell.packages set!"
|
|
||||||
(pkgs.lib.foldr __generateOptparseApplicativeCompletion pkg commands);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Retained for backwards compatibility.
|
|
||||||
Use haskell.packages.*.generateOptparseApplicativeCompletions
|
|
||||||
which is cross aware instead.
|
|
||||||
*/
|
|
||||||
generateOptparseApplicativeCompletion = command: pkg:
|
|
||||||
lib.warnIf (lib.isInOldestRelease 2211) "haskellLib.generateOptparseApplicativeCompletion is deprecated in favor of haskellPackages.generateOptparseApplicativeCompletions (plural!). Please change ${pkg.name} to use the latter and make sure it uses its matching haskell.packages set!"
|
|
||||||
(__generateOptparseApplicativeCompletion command pkg);
|
|
||||||
|
|
||||||
# Don't fail at configure time if there are multiple versions of the
|
|
||||||
# same package in the (recursive) dependencies of the package being
|
|
||||||
# built. Will delay failures, if any, to compile time.
|
|
||||||
allowInconsistentDependencies = overrideCabal (drv: {
|
|
||||||
allowInconsistentDependencies = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
# Work around a Cabal bug requiring pkg-config --static --libs to work even
|
|
||||||
# when linking dynamically, affecting Cabal 3.8 and 3.9.
|
|
||||||
# https://github.com/haskell/cabal/issues/8455
|
|
||||||
#
|
|
||||||
# For this, we treat the runtime system/pkg-config dependencies of a Haskell
|
|
||||||
# derivation as if they were propagated from their dependencies which allows
|
|
||||||
# pkg-config --static to work in most cases.
|
|
||||||
#
|
|
||||||
# Warning: This function may change or be removed at any time, e.g. if we find
|
|
||||||
# a different workaround, upstream fixes the bug or we patch Cabal.
|
|
||||||
__CabalEagerPkgConfigWorkaround =
|
|
||||||
let
|
|
||||||
# Take list of derivations and return list of the transitive dependency
|
|
||||||
# closure, only taking into account buildInputs. Loosely based on
|
|
||||||
# closePropagationFast.
|
|
||||||
propagatedPlainBuildInputs = drvs:
|
|
||||||
builtins.map (i: i.val) (
|
|
||||||
builtins.genericClosure {
|
|
||||||
startSet = builtins.map (drv:
|
|
||||||
{ key = drv.outPath; val = drv; }
|
|
||||||
) drvs;
|
|
||||||
operator = { val, ... }:
|
|
||||||
if !lib.isDerivation val
|
|
||||||
then [ ]
|
|
||||||
else
|
|
||||||
builtins.concatMap (drv:
|
|
||||||
if !lib.isDerivation drv
|
|
||||||
then [ ]
|
|
||||||
else [ { key = drv.outPath; val = drv; } ]
|
|
||||||
) (val.buildInputs or [ ] ++ val.propagatedBuildInputs or [ ]);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
in
|
|
||||||
overrideCabal (old: {
|
|
||||||
benchmarkPkgconfigDepends = propagatedPlainBuildInputs old.benchmarkPkgconfigDepends or [ ];
|
|
||||||
executablePkgconfigDepends = propagatedPlainBuildInputs old.executablePkgconfigDepends or [ ];
|
|
||||||
libraryPkgconfigDepends = propagatedPlainBuildInputs old.libraryPkgconfigDepends or [ ];
|
|
||||||
testPkgconfigDepends = propagatedPlainBuildInputs old.testPkgconfigDepends or [ ];
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,362 +0,0 @@
|
||||||
# TODO(@Ericson2314): Remove `pkgs` param, which is only used for
|
|
||||||
# `buildStackProject`, `justStaticExecutables` and `checkUnusedPackages`
|
|
||||||
{ pkgs, lib }:
|
|
||||||
|
|
||||||
rec {
|
|
||||||
/* The same functionality as this haskell.lib, except that the derivation
|
|
||||||
being overridden is always the last parameter. This permits more natural
|
|
||||||
composition of several overrides, i.e. without having to nestle one call
|
|
||||||
between the function name and argument of another. haskell.lib.compose is
|
|
||||||
preferred for any new code.
|
|
||||||
*/
|
|
||||||
compose = import ./compose.nix { inherit pkgs lib; };
|
|
||||||
|
|
||||||
/* This function takes a file like `hackage-packages.nix` and constructs
|
|
||||||
a full package set out of that.
|
|
||||||
*/
|
|
||||||
makePackageSet = compose.makePackageSet;
|
|
||||||
|
|
||||||
/* The function overrideCabal lets you alter the arguments to the
|
|
||||||
mkDerivation function.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
First, note how the aeson package is constructed in hackage-packages.nix:
|
|
||||||
|
|
||||||
"aeson" = callPackage ({ mkDerivation, attoparsec, <snip>
|
|
||||||
}:
|
|
||||||
mkDerivation {
|
|
||||||
pname = "aeson";
|
|
||||||
<snip>
|
|
||||||
homepage = "https://github.com/bos/aeson";
|
|
||||||
})
|
|
||||||
|
|
||||||
The mkDerivation function of haskellPackages will take care of putting
|
|
||||||
the homepage in the right place, in meta.
|
|
||||||
|
|
||||||
> haskellPackages.aeson.meta.homepage
|
|
||||||
"https://github.com/bos/aeson"
|
|
||||||
|
|
||||||
> x = haskell.lib.overrideCabal haskellPackages.aeson (old: { homepage = old.homepage + "#readme"; })
|
|
||||||
> x.meta.homepage
|
|
||||||
"https://github.com/bos/aeson#readme"
|
|
||||||
|
|
||||||
*/
|
|
||||||
overrideCabal = drv: f: compose.overrideCabal f drv;
|
|
||||||
|
|
||||||
# : Map Name (Either Path VersionNumber) -> HaskellPackageOverrideSet
|
|
||||||
# Given a set whose values are either paths or version strings, produces
|
|
||||||
# a package override set (i.e. (self: super: { etc. })) that sets
|
|
||||||
# the packages named in the input set to the corresponding versions
|
|
||||||
packageSourceOverrides = compose.packageSourceOverrides;
|
|
||||||
|
|
||||||
/* doCoverage modifies a haskell package to enable the generation
|
|
||||||
and installation of a coverage report.
|
|
||||||
|
|
||||||
See https://wiki.haskell.org/Haskell_program_coverage
|
|
||||||
*/
|
|
||||||
doCoverage = compose.doCoverage;
|
|
||||||
|
|
||||||
/* dontCoverage modifies a haskell package to disable the generation
|
|
||||||
and installation of a coverage report.
|
|
||||||
*/
|
|
||||||
dontCoverage = compose.dontCoverage;
|
|
||||||
|
|
||||||
/* doHaddock modifies a haskell package to enable the generation and
|
|
||||||
installation of API documentation from code comments using the
|
|
||||||
haddock tool.
|
|
||||||
*/
|
|
||||||
doHaddock = compose.doHaddock;
|
|
||||||
|
|
||||||
/* dontHaddock modifies a haskell package to disable the generation and
|
|
||||||
installation of API documentation from code comments using the
|
|
||||||
haddock tool.
|
|
||||||
*/
|
|
||||||
dontHaddock = compose.dontHaddock;
|
|
||||||
|
|
||||||
/* doJailbreak enables the removal of version bounds from the cabal
|
|
||||||
file. You may want to avoid this function.
|
|
||||||
|
|
||||||
This is useful when a package reports that it can not be built
|
|
||||||
due to version mismatches. In some cases, removing the version
|
|
||||||
bounds entirely is an easy way to make a package build, but at
|
|
||||||
the risk of breaking software in non-obvious ways now or in the
|
|
||||||
future.
|
|
||||||
|
|
||||||
Instead of jailbreaking, you can patch the cabal file.
|
|
||||||
|
|
||||||
Note that jailbreaking at this time, doesn't lift bounds on
|
|
||||||
conditional branches.
|
|
||||||
https://github.com/peti/jailbreak-cabal/issues/7 has further details.
|
|
||||||
|
|
||||||
*/
|
|
||||||
doJailbreak = compose.doJailbreak;
|
|
||||||
|
|
||||||
/* dontJailbreak restores the use of the version bounds the check
|
|
||||||
the use of dependencies in the package description.
|
|
||||||
*/
|
|
||||||
dontJailbreak = compose.dontJailbreak;
|
|
||||||
|
|
||||||
/* doCheck enables dependency checking, compilation and execution
|
|
||||||
of test suites listed in the package description file.
|
|
||||||
*/
|
|
||||||
doCheck = compose.doCheck;
|
|
||||||
/* dontCheck disables dependency checking, compilation and execution
|
|
||||||
of test suites listed in the package description file.
|
|
||||||
*/
|
|
||||||
dontCheck = compose.dontCheck;
|
|
||||||
/* The dontCheckIf variant sets doCheck = false if the condition
|
|
||||||
applies. In any other case the previously set/default value is used.
|
|
||||||
This prevents accidentally re-enabling tests in a later override.
|
|
||||||
*/
|
|
||||||
dontCheckIf = drv: condition: compose.dontCheckIf condition drv;
|
|
||||||
|
|
||||||
/* doBenchmark enables dependency checking, compilation and execution
|
|
||||||
for benchmarks listed in the package description file.
|
|
||||||
*/
|
|
||||||
doBenchmark = compose.doBenchmark;
|
|
||||||
/* dontBenchmark disables dependency checking, compilation and execution
|
|
||||||
for benchmarks listed in the package description file.
|
|
||||||
*/
|
|
||||||
dontBenchmark = compose.dontBenchmark;
|
|
||||||
|
|
||||||
/* doDistribute enables the distribution of binaries for the package
|
|
||||||
via hydra.
|
|
||||||
*/
|
|
||||||
doDistribute = compose.doDistribute;
|
|
||||||
/* dontDistribute disables the distribution of binaries for the package
|
|
||||||
via hydra.
|
|
||||||
*/
|
|
||||||
dontDistribute = compose.dontDistribute;
|
|
||||||
|
|
||||||
/* appendConfigureFlag adds a single argument that will be passed to the
|
|
||||||
cabal configure command, after the arguments that have been defined
|
|
||||||
in the initial declaration or previous overrides.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
> haskell.lib.appendConfigureFlag haskellPackages.servant "--profiling-detail=all-functions"
|
|
||||||
*/
|
|
||||||
appendConfigureFlag = drv: x: compose.appendConfigureFlag x drv;
|
|
||||||
appendConfigureFlags = drv: xs: compose.appendConfigureFlags xs drv;
|
|
||||||
|
|
||||||
appendBuildFlag = drv: x: compose.appendBuildFlag x drv;
|
|
||||||
appendBuildFlags = drv: xs: compose.appendBuildFlags xs drv;
|
|
||||||
|
|
||||||
/* removeConfigureFlag drv x is a Haskell package like drv, but with
|
|
||||||
all cabal configure arguments that are equal to x removed.
|
|
||||||
|
|
||||||
> haskell.lib.removeConfigureFlag haskellPackages.servant "--verbose"
|
|
||||||
*/
|
|
||||||
removeConfigureFlag = drv: x: compose.removeConfigureFlag x drv;
|
|
||||||
|
|
||||||
addBuildTool = drv: x: compose.addBuildTool x drv;
|
|
||||||
addBuildTools = drv: xs: compose.addBuildTools xs drv;
|
|
||||||
|
|
||||||
addExtraLibrary = drv: x: compose.addExtraLibrary x drv;
|
|
||||||
addExtraLibraries = drv: xs: compose.addExtraLibraries xs drv;
|
|
||||||
|
|
||||||
addBuildDepend = drv: x: compose.addBuildDepend x drv;
|
|
||||||
addBuildDepends = drv: xs: compose.addBuildDepends xs drv;
|
|
||||||
|
|
||||||
addTestToolDepend = drv: x: compose.addTestToolDepend x drv;
|
|
||||||
addTestToolDepends = drv: xs: compose.addTestToolDepends xs drv;
|
|
||||||
|
|
||||||
addPkgconfigDepend = drv: x: compose.addPkgconfigDepend x drv;
|
|
||||||
addPkgconfigDepends = drv: xs: compose.addPkgconfigDepends xs drv;
|
|
||||||
|
|
||||||
addSetupDepend = drv: x: compose.addSetupDepend x drv;
|
|
||||||
addSetupDepends = drv: xs: compose.addSetupDepends xs drv;
|
|
||||||
|
|
||||||
enableCabalFlag = drv: x: compose.enableCabalFlag x drv;
|
|
||||||
disableCabalFlag = drv: x: compose.disableCabalFlag x drv;
|
|
||||||
|
|
||||||
markBroken = compose.markBroken;
|
|
||||||
unmarkBroken = compose.unmarkBroken;
|
|
||||||
markBrokenVersion = compose.markBrokenVersion;
|
|
||||||
markUnbroken = compose.markUnbroken;
|
|
||||||
|
|
||||||
enableLibraryProfiling = compose.enableLibraryProfiling;
|
|
||||||
disableLibraryProfiling = compose.disableLibraryProfiling;
|
|
||||||
|
|
||||||
enableExecutableProfiling = compose.enableExecutableProfiling;
|
|
||||||
disableExecutableProfiling = compose.disableExecutableProfiling;
|
|
||||||
|
|
||||||
enableSharedExecutables = compose.enableSharedExecutables;
|
|
||||||
disableSharedExecutables = compose.disableSharedExecutables;
|
|
||||||
|
|
||||||
enableSharedLibraries = compose.enableSharedLibraries;
|
|
||||||
disableSharedLibraries = compose.disableSharedLibraries;
|
|
||||||
|
|
||||||
enableDeadCodeElimination = compose.enableDeadCodeElimination;
|
|
||||||
disableDeadCodeElimination = compose.disableDeadCodeElimination;
|
|
||||||
|
|
||||||
enableStaticLibraries = compose.enableStaticLibraries;
|
|
||||||
disableStaticLibraries = compose.disableStaticLibraries;
|
|
||||||
|
|
||||||
enableSeparateBinOutput = compose.enableSeparateBinOutput;
|
|
||||||
|
|
||||||
appendPatch = drv: x: compose.appendPatch x drv;
|
|
||||||
appendPatches = drv: xs: compose.appendPatches xs drv;
|
|
||||||
|
|
||||||
/* Set a specific build target instead of compiling all targets in the package.
|
|
||||||
* For example, imagine we have a .cabal file with a library, and 2 executables "dev" and "server".
|
|
||||||
* We can build only "server" and not wait on the compilation of "dev" by using setBuildTarget as follows:
|
|
||||||
*
|
|
||||||
* setBuildTarget (callCabal2nix "thePackageName" thePackageSrc {}) "server"
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
setBuildTargets = drv: xs: compose.setBuildTargets xs drv;
|
|
||||||
setBuildTarget = drv: x: compose.setBuildTarget x drv;
|
|
||||||
|
|
||||||
doHyperlinkSource = compose.doHyperlinkSource;
|
|
||||||
dontHyperlinkSource = compose.dontHyperlinkSource;
|
|
||||||
|
|
||||||
disableHardening = drv: flags: compose.disableHardening flags drv;
|
|
||||||
|
|
||||||
/* Let Nix strip the binary files.
|
|
||||||
* This removes debugging symbols.
|
|
||||||
*/
|
|
||||||
doStrip = compose.doStrip;
|
|
||||||
|
|
||||||
/* Stop Nix from stripping the binary files.
|
|
||||||
* This keeps debugging symbols.
|
|
||||||
*/
|
|
||||||
dontStrip = compose.dontStrip;
|
|
||||||
|
|
||||||
/* Useful for debugging segfaults with gdb.
|
|
||||||
* This includes dontStrip.
|
|
||||||
*/
|
|
||||||
enableDWARFDebugging = compose.enableDWARFDebugging;
|
|
||||||
|
|
||||||
/* Create a source distribution tarball like those found on hackage,
|
|
||||||
instead of building the package.
|
|
||||||
*/
|
|
||||||
sdistTarball = compose.sdistTarball;
|
|
||||||
|
|
||||||
/* Create a documentation tarball suitable for uploading to Hackage instead
|
|
||||||
of building the package.
|
|
||||||
*/
|
|
||||||
documentationTarball = compose.documentationTarball;
|
|
||||||
|
|
||||||
/* Use the gold linker. It is a linker for ELF that is designed
|
|
||||||
"to run as fast as possible on modern systems"
|
|
||||||
*/
|
|
||||||
linkWithGold = compose.linkWithGold;
|
|
||||||
|
|
||||||
/* link executables statically against haskell libs to reduce
|
|
||||||
closure size
|
|
||||||
*/
|
|
||||||
justStaticExecutables = compose.justStaticExecutables;
|
|
||||||
|
|
||||||
/* Build a source distribution tarball instead of using the source files
|
|
||||||
directly. The effect is that the package is built as if it were published
|
|
||||||
on hackage. This can be used as a test for the source distribution,
|
|
||||||
assuming the build fails when packaging mistakes are in the cabal file.
|
|
||||||
*/
|
|
||||||
buildFromSdist = compose.buildFromSdist;
|
|
||||||
|
|
||||||
/* Build the package in a strict way to uncover potential problems.
|
|
||||||
This includes buildFromSdist and failOnAllWarnings.
|
|
||||||
*/
|
|
||||||
buildStrictly = compose.buildStrictly;
|
|
||||||
|
|
||||||
/* Disable core optimizations, significantly speeds up build time */
|
|
||||||
disableOptimization = compose.disableOptimization;
|
|
||||||
|
|
||||||
/* Turn on most of the compiler warnings and fail the build if any
|
|
||||||
of them occur. */
|
|
||||||
failOnAllWarnings = compose.failOnAllWarnings;
|
|
||||||
|
|
||||||
/* Add a post-build check to verify that dependencies declared in
|
|
||||||
the cabal file are actually used.
|
|
||||||
|
|
||||||
The first attrset argument can be used to configure the strictness
|
|
||||||
of this check and a list of ignored package names that would otherwise
|
|
||||||
cause false alarms.
|
|
||||||
*/
|
|
||||||
checkUnusedPackages = compose.checkUnusedPackages;
|
|
||||||
|
|
||||||
buildStackProject = compose.buildStackProject;
|
|
||||||
|
|
||||||
/* Add a dummy command to trigger a build despite an equivalent
|
|
||||||
earlier build that is present in the store or cache.
|
|
||||||
*/
|
|
||||||
triggerRebuild = drv: i: compose.triggerRebuild i drv;
|
|
||||||
|
|
||||||
/* Override the sources for the package and optionally the version.
|
|
||||||
This also takes of removing editedCabalFile.
|
|
||||||
*/
|
|
||||||
overrideSrc = drv: src: compose.overrideSrc src drv;
|
|
||||||
|
|
||||||
# Get all of the build inputs of a haskell package, divided by category.
|
|
||||||
getBuildInputs = compose.getBuildInputs;
|
|
||||||
|
|
||||||
# Extract the haskell build inputs of a haskell package.
|
|
||||||
# This is useful to build environments for developing on that
|
|
||||||
# package.
|
|
||||||
getHaskellBuildInputs = compose.getHaskellBuildInputs;
|
|
||||||
|
|
||||||
# Under normal evaluation, simply return the original package. Under
|
|
||||||
# nix-shell evaluation, return a nix-shell optimized environment.
|
|
||||||
shellAware = compose.shellAware;
|
|
||||||
|
|
||||||
ghcInfo = compose.ghcInfo;
|
|
||||||
|
|
||||||
### mkDerivation helpers
|
|
||||||
# These allow external users of a haskell package to extract
|
|
||||||
# information about how it is built in the same way that the
|
|
||||||
# generic haskell builder does, by reusing the same functions.
|
|
||||||
# Each function here has the same interface as mkDerivation and thus
|
|
||||||
# can be called for a given package simply by overriding the
|
|
||||||
# mkDerivation argument it used. See getHaskellBuildInputs above for
|
|
||||||
# an example of this.
|
|
||||||
|
|
||||||
# Some information about which phases should be run.
|
|
||||||
controlPhases = compose.controlPhases;
|
|
||||||
|
|
||||||
# Utility to convert a directory full of `cabal2nix`-generated files into a
|
|
||||||
# package override set
|
|
||||||
#
|
|
||||||
# packagesFromDirectory : { directory : Directory, ... } -> HaskellPackageOverrideSet
|
|
||||||
packagesFromDirectory = compose.packagesFromDirectory;
|
|
||||||
|
|
||||||
addOptparseApplicativeCompletionScripts = exeName: pkg:
|
|
||||||
lib.warn "addOptparseApplicativeCompletionScripts is deprecated in favor of haskellPackages.generateOptparseApplicativeCompletions. Please change ${pkg.name} to use the latter and make sure it uses its matching haskell.packages set!"
|
|
||||||
(compose.__generateOptparseApplicativeCompletion exeName pkg);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Modify a Haskell package to add shell completion scripts for the
|
|
||||||
given executable produced by it. These completion scripts will be
|
|
||||||
picked up automatically if the resulting derivation is installed,
|
|
||||||
e.g. by `nix-env -i`.
|
|
||||||
|
|
||||||
Invocation:
|
|
||||||
generateOptparseApplicativeCompletions command pkg
|
|
||||||
|
|
||||||
|
|
||||||
command: name of an executable
|
|
||||||
pkg: Haskell package that builds the executables
|
|
||||||
*/
|
|
||||||
generateOptparseApplicativeCompletion = compose.generateOptparseApplicativeCompletion;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Modify a Haskell package to add shell completion scripts for the
|
|
||||||
given executables produced by it. These completion scripts will be
|
|
||||||
picked up automatically if the resulting derivation is installed,
|
|
||||||
e.g. by `nix-env -i`.
|
|
||||||
|
|
||||||
Invocation:
|
|
||||||
generateOptparseApplicativeCompletions commands pkg
|
|
||||||
|
|
||||||
|
|
||||||
commands: name of an executable
|
|
||||||
pkg: Haskell package that builds the executables
|
|
||||||
*/
|
|
||||||
generateOptparseApplicativeCompletions = compose.generateOptparseApplicativeCompletions;
|
|
||||||
|
|
||||||
# Don't fail at configure time if there are multiple versions of the
|
|
||||||
# same package in the (recursive) dependencies of the package being
|
|
||||||
# built. Will delay failures, if any, to compile time.
|
|
||||||
allowInconsistentDependencies = compose.allowInconsistentDependencies;
|
|
||||||
}
|
|
|
@ -1,646 +0,0 @@
|
||||||
# This expression takes a file like `hackage-packages.nix` and constructs
|
|
||||||
# a full package set out of that.
|
|
||||||
|
|
||||||
{ # package-set used for build tools (all of nixpkgs)
|
|
||||||
buildPackages
|
|
||||||
|
|
||||||
, # A haskell package set for Setup.hs, compiler plugins, and similar
|
|
||||||
# build-time uses.
|
|
||||||
buildHaskellPackages
|
|
||||||
|
|
||||||
, # package-set used for non-haskell dependencies (all of nixpkgs)
|
|
||||||
pkgs
|
|
||||||
|
|
||||||
, # stdenv provides our build and host platforms
|
|
||||||
stdenv
|
|
||||||
|
|
||||||
, # this module provides the list of known licenses and maintainers
|
|
||||||
lib
|
|
||||||
|
|
||||||
# needed for overrideCabal & packageSourceOverrides
|
|
||||||
, haskellLib
|
|
||||||
|
|
||||||
, # hashes for downloading Hackage packages
|
|
||||||
# This is either a directory or a .tar.gz containing the cabal files and
|
|
||||||
# hashes of Hackage as exemplified by this repository:
|
|
||||||
# https://github.com/commercialhaskell/all-cabal-hashes/tree/hackage
|
|
||||||
all-cabal-hashes
|
|
||||||
|
|
||||||
, # compiler to use
|
|
||||||
ghc
|
|
||||||
|
|
||||||
, # A function that takes `{ pkgs, lib, callPackage }` as the first arg and
|
|
||||||
# `self` as second, and returns a set of haskell packages
|
|
||||||
package-set
|
|
||||||
|
|
||||||
, # The final, fully overridden package set usable with the nixpkgs fixpoint
|
|
||||||
# overriding functionality
|
|
||||||
extensible-self
|
|
||||||
}:
|
|
||||||
|
|
||||||
# return value: a function from self to the package set
|
|
||||||
self:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (stdenv) buildPlatform hostPlatform;
|
|
||||||
|
|
||||||
inherit (lib) fix' extends makeOverridable;
|
|
||||||
inherit (haskellLib) overrideCabal;
|
|
||||||
|
|
||||||
mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
|
|
||||||
inherit stdenv;
|
|
||||||
nodejs = buildPackages.nodejs-slim;
|
|
||||||
inherit (self) buildHaskellPackages ghc ghcWithHoogle ghcWithPackages;
|
|
||||||
inherit (self.buildHaskellPackages) jailbreak-cabal;
|
|
||||||
hscolour = overrideCabal (drv: {
|
|
||||||
isLibrary = false;
|
|
||||||
doHaddock = false;
|
|
||||||
hyperlinkSource = false; # Avoid depending on hscolour for this build.
|
|
||||||
postFixup = "rm -rf $out/lib $out/share $out/nix-support";
|
|
||||||
}) self.buildHaskellPackages.hscolour;
|
|
||||||
cpphs = overrideCabal (drv: {
|
|
||||||
isLibrary = false;
|
|
||||||
postFixup = "rm -rf $out/lib $out/share $out/nix-support";
|
|
||||||
}) (self.cpphs.overrideScope (self: super: {
|
|
||||||
mkDerivation = drv: super.mkDerivation (drv // {
|
|
||||||
enableSharedExecutables = false;
|
|
||||||
enableSharedLibraries = false;
|
|
||||||
doHaddock = false;
|
|
||||||
useCpphs = false;
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
mkDerivation = makeOverridable mkDerivationImpl;
|
|
||||||
|
|
||||||
# manualArgs are the arguments that were explicitly passed to `callPackage`, like:
|
|
||||||
#
|
|
||||||
# callPackage foo { bar = null; };
|
|
||||||
#
|
|
||||||
# here `bar` is a manual argument.
|
|
||||||
callPackageWithScope = scope: fn: manualArgs:
|
|
||||||
let
|
|
||||||
# this code is copied from callPackage in lib/customisation.nix
|
|
||||||
#
|
|
||||||
# we cannot use `callPackage` here because we want to call `makeOverridable`
|
|
||||||
# on `drvScope` (we cannot add `overrideScope` after calling `callPackage` because then it is
|
|
||||||
# lost on `.override`) but determine the auto-args based on `drv` (the problem here
|
|
||||||
# is that nix has no way to "passthrough" args while preserving the reflection
|
|
||||||
# info that callPackage uses to determine the arguments).
|
|
||||||
drv = if lib.isFunction fn then fn else import fn;
|
|
||||||
auto = builtins.intersectAttrs (lib.functionArgs drv) scope;
|
|
||||||
|
|
||||||
# Converts a returned function to a functor attribute set if necessary
|
|
||||||
ensureAttrs = v: if builtins.isFunction v then { __functor = _: v; } else v;
|
|
||||||
|
|
||||||
# this wraps the `drv` function to add `scope` and `overrideScope` to the result.
|
|
||||||
drvScope = allArgs: ensureAttrs (drv allArgs) // {
|
|
||||||
inherit scope;
|
|
||||||
overrideScope = f:
|
|
||||||
let newScope = mkScope (fix' (extends f scope.__unfix__));
|
|
||||||
# note that we have to be careful here: `allArgs` includes the auto-arguments that
|
|
||||||
# weren't manually specified. If we would just pass `allArgs` to the recursive call here,
|
|
||||||
# then we wouldn't look up any packages in the scope in the next interation, because it
|
|
||||||
# appears as if all arguments were already manually passed, so the scope change would do
|
|
||||||
# nothing.
|
|
||||||
in callPackageWithScope newScope drv manualArgs;
|
|
||||||
};
|
|
||||||
in lib.makeOverridable drvScope (auto // manualArgs);
|
|
||||||
|
|
||||||
mkScope = scope: let
|
|
||||||
ps = pkgs.__splicedPackages;
|
|
||||||
scopeSpliced = pkgs.splicePackages {
|
|
||||||
pkgsBuildBuild = scope.buildHaskellPackages.buildHaskellPackages;
|
|
||||||
pkgsBuildHost = scope.buildHaskellPackages;
|
|
||||||
pkgsBuildTarget = {};
|
|
||||||
pkgsHostHost = {};
|
|
||||||
pkgsHostTarget = scope;
|
|
||||||
pkgsTargetTarget = {};
|
|
||||||
} // {
|
|
||||||
# Don't splice these
|
|
||||||
inherit (scope) ghc buildHaskellPackages;
|
|
||||||
};
|
|
||||||
in ps // ps.xorg // { inherit stdenv; } // scopeSpliced;
|
|
||||||
defaultScope = mkScope self;
|
|
||||||
callPackage = drv: args: callPackageWithScope defaultScope drv args;
|
|
||||||
|
|
||||||
# Use cabal2nix to create a default.nix for the package sources found at 'src'.
|
|
||||||
haskellSrc2nix = { name, src, sha256 ? null, extraCabal2nixOptions ? "" }:
|
|
||||||
let
|
|
||||||
sha256Arg = if sha256 == null then "--sha256=" else ''--sha256="${sha256}"'';
|
|
||||||
in buildPackages.runCommand "cabal2nix-${name}" {
|
|
||||||
nativeBuildInputs = [ buildPackages.cabal2nix-unwrapped ];
|
|
||||||
preferLocalBuild = true;
|
|
||||||
allowSubstitutes = false;
|
|
||||||
LANG = "en_US.UTF-8";
|
|
||||||
LOCALE_ARCHIVE = pkgs.lib.optionalString (buildPlatform.libc == "glibc") "${buildPackages.glibcLocales}/lib/locale/locale-archive";
|
|
||||||
} ''
|
|
||||||
export HOME="$TMP"
|
|
||||||
mkdir -p "$out"
|
|
||||||
cabal2nix --compiler=${self.ghc.haskellCompilerName} --system=${hostPlatform.config} ${sha256Arg} "${src}" ${extraCabal2nixOptions} > "$out/default.nix"
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Given a package name and version, e.g. name = "async", version = "2.2.4",
|
|
||||||
# gives its cabal file and hashes (JSON file) as discovered from the
|
|
||||||
# all-cabal-hashes value. If that's a directory, it will copy the relevant
|
|
||||||
# files to $out; if it's a tarball, it will extract and move them to $out.
|
|
||||||
all-cabal-hashes-component = name: version: buildPackages.runCommand "all-cabal-hashes-component-${name}-${version}" {} ''
|
|
||||||
mkdir -p $out
|
|
||||||
if [ -d ${all-cabal-hashes} ]
|
|
||||||
then
|
|
||||||
cp ${all-cabal-hashes}/${name}/${version}/${name}.json $out
|
|
||||||
cp ${all-cabal-hashes}/${name}/${version}/${name}.cabal $out
|
|
||||||
else
|
|
||||||
tar --wildcards -xzvf ${all-cabal-hashes} \*/${name}/${version}/${name}.{json,cabal}
|
|
||||||
mv */${name}/${version}/${name}.{json,cabal} $out
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
|
|
||||||
hackage2nix = name: version: let component = all-cabal-hashes-component name version; in self.haskellSrc2nix {
|
|
||||||
name = "${name}-${version}";
|
|
||||||
sha256 = ''$(sed -e 's/.*"SHA256":"//' -e 's/".*$//' "${component}/${name}.json")'';
|
|
||||||
src = "${component}/${name}.cabal";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Adds a nix file derived from cabal2nix in the passthru of the derivation it
|
|
||||||
# produces. This is useful to debug callHackage / callCabal2nix by looking at
|
|
||||||
# the content of the nix file pointed by `cabal2nixDeriver`.
|
|
||||||
# However, it does not keep a reference to that file, which may be garbage
|
|
||||||
# collected, which may be an annoyance.
|
|
||||||
callPackageKeepDeriver = src: args:
|
|
||||||
overrideCabal (orig: {
|
|
||||||
passthru = orig.passthru or {} // {
|
|
||||||
# When using callCabal2nix or callHackage, it is often useful
|
|
||||||
# to debug a failure by inspecting the Nix expression
|
|
||||||
# generated by cabal2nix. This can be accessed via this
|
|
||||||
# cabal2nixDeriver field.
|
|
||||||
cabal2nixDeriver = src;
|
|
||||||
};
|
|
||||||
}) (self.callPackage src args);
|
|
||||||
|
|
||||||
in package-set { inherit pkgs lib callPackage; } self // {
|
|
||||||
|
|
||||||
inherit mkDerivation callPackage haskellSrc2nix hackage2nix buildHaskellPackages;
|
|
||||||
|
|
||||||
inherit (haskellLib) packageSourceOverrides;
|
|
||||||
|
|
||||||
# callHackage :: Text -> Text -> AttrSet -> HaskellPackage
|
|
||||||
#
|
|
||||||
# e.g., while overriding a package set:
|
|
||||||
# '... foo = self.callHackage "foo" "1.5.3" {}; ...'
|
|
||||||
callHackage = name: version: callPackageKeepDeriver (self.hackage2nix name version);
|
|
||||||
|
|
||||||
# callHackageDirect
|
|
||||||
# :: { pkg :: Text, ver :: Text, sha256 :: Text }
|
|
||||||
# -> AttrSet
|
|
||||||
# -> HaskellPackage
|
|
||||||
#
|
|
||||||
# This function does not depend on all-cabal-hashes and therefore will work
|
|
||||||
# for any version that has been released on hackage as opposed to only
|
|
||||||
# versions released before whatever version of all-cabal-hashes you happen
|
|
||||||
# to be currently using.
|
|
||||||
callHackageDirect = {pkg, ver, sha256, rev ? { revision = null; sha256 = null; }}: args:
|
|
||||||
let pkgver = "${pkg}-${ver}";
|
|
||||||
firstRevision = self.callCabal2nix pkg (pkgs.fetchzip {
|
|
||||||
url = "mirror://hackage/${pkgver}/${pkgver}.tar.gz";
|
|
||||||
inherit sha256;
|
|
||||||
}) args;
|
|
||||||
in overrideCabal (orig: {
|
|
||||||
revision = rev.revision;
|
|
||||||
editedCabalFile = rev.sha256;
|
|
||||||
}) firstRevision;
|
|
||||||
|
|
||||||
# Creates a Haskell package from a source package by calling cabal2nix on the source.
|
|
||||||
callCabal2nixWithOptions = name: src: extraCabal2nixOptions: args:
|
|
||||||
let
|
|
||||||
filter = path: type:
|
|
||||||
pkgs.lib.hasSuffix ".cabal" path ||
|
|
||||||
baseNameOf path == "package.yaml";
|
|
||||||
expr = self.haskellSrc2nix {
|
|
||||||
inherit name extraCabal2nixOptions;
|
|
||||||
src = if pkgs.lib.canCleanSource src
|
|
||||||
then pkgs.lib.cleanSourceWith { inherit src filter; }
|
|
||||||
else src;
|
|
||||||
};
|
|
||||||
in overrideCabal (orig: {
|
|
||||||
inherit src;
|
|
||||||
}) (callPackageKeepDeriver expr args);
|
|
||||||
|
|
||||||
callCabal2nix = name: src: args: self.callCabal2nixWithOptions name src "" args;
|
|
||||||
|
|
||||||
# : { root : Path
|
|
||||||
# , name : Defaulted String
|
|
||||||
# , source-overrides : Defaulted (Either Path VersionNumber)
|
|
||||||
# , overrides : Defaulted (HaskellPackageOverrideSet)
|
|
||||||
# , modifier : Defaulted
|
|
||||||
# , returnShellEnv : Defaulted
|
|
||||||
# , withHoogle : Defaulted
|
|
||||||
# , cabal2nixOptions : Defaulted
|
|
||||||
# } -> NixShellAwareDerivation
|
|
||||||
#
|
|
||||||
# Given a path to a haskell package directory, an optional package name
|
|
||||||
# which defaults to the base name of the path, an optional set of source
|
|
||||||
# overrides as appropriate for the 'packageSourceOverrides' function, an
|
|
||||||
# optional set of arbitrary overrides, and an optional haskell package
|
|
||||||
# modifier, return a derivation appropriate for nix-build or nix-shell to
|
|
||||||
# build that package.
|
|
||||||
#
|
|
||||||
# If 'returnShellEnv' is true this returns a derivation which will give you
|
|
||||||
# an environment suitable for developing the listed packages with an
|
|
||||||
# incremental tool like cabal-install.
|
|
||||||
#
|
|
||||||
# If 'withHoogle' is true (the default if a shell environment is requested)
|
|
||||||
# then 'ghcWithHoogle' is used to generate the derivation (instead of
|
|
||||||
# 'ghcWithPackages'), see the documentation there for more information.
|
|
||||||
#
|
|
||||||
# 'cabal2nixOptions' can contain extra command line arguments to pass to
|
|
||||||
# 'cabal2nix' when generating the package derivation, for example setting
|
|
||||||
# a cabal flag with '--flag=myflag'.
|
|
||||||
developPackage =
|
|
||||||
{ root
|
|
||||||
, name ? lib.optionalString (builtins.typeOf root == "path") (builtins.baseNameOf root)
|
|
||||||
, source-overrides ? {}
|
|
||||||
, overrides ? self: super: {}
|
|
||||||
, modifier ? drv: drv
|
|
||||||
, returnShellEnv ? pkgs.lib.inNixShell
|
|
||||||
, withHoogle ? returnShellEnv
|
|
||||||
, cabal2nixOptions ? "" }:
|
|
||||||
let drv =
|
|
||||||
(extensible-self.extend
|
|
||||||
(pkgs.lib.composeExtensions
|
|
||||||
(self.packageSourceOverrides source-overrides)
|
|
||||||
overrides))
|
|
||||||
.callCabal2nixWithOptions name root cabal2nixOptions {};
|
|
||||||
in if returnShellEnv
|
|
||||||
then (modifier drv).envFunc {inherit withHoogle;}
|
|
||||||
else modifier drv;
|
|
||||||
|
|
||||||
# This can be used to easily create a derivation containing GHC and the specified set of Haskell packages.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
# $ nix-shell -p 'haskellPackages.ghcWithPackages (hpkgs: [ hpkgs.mtl hpkgs.lens ])'
|
|
||||||
# $ ghci # in the nix-shell
|
|
||||||
# Prelude > import Control.Lens
|
|
||||||
#
|
|
||||||
# GHC is setup with a package database with all the specified Haskell packages.
|
|
||||||
#
|
|
||||||
# ghcWithPackages :: (HaskellPkgSet -> [ HaskellPkg ]) -> Derivation
|
|
||||||
ghcWithPackages = buildHaskellPackages.callPackage ./with-packages-wrapper.nix {
|
|
||||||
haskellPackages = self;
|
|
||||||
inherit (self) hoogleWithPackages;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
# Put 'hoogle' into the derivation's PATH with a database containing all
|
|
||||||
# the package's dependencies; run 'hoogle server --local' in a shell to
|
|
||||||
# host a search engine for the dependencies.
|
|
||||||
#
|
|
||||||
# Example usage:
|
|
||||||
# $ nix-shell -p 'haskellPackages.hoogleWithPackages (p: [ p.mtl p.lens ])'
|
|
||||||
# [nix-shell] $ hoogle server
|
|
||||||
#
|
|
||||||
# hoogleWithPackages :: (HaskellPkgSet -> [ HaskellPkg ]) -> Derivation
|
|
||||||
#
|
|
||||||
# To reload the Hoogle server automatically on .cabal file changes try
|
|
||||||
# this:
|
|
||||||
# echo *.cabal | entr -r -- nix-shell --run 'hoogle server --local'
|
|
||||||
hoogleWithPackages = self.callPackage ./hoogle.nix {
|
|
||||||
haskellPackages = self;
|
|
||||||
};
|
|
||||||
hoogleLocal =
|
|
||||||
{ packages ? [] }:
|
|
||||||
lib.warn "hoogleLocal is deprecated, use hoogleWithPackages instead" (
|
|
||||||
self.hoogleWithPackages (_: packages)
|
|
||||||
);
|
|
||||||
# This is like a combination of ghcWithPackages and hoogleWithPackages.
|
|
||||||
# It provides a derivation containing both GHC and Hoogle with an index of
|
|
||||||
# the given Haskell package database.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
# $ nix-shell -p 'haskellPackages.ghcWithHoogle (hpkgs: [ hpkgs.conduit hpkgs.lens ])'
|
|
||||||
#
|
|
||||||
# ghcWithHoogle :: (HaskellPkgSet -> [ HaskellPkg ]) -> Derivation
|
|
||||||
ghcWithHoogle = self.ghcWithPackages.override {
|
|
||||||
withHoogle = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Returns a derivation whose environment contains a GHC with only
|
|
||||||
# the dependencies of packages listed in `packages`, not the
|
|
||||||
# packages themselves. Using nix-shell on this derivation will
|
|
||||||
# give you an environment suitable for developing the listed
|
|
||||||
# packages with an incremental tool like cabal-install.
|
|
||||||
#
|
|
||||||
# In addition to the "packages" arg and "withHoogle" arg, anything that
|
|
||||||
# can be passed into stdenv.mkDerivation can be included in the input attrset
|
|
||||||
#
|
|
||||||
# # default.nix
|
|
||||||
# with import <nixpkgs> {};
|
|
||||||
# haskellPackages.extend (haskell.lib.compose.packageSourceOverrides {
|
|
||||||
# frontend = ./frontend;
|
|
||||||
# backend = ./backend;
|
|
||||||
# common = ./common;
|
|
||||||
# })
|
|
||||||
#
|
|
||||||
# # shell.nix
|
|
||||||
# let pkgs = import <nixpkgs> {} in
|
|
||||||
# (import ./.).shellFor {
|
|
||||||
# packages = p: [p.frontend p.backend p.common];
|
|
||||||
# withHoogle = true;
|
|
||||||
# buildInputs = [ pkgs.python pkgs.cabal-install ];
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# -- cabal.project
|
|
||||||
# packages:
|
|
||||||
# frontend/
|
|
||||||
# backend/
|
|
||||||
# common/
|
|
||||||
#
|
|
||||||
# bash$ nix-shell --run "cabal new-build all"
|
|
||||||
# bash$ nix-shell --run "python"
|
|
||||||
shellFor =
|
|
||||||
{ # Packages to create this development shell for. These are usually
|
|
||||||
# your local packages.
|
|
||||||
packages
|
|
||||||
, # Whether or not to generate a Hoogle database for all the
|
|
||||||
# dependencies.
|
|
||||||
withHoogle ? false
|
|
||||||
, # Whether or not to include benchmark dependencies of your local
|
|
||||||
# packages. You should set this to true if you have benchmarks defined
|
|
||||||
# in your local packages that you want to be able to run with cabal benchmark
|
|
||||||
doBenchmark ? false
|
|
||||||
# An optional function that can modify the generic builder arguments
|
|
||||||
# for the fake package that shellFor uses to construct its environment.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
# let
|
|
||||||
# # elided...
|
|
||||||
# haskellPkgs = pkgs.haskell.packages.ghc884.override (hpArgs: {
|
|
||||||
# overrides = pkgs.lib.composeExtensions (hpArgs.overrides or (_: _: { })) (
|
|
||||||
# _hfinal: hprev: {
|
|
||||||
# mkDerivation = args: hprev.mkDerivation ({
|
|
||||||
# doCheck = false;
|
|
||||||
# doBenchmark = false;
|
|
||||||
# doHoogle = true;
|
|
||||||
# doHaddock = true;
|
|
||||||
# enableLibraryProfiling = false;
|
|
||||||
# enableExecutableProfiling = false;
|
|
||||||
# } // args);
|
|
||||||
# }
|
|
||||||
# );
|
|
||||||
# });
|
|
||||||
# in
|
|
||||||
# haskellPkgs.shellFor {
|
|
||||||
# packages = p: [ p.foo ];
|
|
||||||
# genericBuilderArgsModifier = args: args // { doCheck = true; doBenchmark = true };
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# This will disable tests and benchmarks for everything in "haskellPkgs"
|
|
||||||
# (which will invalidate the binary cache), and then re-enable them
|
|
||||||
# for the "shellFor" environment (ensuring that any test/benchmark
|
|
||||||
# dependencies for "foo" will be available within the nix-shell).
|
|
||||||
, genericBuilderArgsModifier ? (args: args)
|
|
||||||
|
|
||||||
# Extra dependencies, in the form of cabal2nix build attributes.
|
|
||||||
#
|
|
||||||
# An example use case is when you have Haskell scripts that use
|
|
||||||
# libraries that don't occur in your packages' dependencies.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
#
|
|
||||||
# extraDependencies = p: {
|
|
||||||
# libraryHaskellDepends = [ p.releaser ];
|
|
||||||
# };
|
|
||||||
, extraDependencies ? p: {}
|
|
||||||
, ...
|
|
||||||
} @ args:
|
|
||||||
let
|
|
||||||
# A list of the packages we want to build a development shell for.
|
|
||||||
# This is a list of Haskell package derivations.
|
|
||||||
selected = packages self;
|
|
||||||
|
|
||||||
# This is a list of attribute sets, where each attribute set
|
|
||||||
# corresponds to the build inputs of one of the packages input to shellFor.
|
|
||||||
#
|
|
||||||
# Each attribute has keys like buildDepends, executableHaskellDepends,
|
|
||||||
# testPkgconfigDepends, etc. The values for the keys of the attribute
|
|
||||||
# set are lists of dependencies.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
# cabalDepsForSelected
|
|
||||||
# => [
|
|
||||||
# # This may be the attribute set corresponding to the `backend`
|
|
||||||
# # package in the example above.
|
|
||||||
# { buildDepends = [ gcc ... ];
|
|
||||||
# libraryHaskellDepends = [ lens conduit ... ];
|
|
||||||
# ...
|
|
||||||
# }
|
|
||||||
# # This may be the attribute set corresponding to the `common`
|
|
||||||
# # package in the example above.
|
|
||||||
# { testHaskellDepends = [ tasty hspec ... ];
|
|
||||||
# libraryHaskellDepends = [ lens aeson ];
|
|
||||||
# benchmarkHaskellDepends = [ criterion ... ];
|
|
||||||
# ...
|
|
||||||
# }
|
|
||||||
# ...
|
|
||||||
# ]
|
|
||||||
cabalDepsForSelected = map (p: p.getCabalDeps) selected;
|
|
||||||
|
|
||||||
# A predicate that takes a derivation as input, and tests whether it is
|
|
||||||
# the same as any of the `selected` packages.
|
|
||||||
#
|
|
||||||
# Returns true if the input derivation is not in the list of `selected`
|
|
||||||
# packages.
|
|
||||||
#
|
|
||||||
# isNotSelected :: Derivation -> Bool
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
#
|
|
||||||
# isNotSelected common [ frontend backend common ]
|
|
||||||
# => false
|
|
||||||
#
|
|
||||||
# isNotSelected lens [ frontend backend common ]
|
|
||||||
# => true
|
|
||||||
isNotSelected = input: pkgs.lib.all (p: input.outPath or null != p.outPath) selected;
|
|
||||||
|
|
||||||
# A function that takes a list of list of derivations, filters out all
|
|
||||||
# the `selected` packages from each list, and concats the results.
|
|
||||||
#
|
|
||||||
# zipperCombinedPkgs :: [[Derivation]] -> [Derivation]
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
# zipperCombinedPkgs [ [ lens conduit ] [ aeson frontend ] ]
|
|
||||||
# => [ lens conduit aeson ]
|
|
||||||
#
|
|
||||||
# Note: The reason this isn't just the function `pkgs.lib.concat` is
|
|
||||||
# that we need to be careful to remove dependencies that are in the
|
|
||||||
# `selected` packages.
|
|
||||||
#
|
|
||||||
# For instance, in the above example, if `common` is a dependency of
|
|
||||||
# `backend`, then zipperCombinedPkgs needs to be careful to filter out
|
|
||||||
# `common`, because cabal will end up ignoring that built version,
|
|
||||||
# assuming new-style commands.
|
|
||||||
zipperCombinedPkgs = vals:
|
|
||||||
pkgs.lib.concatMap
|
|
||||||
(drvList: pkgs.lib.filter isNotSelected drvList)
|
|
||||||
vals;
|
|
||||||
|
|
||||||
# Zip `cabalDepsForSelected` into a single attribute list, combining
|
|
||||||
# the derivations in all the individual attributes.
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
# packageInputs
|
|
||||||
# => # Assuming the value of cabalDepsForSelected is the same as
|
|
||||||
# # the example in cabalDepsForSelected:
|
|
||||||
# { buildDepends = [ gcc ... ];
|
|
||||||
# libraryHaskellDepends = [ lens conduit aeson ... ];
|
|
||||||
# testHaskellDepends = [ tasty hspec ... ];
|
|
||||||
# benchmarkHaskellDepends = [ criterion ... ];
|
|
||||||
# ...
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# See the Note in `zipperCombinedPkgs` for what gets filtered out from
|
|
||||||
# each of these dependency lists.
|
|
||||||
packageInputs =
|
|
||||||
pkgs.lib.zipAttrsWith (_name: zipperCombinedPkgs) (cabalDepsForSelected ++ [ (extraDependencies self) ]);
|
|
||||||
|
|
||||||
# A attribute set to pass to `haskellPackages.mkDerivation`.
|
|
||||||
#
|
|
||||||
# The important thing to note here is that all the fields from
|
|
||||||
# packageInputs are set correctly.
|
|
||||||
genericBuilderArgs = {
|
|
||||||
pname =
|
|
||||||
if pkgs.lib.length selected == 1
|
|
||||||
then (pkgs.lib.head selected).name
|
|
||||||
else "packages";
|
|
||||||
version = "0";
|
|
||||||
license = null;
|
|
||||||
}
|
|
||||||
// packageInputs
|
|
||||||
// pkgs.lib.optionalAttrs doBenchmark {
|
|
||||||
# `doBenchmark` needs to explicitly be set here because haskellPackages.mkDerivation defaults it to `false`. If the user wants benchmark dependencies included in their development shell, it has to be explicitly enabled here.
|
|
||||||
doBenchmark = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
# This is a pseudo Haskell package derivation that contains all the
|
|
||||||
# dependencies for the packages in `selected`.
|
|
||||||
#
|
|
||||||
# This is a derivation created with `haskellPackages.mkDerivation`.
|
|
||||||
#
|
|
||||||
# pkgWithCombinedDeps :: HaskellDerivation
|
|
||||||
pkgWithCombinedDeps = self.mkDerivation (genericBuilderArgsModifier genericBuilderArgs);
|
|
||||||
|
|
||||||
# The derivation returned from `envFunc` for `pkgWithCombinedDeps`.
|
|
||||||
#
|
|
||||||
# This is a derivation that can be run with `nix-shell`. It provides a
|
|
||||||
# GHC with a package database with all the dependencies of our
|
|
||||||
# `selected` packages.
|
|
||||||
#
|
|
||||||
# This is a derivation created with `stdenv.mkDerivation` (not
|
|
||||||
# `haskellPackages.mkDerivation`).
|
|
||||||
#
|
|
||||||
# pkgWithCombinedDepsDevDrv :: Derivation
|
|
||||||
pkgWithCombinedDepsDevDrv = pkgWithCombinedDeps.envFunc { inherit withHoogle; };
|
|
||||||
|
|
||||||
mkDerivationArgs = builtins.removeAttrs args [ "genericBuilderArgsModifier" "packages" "withHoogle" "doBenchmark" "extraDependencies" ];
|
|
||||||
|
|
||||||
in pkgWithCombinedDepsDevDrv.overrideAttrs (old: mkDerivationArgs // {
|
|
||||||
nativeBuildInputs = old.nativeBuildInputs ++ mkDerivationArgs.nativeBuildInputs or [];
|
|
||||||
buildInputs = old.buildInputs ++ mkDerivationArgs.buildInputs or [];
|
|
||||||
});
|
|
||||||
|
|
||||||
ghc = ghc // {
|
|
||||||
withPackages = self.ghcWithPackages;
|
|
||||||
withHoogle = self.ghcWithHoogle;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Run `cabal sdist` on a source.
|
|
||||||
|
|
||||||
Unlike `haskell.lib.sdistTarball`, this does not require any dependencies
|
|
||||||
to be present, as it uses `cabal-install` instead of building `Setup.hs`.
|
|
||||||
This makes `cabalSdist` faster than `sdistTarball`.
|
|
||||||
*/
|
|
||||||
cabalSdist = {
|
|
||||||
src,
|
|
||||||
name ? if src?name then "${src.name}-sdist.tar.gz" else "source.tar.gz"
|
|
||||||
}:
|
|
||||||
pkgs.runCommandLocal name
|
|
||||||
{
|
|
||||||
inherit src;
|
|
||||||
nativeBuildInputs = [
|
|
||||||
buildHaskellPackages.cabal-install
|
|
||||||
|
|
||||||
# TODO after https://github.com/haskell/cabal/issues/8352
|
|
||||||
# remove ghc
|
|
||||||
self.ghc
|
|
||||||
];
|
|
||||||
dontUnpack = false;
|
|
||||||
} ''
|
|
||||||
unpackPhase
|
|
||||||
cd "''${sourceRoot:-.}"
|
|
||||||
patchPhase
|
|
||||||
mkdir out
|
|
||||||
HOME=$PWD cabal sdist --output-directory out
|
|
||||||
mv out/*.tar.gz $out
|
|
||||||
'';
|
|
||||||
|
|
||||||
/*
|
|
||||||
Like `haskell.lib.buildFromSdist`, but using `cabal sdist` instead of
|
|
||||||
building `./Setup`.
|
|
||||||
|
|
||||||
Unlike `haskell.lib.buildFromSdist`, this does not require any dependencies
|
|
||||||
to be present. This makes `buildFromCabalSdist` faster than `haskell.lib.buildFromSdist`.
|
|
||||||
*/
|
|
||||||
buildFromCabalSdist = pkg:
|
|
||||||
haskellLib.overrideSrc
|
|
||||||
{
|
|
||||||
src = self.cabalSdist { inherit (pkg) src; };
|
|
||||||
version = pkg.version;
|
|
||||||
}
|
|
||||||
pkg;
|
|
||||||
|
|
||||||
/*
|
|
||||||
Modify a Haskell package to add shell completion scripts for the
|
|
||||||
given executables produced by it. These completion scripts will be
|
|
||||||
picked up automatically if the resulting derivation is installed,
|
|
||||||
e.g. by `nix-env -i`.
|
|
||||||
|
|
||||||
This depends on the `--*-completion` flag `optparse-applicative` provides
|
|
||||||
automatically. Since we need to invoke installed executables, completions
|
|
||||||
are not generated if we are cross-compiling.
|
|
||||||
|
|
||||||
commands: names of the executables built by the derivation
|
|
||||||
pkg: Haskell package that builds the executables
|
|
||||||
|
|
||||||
Example:
|
|
||||||
generateOptparseApplicativeCompletions [ "exec1" "exec2" ] pkg
|
|
||||||
|
|
||||||
Type: [str] -> drv -> drv
|
|
||||||
*/
|
|
||||||
generateOptparseApplicativeCompletions =
|
|
||||||
(self.callPackage (
|
|
||||||
{ stdenv }:
|
|
||||||
|
|
||||||
commands:
|
|
||||||
pkg:
|
|
||||||
|
|
||||||
if stdenv.buildPlatform.canExecute stdenv.hostPlatform
|
|
||||||
then lib.foldr haskellLib.__generateOptparseApplicativeCompletion pkg commands
|
|
||||||
else pkg
|
|
||||||
) { }) // { __attrsFailEvaluation = true; };
|
|
||||||
|
|
||||||
/*
|
|
||||||
Modify given Haskell package to force GHC to employ the LLVM
|
|
||||||
codegen backend when compiling. Useful when working around bugs
|
|
||||||
in a native codegen backend GHC defaults to.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
forceLlvmCodegenBackend tls
|
|
||||||
|
|
||||||
Type: drv -> drv
|
|
||||||
*/
|
|
||||||
forceLlvmCodegenBackend = overrideCabal (drv: {
|
|
||||||
configureFlags = drv.configureFlags or [ ] ++ [ "--ghc-option=-fllvm" ];
|
|
||||||
buildTools = drv.buildTools or [ ] ++ [ self.llvmPackages.llvm ];
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
{ pkgs, haskellLib }:
|
|
||||||
|
|
||||||
# EXTRA HASKELL PACKAGES NOT ON HACKAGE
|
|
||||||
#
|
|
||||||
# This file should only contain packages that are not in ./hackage-packages.nix.
|
|
||||||
# Attributes in this set should be nothing more than a callPackage call.
|
|
||||||
# Overrides to these packages should go to either configuration-nix.nix,
|
|
||||||
# configuration-common.nix or to one of the compiler specific configuration
|
|
||||||
# files.
|
|
||||||
self: super: {
|
|
||||||
|
|
||||||
changelog-d = self.callPackage ../misc/haskell/changelog-d {};
|
|
||||||
|
|
||||||
dconf2nix = self.callPackage ../tools/haskell/dconf2nix/dconf2nix.nix { };
|
|
||||||
|
|
||||||
# Used by maintainers/scripts/regenerate-hackage-packages.sh, and generated
|
|
||||||
# from the latest master instead of the current version on Hackage.
|
|
||||||
cabal2nix-unstable = self.callPackage ./cabal2nix-unstable.nix { };
|
|
||||||
|
|
||||||
# https://github.com/channable/vaultenv/issues/1
|
|
||||||
vaultenv = self.callPackage ../tools/haskell/vaultenv { };
|
|
||||||
|
|
||||||
# spago is not released to Hackage.
|
|
||||||
# https://github.com/spacchetti/spago/issues/512
|
|
||||||
spago = self.callPackage ../tools/purescript/spago/spago.nix { };
|
|
||||||
|
|
||||||
nix-linter = self.callPackage ../../development/tools/analysis/nix-linter { };
|
|
||||||
|
|
||||||
# hasura graphql-engine is not released to hackage.
|
|
||||||
# https://github.com/hasura/graphql-engine/issues/7391
|
|
||||||
ci-info = self.callPackage ../misc/haskell/hasura/ci-info.nix {};
|
|
||||||
pg-client = self.callPackage ../misc/haskell/hasura/pg-client.nix {};
|
|
||||||
graphql-parser = self.callPackage ../misc/haskell/hasura/graphql-parser.nix {};
|
|
||||||
graphql-engine = self.callPackage ../misc/haskell/hasura/graphql-engine.nix {};
|
|
||||||
kriti-lang = self.callPackage ../misc/haskell/hasura/kriti-lang.nix {};
|
|
||||||
hasura-resource-pool = self.callPackage ../misc/haskell/hasura/pool.nix {};
|
|
||||||
hasura-ekg-core = self.callPackage ../misc/haskell/hasura/ekg-core.nix {};
|
|
||||||
hasura-ekg-json = self.callPackage ../misc/haskell/hasura/ekg-json.nix {};
|
|
||||||
|
|
||||||
# Unofficial fork until PRs are merged https://github.com/pcapriotti/optparse-applicative/pulls/roberth
|
|
||||||
# cabal2nix --maintainer roberth https://github.com/hercules-ci/optparse-applicative.git > pkgs/development/misc/haskell/hercules-ci-optparse-applicative.nix
|
|
||||||
hercules-ci-optparse-applicative = self.callPackage ../misc/haskell/hercules-ci-optparse-applicative.nix {};
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
{ runCommand, haskellPackages, lib, all-cabal-hashes, writeShellScript }:
|
|
||||||
let
|
|
||||||
# Checks if the version looks like a Haskell PVP version which is the format
|
|
||||||
# Hackage enforces. This will return false if the version strings is empty or
|
|
||||||
# we've overridden the package to ship an unstable version of the package
|
|
||||||
# (sadly there's no good way to show something useful on hackage in this case).
|
|
||||||
isPvpVersion = v: builtins.match "([0-9]+)(\\.[0-9]+)*" v != null;
|
|
||||||
|
|
||||||
pkgLine = name: pkg:
|
|
||||||
let
|
|
||||||
version = pkg.version or "";
|
|
||||||
in
|
|
||||||
lib.optionalString (isPvpVersion version && (pkg.meta.hydraPlatforms or null) != lib.platforms.none)
|
|
||||||
''"${name}","${version}","http://hydra.nixos.org/job/nixpkgs/trunk/haskellPackages.${name}.x86_64-linux"'';
|
|
||||||
all-haskellPackages = builtins.toFile "all-haskellPackages" (lib.concatStringsSep "\n" (lib.filter (x: x != "") (lib.mapAttrsToList pkgLine haskellPackages)));
|
|
||||||
in
|
|
||||||
runCommand "hackage-package-list" { }
|
|
||||||
# This command will make a join between all packages on hackage and haskellPackages.*.
|
|
||||||
# It ignores packages marked as broken (according to hydraPlatforms)
|
|
||||||
# It creates a valid csv file which can be uploaded to hackage.haskell.org.
|
|
||||||
# The call is wrapped in echo $(...) to trim trailing newline, which hackage requires.
|
|
||||||
''
|
|
||||||
mkdir -p $out/bin
|
|
||||||
echo -n "$(tar -t -f ${all-cabal-hashes} | sed 's![^/]*/\([^/]*\)/.*!"\1"!' | sort -u | join -t , - ${all-haskellPackages})" > $out/nixos-hackage-packages.csv
|
|
||||||
''
|
|
|
@ -1,12 +0,0 @@
|
||||||
diff --git a/GLUT.cabal b/GLUT.cabal
|
|
||||||
index f370d6c..a404e1e 100644
|
|
||||||
--- a/GLUT.cabal
|
|
||||||
+++ b/GLUT.cabal
|
|
||||||
@@ -103,6 +103,7 @@ library
|
|
||||||
else
|
|
||||||
cpp-options: "-DCALLCONV=ccall"
|
|
||||||
cc-options: "-DUSE_DLSYM"
|
|
||||||
+ pkgconfig-depends: glut
|
|
||||||
|
|
||||||
executable BOGLGP01-OnYourOwn1
|
|
||||||
if !flag(BuildExamples)
|
|
|
@ -1,17 +0,0 @@
|
||||||
diff --git a/HSH/ShellEquivs.hs b/HSH/ShellEquivs.hs
|
|
||||||
index f9287e8..b132737 100644
|
|
||||||
--- a/HSH/ShellEquivs.hs
|
|
||||||
+++ b/HSH/ShellEquivs.hs
|
|
||||||
@@ -223,9 +223,9 @@ catToFIFO fp ichan =
|
|
||||||
return (ChanString "")
|
|
||||||
|
|
||||||
fifoOpen :: FilePath -> IO Handle
|
|
||||||
-fifoOpen fp =
|
|
||||||
- do fd <- throwErrnoPathIf (< 0) "HSH fifoOpen" fp $
|
|
||||||
- openFd fp WriteOnly Nothing defaultFileFlags
|
|
||||||
+fifoOpen fp =
|
|
||||||
+ do fd <- throwErrnoPathIf (< 0) "HSH fifoOpen" fp $
|
|
||||||
+ openFd fp WriteOnly defaultFileFlags
|
|
||||||
fdToHandle fd
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,9 +0,0 @@
|
||||||
--- SDL-image-0.6.2.0/Graphics/UI/SDL/Image/Version.hsc.orig 2021-08-06 01:21:05.000000000 +0200
|
|
||||||
+++ SDL-image-0.6.2.0/Graphics/UI/SDL/Image/Version.hsc 2021-08-06 01:21:56.000000000 +0200
|
|
||||||
@@ -1,4 +1,6 @@
|
|
||||||
#include "SDL_image.h"
|
|
||||||
+-- override SDL_main.h redefining main to SDL_main on darwin
|
|
||||||
+#define main main
|
|
||||||
module Graphics.UI.SDL.Image.Version
|
|
||||||
( compiledFor
|
|
||||||
, linkedWith
|
|
|
@ -1,9 +0,0 @@
|
||||||
--- SDL-ttf-0.6.3.0/Graphics/UI/SDL/TTF/Version.hsc.orig 2021-08-06 01:31:39.000000000 +0200
|
|
||||||
+++ SDL-ttf-0.6.3.0/Graphics/UI/SDL/TTF/Version.hsc 2021-08-06 01:32:03.000000000 +0200
|
|
||||||
@@ -1,4 +1,6 @@
|
|
||||||
#include "SDL_ttf.h"
|
|
||||||
+-- override SDL_main.h redefining main to SDL_main on darwin
|
|
||||||
+#define main main
|
|
||||||
module Graphics.UI.SDL.TTF.Version
|
|
||||||
( compiledFor
|
|
||||||
, linkedWith
|
|
|
@ -1,23 +0,0 @@
|
||||||
diff --git a/Cheapskate/Parse.hs b/Cheapskate/Parse.hs
|
|
||||||
index b90d8e5..2925132 100644
|
|
||||||
--- a/Cheapskate/Parse.hs
|
|
||||||
+++ b/Cheapskate/Parse.hs
|
|
||||||
@@ -1,4 +1,5 @@
|
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
|
||||||
+{-# LANGUAGE CPP #-}
|
|
||||||
module Cheapskate.Parse (
|
|
||||||
markdown
|
|
||||||
) where
|
|
||||||
@@ -21,6 +22,12 @@ import Control.Applicative
|
|
||||||
import qualified Data.Map as M
|
|
||||||
import Data.List (intercalate)
|
|
||||||
|
|
||||||
+#if MIN_VERSION_mtl(2, 3, 0)
|
|
||||||
+import Control.Monad (guard, unless, replicateM)
|
|
||||||
+#else
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+
|
|
||||||
import Debug.Trace
|
|
||||||
|
|
||||||
-- | Parses the input as a markdown document. Note that 'Doc' is an instance
|
|
|
@ -1,69 +0,0 @@
|
||||||
diff --git a/Crypto/KDF/Argon2.hs b/Crypto/KDF/Argon2.hs
|
|
||||||
index 044ba00..31dc6f1 100644
|
|
||||||
--- a/Crypto/KDF/Argon2.hs
|
|
||||||
+++ b/Crypto/KDF/Argon2.hs
|
|
||||||
@@ -12,6 +12,7 @@
|
|
||||||
-- File started from Argon2.hs, from Oliver Charles
|
|
||||||
-- at https://github.com/ocharles/argon2
|
|
||||||
--
|
|
||||||
+{-# LANGUAGE DataKinds #-}
|
|
||||||
module Crypto.KDF.Argon2
|
|
||||||
(
|
|
||||||
Options(..)
|
|
||||||
@@ -32,6 +33,7 @@ import Control.Monad (when)
|
|
||||||
import Data.Word
|
|
||||||
import Foreign.C
|
|
||||||
import Foreign.Ptr
|
|
||||||
+import Data.Proxy
|
|
||||||
|
|
||||||
-- | Which variant of Argon2 to use. You should choose the variant that is most
|
|
||||||
-- applicable to your intention to hash inputs.
|
|
||||||
@@ -100,33 +102,12 @@ defaultOptions =
|
|
||||||
}
|
|
||||||
|
|
||||||
hash :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray out)
|
|
||||||
- => Options
|
|
||||||
+ => [Proxy "cryptonite:Crypto.KDF.Argon2.hash is known to be broken on this architecture. See https://github.com/haskell-crypto/cryptonite/issues/360"]
|
|
||||||
-> password
|
|
||||||
-> salt
|
|
||||||
-> Int
|
|
||||||
-> CryptoFailable out
|
|
||||||
-hash options password salt outLen
|
|
||||||
- | saltLen < saltMinLength = CryptoFailed CryptoError_SaltTooSmall
|
|
||||||
- | outLen < outputMinLength = CryptoFailed CryptoError_OutputLengthTooSmall
|
|
||||||
- | outLen > outputMaxLength = CryptoFailed CryptoError_OutputLengthTooBig
|
|
||||||
- | otherwise = CryptoPassed $ B.allocAndFreeze outLen $ \out -> do
|
|
||||||
- res <- B.withByteArray password $ \pPass ->
|
|
||||||
- B.withByteArray salt $ \pSalt ->
|
|
||||||
- argon2_hash (iterations options)
|
|
||||||
- (memory options)
|
|
||||||
- (parallelism options)
|
|
||||||
- pPass
|
|
||||||
- (csizeOfInt passwordLen)
|
|
||||||
- pSalt
|
|
||||||
- (csizeOfInt saltLen)
|
|
||||||
- out
|
|
||||||
- (csizeOfInt outLen)
|
|
||||||
- (cOfVariant $ variant options)
|
|
||||||
- (cOfVersion $ version options)
|
|
||||||
- when (res /= 0) $ error "argon2: hash: internal error"
|
|
||||||
- where
|
|
||||||
- saltLen = B.length salt
|
|
||||||
- passwordLen = B.length password
|
|
||||||
+hash options password salt outLen = error "cryptonite:Crypto.KDF.Argon2.hash is known to be broken on this architecture. See https://github.com/haskell-crypto/cryptonite/issues/360"
|
|
||||||
|
|
||||||
data Pass
|
|
||||||
data Salt
|
|
||||||
diff --git a/tests/KAT_Argon2.hs b/tests/KAT_Argon2.hs
|
|
||||||
index a347fc5..fdba079 100644
|
|
||||||
--- a/tests/KAT_Argon2.hs
|
|
||||||
+++ b/tests/KAT_Argon2.hs
|
|
||||||
@@ -32,7 +32,7 @@ kdfTests = zipWith toKDFTest is vectors
|
|
||||||
where
|
|
||||||
toKDFTest i v =
|
|
||||||
testCase (show i)
|
|
||||||
- (CryptoPassed (kdfResult v) @=? Argon2.hash (kdfOptions v) (kdfPass v) (kdfSalt v) (B.length $ kdfResult v))
|
|
||||||
+ (pure ())
|
|
||||||
|
|
||||||
is :: [Int]
|
|
||||||
is = [1..]
|
|
|
@ -1,67 +0,0 @@
|
||||||
From 67bb87ceff53f0178c988dd4e15eeb2daee92b84 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Gregor Kleen <pngwjpgh@users.noreply.github.com>
|
|
||||||
Date: Tue, 20 Feb 2018 17:46:24 +0100
|
|
||||||
Subject: [PATCH] Relax upper version bounds on dependencies
|
|
||||||
|
|
||||||
---
|
|
||||||
Setup.hs | 20 ++++++++++++++++----
|
|
||||||
encoding.cabal | 4 ++--
|
|
||||||
stack.yaml | 4 ++--
|
|
||||||
3 files changed, 20 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/Setup.hs b/Setup.hs
|
|
||||||
index de719e6..fe5b84c 100644
|
|
||||||
--- a/Setup.hs
|
|
||||||
+++ b/Setup.hs
|
|
||||||
@@ -1,13 +1,25 @@
|
|
||||||
+{-# LANGUAGE CPP #-}
|
|
||||||
+
|
|
||||||
module Main where
|
|
||||||
|
|
||||||
import Distribution.Simple
|
|
||||||
import Data.Encoding.Preprocessor.Mapping
|
|
||||||
import Data.Encoding.Preprocessor.XMLMappingBuilder
|
|
||||||
|
|
||||||
+#if MIN_VERSION_Cabal(2,0,0)
|
|
||||||
+main = defaultMainWithHooks (simpleUserHooks
|
|
||||||
+ {hookedPreProcessors = ( ("mapping" , \_ _ _ -> mappingPreprocessor)
|
|
||||||
+ : ("mapping2", \_ _ _ -> mappingPreprocessor)
|
|
||||||
+ : ("xml" , \_ _ _ -> xmlPreprocessor)
|
|
||||||
+ : (hookedPreProcessors simpleUserHooks)
|
|
||||||
+ )
|
|
||||||
+ })
|
|
||||||
+#else
|
|
||||||
main = defaultMainWithHooks (simpleUserHooks
|
|
||||||
- {hookedPreProcessors = (("mapping",\_ _ -> mappingPreprocessor)
|
|
||||||
- :("mapping2",\_ _ -> mappingPreprocessor)
|
|
||||||
- :("xml",\_ _ -> xmlPreprocessor)
|
|
||||||
- :(hookedPreProcessors simpleUserHooks)
|
|
||||||
+ {hookedPreProcessors = ( ("mapping" , \_ _ -> mappingPreprocessor)
|
|
||||||
+ : ("mapping2", \_ _ -> mappingPreprocessor)
|
|
||||||
+ : ("xml" , \_ _ -> xmlPreprocessor)
|
|
||||||
+ : (hookedPreProcessors simpleUserHooks)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
+#endif
|
|
||||||
diff --git a/encoding.cabal b/encoding.cabal
|
|
||||||
index ec20617..f221715 100644
|
|
||||||
--- a/encoding.cabal
|
|
||||||
+++ b/encoding.cabal
|
|
||||||
@@ -36,7 +36,7 @@ Source-Repository this
|
|
||||||
|
|
||||||
Custom-Setup
|
|
||||||
Setup-Depends: base >=3 && <5,
|
|
||||||
- Cabal >=1.24 && <1.25,
|
|
||||||
+ Cabal >=1.24 && <2.1,
|
|
||||||
containers,
|
|
||||||
filepath,
|
|
||||||
ghc-prim,
|
|
||||||
@@ -51,7 +51,7 @@ Library
|
|
||||||
extensible-exceptions >=0.1 && <0.2,
|
|
||||||
ghc-prim >=0.3 && <0.6,
|
|
||||||
mtl >=2.0 && <2.3,
|
|
||||||
- regex-compat >=0.71 && <0.95
|
|
||||||
+ regex-compat >=0.71 && <0.96
|
|
||||||
|
|
||||||
Extensions: CPP
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue