nh2 / static-haskell-nix

easily build most Haskell programs into fully static Linux executables
388 stars 36 forks source link

Failed to build cabal2nix #9

Open NCrashed opened 5 years ago

NCrashed commented 5 years ago

I tried to use callCabal2Nix and got the following linking errors.

../lib/.libs/libsasl2.a(dlopen.o):(.data.rel+0x10): undefined reference to `gssapiv2_server_plug_init'
../lib/.libs/libsasl2.a(dlopen.o):(.data.rel+0x28): undefined reference to `gssapiv2_client_plug_init'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:512: dbconverter-2] Error 1
make[2]: Leaving directory '/tmp/nix-build-cyrus-sasl-2.1.26.drv-0/cyrus-sasl-2.1.26/utils'
make[1]: *** [Makefile:457: all-recursive] Error 1
make[1]: Leaving directory '/tmp/nix-build-cyrus-sasl-2.1.26.drv-0/cyrus-sasl-2.1.26'
make: *** [Makefile:364: all] Error 2
builder for '/nix/store/xfayfd1zx790avva7c9d6r7q4ahj15vr-cyrus-sasl-2.1.26.drv' failed with exit code 2
cannot build derivation '/nix/store/16l4brwp3a094w71da4zk8qd4yi1xdzn-openldap-2.4.46.drv': 1 dependencies couldn't be built
building '/nix/store/zgs53hrw6qlyb32wqraqg8rcfcmil79k-python3-3.6.6.drv'...
cannot build derivation '/nix/store/h2c9gbs6fb5fnscyvwqwlwv3jcb4sncw-apr-util-1.6.1.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/xawqfkgq701fhza101nmfb89iwx1w9c8-subversion-1.10.2.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/vlabs20b2nhwqidqbfcwhb8lzd4sk7hf-nix-prefetch-svn.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/46vwrr2062wfllqrxi2yh6lc2j46w2w0-nix-prefetch-scripts.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/k27dlmgaz9ys2raq91pd7sz4syalhra1-cabal2nix-2.11.1.drv': 1 dependencies couldn't be built

nixpkgs version:

import ((import <nixpkgs> {}).fetchFromGitHub {
  owner = "NixOS";
  repo = "nixpkgs-channels";
  rev = "f753852e11d72c05cb74d1058ea8b7f6d5dd4748";
  sha256  = "0xvjrsi3j4hzq9cdzqpccxnl9gqc8f5y59lkgqs2s2dkng35zv74";
})
nh2 commented 5 years ago

This works for me on latest master commit 9a3e919a91e98a66e749a8aa9bdd2c353f210e57 with:

NIX_PATH=nixpkgs=nixpkgs nix-build --no-link survey/default.nix -A haskellPackages.cabal2nix.

Please confirm whether it still doesn't work for you.

cdepillabout commented 5 years ago

@nh2 I was trying to use callHackageDirect (which uses callCabal2nix, which uses the cabal2nix binary), and I got an error about not being able to build cabal2nix.

Here's my derivation:

let
  survey = import ./survey { normalPkgs = import ./nixpkgs {}; };

  myHaskellPackages =
    survey.haskellPackages.override {
      overrides = self: super: {
        termonad =
          self.callHackageDirect
            {
              pkg = "termonad";
              ver = "2.0.0.0";
              sha256 = "1xs15186zk0z4crcrflk0x4nch858i0rgr60zd89f8l225gjwfrq";
            }
            {};
      };
    };
in

myHaskellPackages.termonad

Here's some of the output I get when running nix-build:

$ nix-build ./build-termonad.nix
...
configure: serf library configuration via prefix
checking serf.h usability... yes
checking serf.h presence... yes
checking for serf.h... yes
checking for serf_context_create in -lserf-1... no
checking was serf enabled... no

An appropriate version of serf could not be found, so libsvn_ra_serf
will not be built.  If you want to build libsvn_ra_serf, please
install serf 1.3.4 or newer.

configure: error: Serf was explicitly enabled but an appropriate version was not found.
builder for '/nix/store/knfk0bsc00wfl9fbmr3zai6dwbhw1jzm-subversion-1.12.0.drv' failed with exit code 1
cannot build derivation '/nix/store/sn7g6bmx35b6wp01ciq5kbv6hsvg3bl4-nix-prefetch-svn.drv': 1 dependencies couldn't be built
building '/nix/store/bhy725wcsysp8i6l5narryfxp2z2x0d8-openssh-7.9p1.drv'...
cannot build derivation '/nix/store/y2hkqc1hh84v3d4r2f8fk09j5ani7v59-nix-prefetch-scripts.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/8hsdal5ck86907f0qz2aksgb0wcl4i6c-cabal2nix-2.14.4.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/0bgwq7ais1sxkiclvyj9zwcgqrf6fka8-cabal2nix-termonad.drv': 1 dependencies couldn't be built
error: build of '/nix/store/0bgwq7ais1sxkiclvyj9zwcgqrf6fka8-cabal2nix-termonad.drv' failed

It appears that cabal2nix depends on nix-prefetch-scripts, and nix-prefetch-svn depends on subversion, which is having problems.

However, I don't understand why this is happening, given that cabal2nix is able to be built fine:

let
  survey = import ./survey { normalPkgs = import ./nixpkgs {}; };
in
survey.haskellPackages.cabal2nix

On the console:

$ nix-build build-cabal2nix.nix
...
/nix/store/az3qzvnadamk4cqiqh50xsqa110k16rl-cabal2nix-2.14.4

Maybe there is some overriding of dependencies that is not happening correctly for the underlying cabal2nix used in callCabal2nix.


This is on the current HEAD of the static-haskell-nix master branch (commit 761f34bb4b09dd5838f82782c5e56ebfac4039fb).