Giter VIP home page Giter VIP logo

Comments (6)

nomeata avatar nomeata commented on September 25, 2024

What also doesn’t work: Removing time (and other GHC-provided packages) from plan.nix: aeson seems to depend on it.

from haskell.nix.

nomeata avatar nomeata commented on September 25, 2024

Maybe https://ghc.haskell.org/trac/ghc/ticket/14889, which has a patch against hsc2hs?
Maybe this (or some other patch) applied when building within ghc, but it is not used when building time exernally?

from haskell.nix.

nomeata avatar nomeata commented on September 25, 2024

I am experimenting with

diff --git a/builder/comp-builder.nix b/builder/comp-builder.nix
index 87cd54f..7cd0c2a 100644
--- a/builder/comp-builder.nix
+++ b/builder/comp-builder.nix
@@ -169,7 +169,8 @@ let
       ++ lib.optional (deadCodeElimination && stdenv.hostPlatform.isLinux) "--enable-split-sections"
       ++ lib.optional (static) "--enable-static"
       ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) (
-        map (arg: "--hsc2hs-option=" + arg) ["--cross-compile" "--via-asm"]
+        [ "--hsc2hs-option=--cross-compile" ]
+        ++ lib.optional (stdenv.hostPlatform.isWindows) "--hsc2hs-option=--via-asm"
         ++ lib.optional (package.buildType == "Configure") "--configure-option=--host=${stdenv.hostPlatform.config}" )
       ++ component.configureFlags
   );

under the somewhat random assumption that musl cross-compilation isn’t cross-compilingishly enough to need --via-asm, and it seems I made it past building time.

from haskell.nix.

nomeata avatar nomeata commented on September 25, 2024

This looks good. With this change, and the following hack(?) in the output of cabal-to-nix:

diff --git a/nix/tttool.nix b/nix/tttool.nix
index 678f1c9..9856027 100644
--- a/nix/tttool.nix
+++ b/nix/tttool.nix
@@ -31,6 +31,13 @@
     components = {
       exes = {
         "tttool" = {
+          configureFlags = pkgs.lib.optionals (pkgs.hostPlatform.isMusl) [
+             "--ghc-option=-static"
+             "--ghc-option=-optl=-static"
+             "--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib"
+             "--extra-lib-dirs=${pkgs.zlib.static}/lib"
+          ];
           depends = (([
             (hsPkgs.base)
             (hsPkgs.binary)

(to simulate --enable-executable-dynamic which was added to cabal only recently at haskell/cabal#5446 by nh2) it seems I can almost link it. I am now stuck because nixpkgs does not seem to provide a static version of libtinfo, which I have reported already at
nh2/static-haskell-nix#14

from haskell.nix.

nomeata avatar nomeata commented on September 25, 2024

Success!

After

~/projekte/tip-toi-reveng $ git diff nix/plan.nix 
diff --git a/nix/plan.nix b/nix/plan.nix
index 4b81166..147ce08 100644
--- a/nix/plan.nix
+++ b/nix/plan.nix
@@ -8,6 +8,7 @@ hackage:
       "polyparse".revision = (((hackage."polyparse")."1.12").revisions).default;
       "old-time".revision = (((hackage."old-time")."1.1.0.3").revisions).default;
       "haskeline".revision = (((hackage."haskeline")."0.7.4.2").revisions).default;
+      "haskeline".flags.terminfo = false;
       "split".revision = (((hackage."split")."0.2.3.3").revisions).default;
       "stm".revision = (((hackage."stm")."2.4.5.1").revisions).default;
       "HTF".revision = (((hackage."HTF")."0.13.2.5").revisions).default;

I can build a static version of the program:

~/projekte/tip-toi-reveng $ file $(nix-build -A static-exe nix)/bin/tttool
/nix/store/sn0p4q19l3gs88bb2vd2bcdc3jm4j27y-tttool-1.8-exe-tttool-x86_64-unknown-linux-musl/bin/tttool: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped

and my default.nix ends in this pleasing derivation:

in
 { linux-exe = tttool-exe {};
   windows-exe = tttool-exe { crossSystem = localLib.systems.examples.mingwW64;};
   static-exe = tttool-exe { crossSystem = localLib.systems.examples.musl64;};
 }

I’ll leave this open for you to assess the fix that applied to builder/comp-builder.nix.

from haskell.nix.

angerman avatar angerman commented on September 25, 2024

@nomeata you can put all those customizations into your pkgs.nix at

https://github.com/entropia/tip-toi-reveng/blob/3183b6ff9be55701de78e71482ba5d6820300019/nix/pkgs.nix#L32

just add the following module:

{
   packages.haskeline.flags.terminfo = false;
   packages.tttool.configureFlags = pkgs.lib.optionals (pkgs.hostPlatform.isMusl) [
             "--ghc-option=-static"
             "--ghc-option=-optl=-static"
             "--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib"
             "--extra-lib-dirs=${pkgs.zlib.static}/lib"
          ];
}

regarding the --via-asm; I thought that was fixed in a recent hsc2hs, but the change would work. I'll add something to input-output-hk/haskell.nix. Thanks!

from haskell.nix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.