-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trying to create static Haskell binaries using Nix
Unfortunately, the build fails with /nix/store/cdbsfljc8m900axs37fab7gnp2y1dksn-binutils-2.31.1/bin/ld: /nix/store/x0ybqvkk6h6x8mhsy5gghplsfvammq6q-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-musl/9.3.0/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object /nix/store/cdbsfljc8m900axs37fab7gnp2y1dksn-binutils-2.31.1/bin/ld: /nix/store/x0ybqvkk6h6x8mhsy5gghplsfvammq6q-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-musl/9.3.0/crtend.o: relocation R_X86_64_32 against `.ctors' can not be used when making a shared object; recompile with -fPIC This may be related to - nh2/static-haskell-nix#99 - input-output-hk/haskell.nix#914
- Loading branch information
Showing
2 changed files
with
38 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,35 @@ | ||
{ compiler ? "ghc865", sources ? import ./nix/sources.nix }: | ||
|
||
let | ||
config = { | ||
packageOverrides = pkgs: rec { | ||
haskell = pkgs.haskell // { | ||
packages = pkgs.haskell.packages // { | ||
"${compiler}" = pkgs.haskell.packages."${compiler}".override { | ||
overrides = haskellPackagesNew: haskellPackagesOld: rec { | ||
envy = haskellPackagesNew.callPackage ./nix/envy.nix {}; # old version (< 2) depended on by envy | ||
hal = pkgs.haskell.lib.markUnbroken haskellPackagesOld.hal; | ||
telegram-api = haskellPackagesNew.callPackage ./nix/haskell-telegram-api.nix {}; # patched version from git repo | ||
halma = haskellPackagesNew.callPackage ./halma/halma.nix {}; | ||
halma-telegram-bot = haskellPackagesNew.callPackage ./halma-telegram-bot/halma-telegram-bot.nix {}; | ||
servant-server = pkgs.haskell.lib.dontCheck haskellPackagesOld.servant-server; # tests fail to compile | ||
}; | ||
}; | ||
nonStaticPkgs = | ||
with | ||
{ overlay = _: pkgs: { niv = import sources.niv {}; }; }; | ||
import sources.nixpkgs { overlays = [ overlay ]; }; | ||
|
||
staticPkgs = (import "${sources.static-haskell-nix}/survey/default.nix" { compiler = compiler; normalPkgs = nonStaticPkgs; }).pkgs; | ||
haskellLib = staticPkgs.haskell.lib; | ||
|
||
staticHaskellPkgs = staticPkgs.haskell.packages.${compiler}.override { | ||
overrides = haskellPackagesNew: haskellPackagesOld: rec { | ||
envy = haskellPackagesNew.callPackage ./nix/envy.nix {}; # old version (< 2) depended on by envy | ||
hal = haskellLib.markUnbroken haskellPackagesOld.hal; | ||
telegram-api = haskellPackagesNew.callPackage ./nix/haskell-telegram-api.nix {}; # patched version from git repo | ||
halma = haskellPackagesNew.callPackage ./halma/halma.nix {}; | ||
halma-telegram-bot = haskellLib.overrideCabal | ||
(haskellLib.justStaticExecutables (haskellPackagesNew.callPackage ./halma-telegram-bot/halma-telegram-bot.nix {})) | ||
{ | ||
configureFlags = [ | ||
"--ghc-option=-optl=-static" | ||
"--extra-lib-dirs=${staticPkgs.gmp6.override { withStatic = true; }}/lib" | ||
"--extra-lib-dirs=${staticPkgs.zlib.static}/lib" | ||
"--extra-lib-dirs=${staticPkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib" | ||
#"--disable-executable-stripping" | ||
]; | ||
}; | ||
}; | ||
servant-server = haskellLib.dontCheck haskellPackagesOld.servant-server; # tests fail to compile | ||
}; | ||
}; | ||
|
||
pkgs = | ||
with | ||
{ overlay = _: pkgs: { niv = import sources.niv {}; }; }; | ||
import sources.nixpkgs { overlays = [ overlay ]; inherit config; }; | ||
|
||
in | ||
{ halma-telegram-bot = pkgs.haskell.packages.${compiler}.halma-telegram-bot; | ||
{ halma-telegram-bot = staticHaskellPkgs.halma-telegram-bot; | ||
} |