Skip to content

Commit

Permalink
Use fedora27 bindist on Linux-x86_64 by default
Browse files Browse the repository at this point in the history
Debian 9 still uses ncurses 5, which complicates installation.
Specifically, ncurses 5 provided by nixpkgs appears not to provide
shared object version information, whereas Debian does. While
`patchelfUnstable` can [1] update library version requirements, it
cannot remove them entirely.

Rather than find some terrible workaround, it's much easier to simply
use a bindist that expects ncurses 6 with symbol versioning. Fedora
27 provides exactly this.

[1]  NixOS/patchelf#85
  • Loading branch information
bgamari committed Feb 27, 2019
1 parent 7978c5a commit 633c6d7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
20 changes: 13 additions & 7 deletions artifact.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
{ stdenv, lib
{ stdenv, lib, patchelfUnstable
, perl, gcc, llvm_39
, ncurses5, gmp, glibc, libiconv
}: { bindistTarball }:
, ncurses6, ncurses5, gmp, glibc, libiconv
}: { bindistTarball, ncursesVersion }:

# Prebuilt only does native
assert stdenv.targetPlatform == stdenv.hostPlatform;

let
libPath = stdenv.lib.makeLibraryPath ([
ncurses5 gmp
selectedNcurses gmp
] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);

selectedNcurses = {
"5" = ncurses5;
"6" = ncurses6;
}."${ncursesVersion}";

libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
+ "LD_LIBRARY_PATH";

Expand Down Expand Up @@ -93,10 +98,11 @@ stdenv.mkDerivation rec {
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
'' +
# Rename needed libraries and binaries, fix interpreter
# N.B. Use patchelfUnstable due to https://github.com/NixOS/patchelf/pull/85
stdenv.lib.optionalString stdenv.isLinux ''
find . -type f -perm -0100 -exec patchelf \
--replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
--replace-needed libtinfo.so libtinfo.so.5 \
find . -type f -perm -0100 -exec ${patchelfUnstable}/bin/patchelf \
--replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.${ncursesVersion} libncurses.so \
--replace-needed libtinfo.so.${ncursesVersion} libncurses.so.${ncursesVersion} \
--interpreter ${glibcDynLinker} {} \;
sed -i "s|/usr/bin/perl|perl\x00 |" ghc*/ghc/stage2/build/tmp/ghc-stage2
Expand Down
7 changes: 4 additions & 3 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ let
ghc = self: ref: self.callPackage ./artifact.nix {} ref;
ol = self: super:
{
ghcHEAD = ghc self {
bindistTarball = self.callPackage ./gitlab-artifact.nix {} { inherit fork branch; };
};
ghcHEAD =
ghc self (self.callPackage ./gitlab-artifact.nix {} {
inherit fork branch;
});
};
in
import <nixpkgs> { overlays = [ol]; }
27 changes: 20 additions & 7 deletions gitlab-artifact.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,33 @@

let
mkUrl = job: "https://gitlab.haskell.org/${fork}/ghc/-/jobs/artifacts/${branch}/raw/ghc.tar.xz?job=${job}";
url = {

# job: the GitLab CI job we should pull the bindist from
# ncursesVersion: the ncurses version which the bindist expects
configs = {
"i386-linux" = {
url = mkUrl "validate-i386-linux-deb9";
job = mkUrl "validate-i386-linux-fedora27";
ncursesVersion = "6";
};
"x86_64-linux" = {
url = mkUrl "validate-x86_64-linux-deb8";
job = mkUrl "validate-x86_64-linux-fedora27";
ncursesVersion = "6";
};
"aarch64-linux" = {
url = mkUrl "validate-aarch64-linux-deb9";
job = mkUrl "validate-aarch64-linux-deb9";
ncursesVersion = "5";
};
"x86_64-darwin" = {
url = mkUrl "validate-x86_64-darwin";
job = mkUrl "validate-x86_64-darwin";
ncursesVersion = "6";
};
}.${stdenv.hostPlatform.system}
};

config = configs.${stdenv.hostPlatform.system}
or (throw "cannot bootstrap GHC on this platform");
in builtins.fetchurl url

in {
bindistTarball = builtins.fetchurl (mkUrl config.job);
inherit (config) ncursesVersion;
}

0 comments on commit 633c6d7

Please sign in to comment.