Skip to content

Commit 338d136

Browse files
committed
Upgrade to nixpkgs master instead of nh2's fork. See #6.
Note that we can't upgrade to the latest master yet because musl 1.1.20 breaks things vs 1.1.19 (see #6).
1 parent 7ad63b1 commit 338d136

File tree

3 files changed

+57
-40
lines changed

3 files changed

+57
-40
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The [`survey`](./survey) directory maintains a select set of Haskell executables
3434
Run for example:
3535

3636
```
37-
NIX_PATH=nixpkgs=https://github.com/nh2/nixpkgs/archive/50677e464359947f2a71cfd497c4022e3cdf8c7d.tar.gz nix-build --no-link survey/default.nix -A working
37+
NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/88ae8f7d.tar.gz nix-build --no-link survey/default.nix -A working
3838
```
3939

4040
There are multiple package sets available in the survey (select via `-A`):

static-stack/default.nix

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,27 @@
88
# does that for you because as of writing, `stack2nix` doesn't support
99
# being run from within a nix build, because it calls `cabal update`.
1010
let
11+
pyopenssl-fix-test-buffer-size-overlay = final: previous: {
12+
python36 = previous.python36.override {
13+
packageOverrides = self: super: {
14+
pyopenssl = super.pyopenssl.overridePythonAttrs (old: rec {
15+
patches = [
16+
# TODO Remove when https://github.com/pyca/pyopenssl/commit/b2777a465b669fb647dbac0a92919cb05458707b is available in nixpkgs
17+
(final.fetchpatch {
18+
name = "wantWriteError-test-buffer-size.patch";
19+
url = "https://github.com/pyca/pyopenssl/commit/b2777a465b669fb647dbac0a92919cb05458707b.patch";
20+
sha256 = "0igksnl0cd5cx8f38bfjdriwdrzbw6ciy0hs805s84mprfwhck8d";
21+
})
22+
];
23+
});
24+
};
25+
};
26+
};
27+
1128
# In `survey` we provide a nixpkgs set with some fixes; import it here.
1229
pkgs = (import ../survey/default.nix {
13-
normalPkgs = import (fetchTarball https://github.com/nh2/nixpkgs/archive/50677e464359947f2a71cfd497c4022e3cdf8c7d.tar.gz) {};
30+
normalPkgs = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/88ae8f7d55efa457c95187011eb410d097108445.tar.gz) {};
31+
overlays = [ pyopenssl-fix-test-buffer-size-overlay ];
1432
}).pkgs;
1533

1634
# TODO Use `pkgs.stack2nix` instead of this once `stack2nix` 0.2 is in `pkgs`
@@ -43,6 +61,7 @@ let
4361
}).haskellPackages.stack;
4462

4563
in {
64+
inherit pkgs;
4665
inherit stack2nix-script;
4766
inherit static_stack;
4867
}

survey/default.nix

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
let
22
tracing = false; # Enable this to see debug traces
33

4-
# TODO: Remove when
5-
# * https://github.com/NixOS/cabal2nix/pull/360
6-
# * https://github.com/NixOS/cabal2nix/commit/7ccbd668d1f9f8154a1fbc1ba48d7a483f37a2a7
7-
# are merged and available
8-
cabal2nix-fix-overlay = pkgs: final: previous:
9-
with final.haskell.lib; {
10-
haskellPackages = previous.haskellPackages.override (old: {
11-
overrides = final.lib.composeExtensions (old.overrides or (_: _: {})) (
12-
13-
self: super: {
14-
cabal2nix = overrideCabal super.cabal2nix (old: {
15-
src = pkgs.fetchFromGitHub {
16-
owner = "nh2";
17-
repo = "cabal2nix";
18-
rev = "4080fbca34278fc099139e7fcd3164ded8fe86c1";
19-
sha256 = "1dp6cmqld6ylyq2hjfpz1n2sz91932fji879ly6c9sri512gmnbx";
20-
};
21-
});
22-
23-
}
24-
);
25-
});
4+
cython-disable-tests-overlay = pkgs: final: previous: {
5+
python27 = pkgs.python27.override {
6+
packageOverrides = self: super: {
7+
cython = super.cython.overridePythonAttrs (old: rec {
8+
# TODO Remove once Cython tests are no longer flaky. See
9+
# https://github.com/nh2/static-haskell-nix/issues/6#issuecomment-420452838
10+
# https://github.com/cython/cython/issues/2602
11+
dontCheck = true;
12+
});
13+
};
2614
};
15+
};
2716

2817
trace = message: value:
2918
if tracing then builtins.trace message value else value;
@@ -33,13 +22,15 @@ in
3322
{
3423
normalPkgs ? (import <nixpkgs> {}),
3524

25+
overlays ? [],
26+
3627
pkgs ? (import normalPkgs.path {
3728
config.allowUnfree = true;
3829
config.allowBroken = true;
3930
# config.permittedInsecurePackages = [
4031
# "webkitgtk-2.4.11"
4132
# ];
42-
overlays = [ (cabal2nix-fix-overlay normalPkgs) ];
33+
overlays = overlays ++ [ (cython-disable-tests-overlay normalPkgs) ];
4334
}).pkgsMusl,
4435

4536
compiler ? "ghc843",
@@ -98,7 +89,7 @@ let
9889
# Contains a list of package names (strings).
9990
stackagePackages =
10091
let
101-
stackageInfoPath = pkgs.path + "/nixpkgs/pkgs/development/haskell-modules/configuration-hackage2nix.yaml";
92+
stackageInfoPath = pkgs.path + "/pkgs/development/haskell-modules/configuration-hackage2nix.yaml";
10293
pythonWithYaml = pkgs.python2Packages.python.withPackages (pkgs: [pkgs.pyyaml]);
10394
dont-distribute-packages-file = normalPkgs.runCommand "test" {} ''
10495
${pythonWithYaml}/bin/python -c 'import yaml, json; x = yaml.load(open("${stackageInfoPath}")); print(json.dumps([line.split(" ")[0] for line in x["default-package-overrides"]]))' > $out
@@ -184,8 +175,10 @@ let
184175

185176
# Stackage package names we want to blacklist.
186177
blacklist = [
187-
# Doens't build in `normalPkgs.haskellPackages` either
178+
# Doesn't build in `normalPkgs.haskellPackages` either
188179
"mercury-api"
180+
# https://github.com/nh2/static-haskell-nix/issues/6#issuecomment-420494800
181+
"sparkle"
189182
];
190183

191184
# All Stackage executables who (and whose dependencies) are not marked
@@ -279,13 +272,14 @@ let
279272

280273
libssh2_static = pkgs.libssh2.overrideAttrs (old: { dontDisableStatic = true; });
281274

282-
# Requires https://github.com/NixOS/nixpkgs/pull/43870
283-
# TODO Remove the above note when it's merged and available
284-
# Note krb5 does not support building both static and shared at the same time.
285-
krb5_static = pkgs.krb5.override { staticOnly = true; };
275+
keyutils_static = pkgs.keyutils.overrideAttrs (old: { dontDisableStatic = true; });
276+
277+
krb5_static = pkgs.krb5.override {
278+
# Note krb5 does not support building both static and shared at the same time.
279+
staticOnly = true;
280+
keyutils = keyutils_static;
281+
};
286282

287-
# Requires https://github.com/NixOS/nixpkgs/pull/43870
288-
# TODO Remove the above note when it's merged and available
289283
openssl_static = pkgs.openssl.override { static = true; };
290284

291285
curl_static = (pkgs.curl.override {
@@ -304,12 +298,18 @@ let
304298
# https://github.com/curl/curl/blob/7bc11804374/configure.ac#L954
305299
pkgs.zlib
306300
];
307-
configureFlags = old.configureFlags ++ [
301+
# Using configureFlagsArray because when passing multiple `LIBS`, we have to have spaces inside that variable.
302+
configureFlagsArray = [
308303
# When linking krb5 statically, one has to pass -lkrb5support explicitly
309304
# because core functions such as `k5_clear_error` are in
310305
# `libkrb5support.a` and not in `libkrb5.a`.
311306
# See https://stackoverflow.com/questions/39960588/gcc-linking-with-kerberos-for-compiling-with-curl-statically/41822755#41822755
312-
"LIBS=-lkrb5support"
307+
#
308+
# Also pass -lkeyutils explicitly because krb5 depends on it; otherwise users of libcurl get linker errors like
309+
# ../lib/.libs/libcurl.so: undefined reference to `add_key'
310+
# ../lib/.libs/libcurl.so: undefined reference to `keyctl_get_keyring_ID'
311+
# ../lib/.libs/libcurl.so: undefined reference to `keyctl_unlink'
312+
"LIBS=-lkrb5support -L${keyutils_static.lib}/lib -lkeyutils"
313313
];
314314
});
315315

@@ -335,6 +335,7 @@ let
335335
preConfigure = builtins.concatStringsSep "\n" [
336336
(old.preConfigure or "")
337337
''
338+
set -e
338339
configureFlags+=$(for flag in $(pkg-config --static ${pkgconfigFlagsString}); do echo -n " --ld-option=$flag"; done)
339340
''
340341
];
@@ -383,7 +384,7 @@ let
383384
# but that doesn't work because that output contains `-Wl,...` flags
384385
# which aren't accepted by `ld` and thus cannot be passed as `ld-option`s.
385386
# See https://github.com/curl/curl/issues/2775 for an investigation of why.
386-
"--libs-only-l libcurl";
387+
"--libs-only-L --libs-only-l libcurl";
387388

388389
postgresql-libpq = super.postgresql-libpq.override { postgresql = postgresql_static; };
389390

@@ -450,7 +451,7 @@ let
450451
# but that doesn't work because that output contains `-Wl,...` flags
451452
# which aren't accepted by `ld` and thus cannot be passed as `ld-option`s.
452453
# See https://github.com/curl/curl/issues/2775 for an investigation of why.
453-
"--libs-only-l libcurl expat";
454+
"--libs-only-L --libs-only-l libcurl expat";
454455

455456
aern2-real =
456457
addStaticLinkerFlagsWithPkgconfig
@@ -620,6 +621,3 @@ in
620621
inherit haskellPackagesWithLibsReadyForStaticLinking;
621622
inherit haskellPackages;
622623
}
623-
624-
# TODO Update README to depend on nixpkgs master in use (instead of nh2's fork), and write something that picks nh2's patches I use on top here
625-
# TODO Instead of picking https://github.com/NixOS/nixpkgs/pull/43713, use a Python script to dedupe `-L` flags from the NIX_*LDFLAGS variables

0 commit comments

Comments
 (0)