繁体   English   中英

无法在堆栈项目中使用 nix 构建 hzk(haskell zookeeper)

[英]Can't build hzk (haskell zookeeper) with nix in stack project

我正在尝试将我雇主的大型 haskell 堆栈项目移植到 nix 并且它正在对zookeeper_mt进行吐槽。 在 stack.yaml 中,我启用了 nix 构建并且已经添加了一些像 zlib 这样的 nix 包来解决构建错误,但即使使用 zookeeper_mt,我也得到:

hzk                             > configure
hzk                             > Configuring hzk-2.1.0...
hzk                             > Warning: 'ghc-options: -rtsopts' has no effect for libraries. It should only
hzk                             > be used for executables.
hzk                             > build
hzk                             > Preprocessing library for hzk-2.1.0..
hzk                             > /run/user/1000/stack-4c469d140762b8b0/hzk-2.1.0/CApi.hsc:76:10: fatal error: zookeeper.h: No such file or directory
hzk                             > compilation terminated.
hzk                             > compiling .stack-work/dist/x86_64-linux-nix/Cabal-3.0.1.0/build/Database/Zookeeper/CApi_hsc_make.c failed (exit code 1)
hzk                             > command was: /nix/store/za1rr3fxmgfbfl6nbigqi819m3m7nkgi-gcc-wrapper-9.3.0/bin/cc -c .stack-work/dist/x86_64-linux-nix/Cabal-3.0.1.0/build/Database/Zookeeper/CApi_hsc_make.c -o .stack-work/dist/x86_64-linux-nix/Cabal-3.0.1.0/build/Database/Zookeeper/CApi_hsc_make.o -fuse-ld=gold -D__GLASGOW_HASKELL__=808 -Dlinux_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dlinux_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -I/usr/include/zookeeper -I/nix/store/fn0kwfwaf53638xm37wl94la8dxlbjaq-zlib-1.2.11-dev/include -I/nix/store/in9vak3zphkx9c635iz639iabgrib2fl-postgresql-11.8/include -I/nix/store/qsarmp3rsyvhb7m22xl0fdpsnaf3lv6b-pcre-8.44-dev/include -I/nix/store/87w0n6hix0had2lp58i5rgmrr5dn3ghf-pkg-config-wrapper-0.29.2/include -I/nix/store/v1v3flnwxs3n5lhfrfrs16rcygjzzhmy-zookeeper-3.4.13/include -I/nix/store/grng8b5wmrppx2rmcsqkmjyq23bj1j38-zookeeper_mt-3.4.13/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/include -I/nix/store/pj43dfd5k4zb0ivafkyqpr1blzd616ry-git-2.27.0/include -I/nix/store/za1rr3fxmgfbfl6nbigqi819m3m7nkgi-gcc-wrapper-9.3.0/include -I/nix/store/00lmw45jlcm9ln2vi1rxxdz7cblwk3y6-gmp-6.2.0-dev/include -I/usr/include/zookeeper -I/nix/store/fn0kwfwaf53638xm37wl94la8dxlbjaq-zlib-1.2.11-dev/include -I/nix/store/in9vak3zphkx9c635iz639iabgrib2fl-postgresql-11.8/include -I/nix/store/qsarmp3rsyvhb7m22xl0fdpsnaf3lv6b-pcre-8.44-dev/include -I/nix/store/87w0n6hix0had2lp58i5rgmrr5dn3ghf-pkg-config-wrapper-0.29.2/include -I/nix/store/v1v3flnwxs3n5lhfrfrs16rcygjzzhmy-zookeeper-3.4.13/include -I/nix/store/grng8b5wmrppx2rmcsqkmjyq23bj1j38-zookeeper_mt-3.4.13/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/include -I/nix/store/pj43dfd5k4zb0ivafkyqpr1blzd616ry-git-2.27.0/include -I/nix/store/za1rr3fxmgfbfl6nbigqi819m3m7nkgi-gcc-wrapper-9.3.0/include -I/nix/store/00lmw45jlcm9ln2vi1rxxdz7cblwk3y6-gmp-6.2.0-dev/include -I.stack-work/dist/x86_64-linux-nix/Cabal-3.0.1.0/build/autogen -I.stack-work/dist/x86_64-linux-nix/Cabal-3.0.1.0/build/global-autogen -include .stack-work/dist/x86_64-linux-nix/Cabal-3.0.1.0/build/autogen/cabal_macros.h -I/nix/store/fn0kwfwaf53638xm37wl94la8dxlbjaq-zlib-1.2.11-dev/include -I/nix/store/in9vak3zphkx9c635iz639iabgrib2fl-postgresql-11.8/include -I/nix/store/qsarmp3rsyvhb7m22xl0fdpsnaf3lv6b-pcre-8.44-dev/include -I/nix/store/87w0n6hix0had2lp58i5rgmrr5dn3ghf-pkg-config-wrapper-0.29.2/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/include -I/nix/store/pj43dfd5k4zb0ivafkyqpr1blzd616ry-git-2.27.0/include -I/nix/store/za1rr3fxmgfbfl6nbigqi819m3m7nkgi-gcc-wrapper-9.3.0/include -I/nix/store/00lmw45jlcm9ln2vi1rxxdz7cblwk3y6-gmp-6.2.0-dev/include -I/nix/store/fn0kwfwaf53638xm37wl94la8dxlbjaq-zlib-1.2.11-dev/include -I/nix/store/in9vak3zphkx9c635iz639iabgrib2fl-postgresql-11.8/include -I/nix/store/qsarmp3rsyvhb7m22xl0fdpsnaf3lv6b-pcre-8.44-dev/include -I/nix/store/87w0n6hix0had2lp58i5rgmrr5dn3ghf-pkg-config-wrapper-0.29.2/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/include -I/nix/store/pj43dfd5k4zb0ivafkyqpr1blzd616ry-git-2.27.0/include -I/nix/store/za1rr3fxmgfbfl6nbigqi819m3m7nkgi-gcc-wrapper-9.3.0/include -I/nix/store/00lmw45jlcm9ln2vi1rxxdz7cblwk3y6-gmp-6.2.0-dev/include -I/home/ad/.stack/snapshots/x86_64-linux-nix/dd8fbb08ccfb9e77e9ffdb798576edd8f70b7edca799105b5bc2de70a44535a1/8.8.3/lib/x86_64-linux-ghc-8.8.3/vector-0.12.1.2-AWRYcz9jfa25Avs2q9Jg9V/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/lib/ghc-8.8.3/time-1.9.3/include -I/nix/store/fn0kwfwaf53638xm37wl94la8dxlbjaq-zlib-1.2.11-dev/include -I/nix/store/in9vak3zphkx9c635iz639iabgrib2fl-postgresql-11.8/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/include -I/nix/store/pj43dfd5k4zb0ivafkyqpr1blzd616ry-git-2.27.0/include -I/nix/store/za1rr3fxmgfbfl6nbigqi819m3m7nkgi-gcc-wrapper-9.3.0/include -I/nix/store/00lmw45jlcm9ln2vi1rxxdz7cblwk3y6-gmp-6.2.0-dev/include -I/home/ad/.stack/snapshots/x86_64-linux-nix/dd8fbb08ccfb9e77e9ffdb798576edd8f70b7edca799105b5bc2de70a44535a1/8.8.3/lib/x86_64-linux-ghc-8.8.3/primitive-0.7.0.1-CN4ea3Jrhra6yENuqrDg51/include -I/nix/store/fn0kwfwaf53638xm37wl94la8dxlbjaq-zlib-1.2.11-dev/include -I/nix/store/in9vak3zphkx9c635iz639iabgrib2fl-postgresql-11.8/include -I/nix/store/qsarmp3rsyvhb7m22xl0fdpsnaf3lv6b-pcre-8.44-dev/include -I/nix/store/87w0n6hix0had2lp58i5rgmrr5dn3ghf-pkg-config-wrapper-0.29.2/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/include -I/nix/store/pj43dfd5k4zb0ivafkyqpr1blzd616ry-git-2.27.0/include -I/nix/store/za1rr3fxmgfbfl6nbigqi819m3m7nkgi-gcc-wrapper-9.3.0/include -I/nix/store/00lmw45jlcm9ln2vi1rxxdz7cblwk3y6-gmp-6.2.0-dev/include -I/nix/store/fn0kwfwaf53638xm37wl94la8dxlbjaq-zlib-1.2.11-dev/include -I/nix/store/in9vak3zphkx9c635iz639iabgrib2fl-postgresql-11.8/include -I/nix/store/qsarmp3rsyvhb7m22xl0fdpsnaf3lv6b-pcre-8.44-dev/include -I/nix/store/87w0n6hix0had2lp58i5rgmrr5dn3ghf-pkg-config-wrapper-0.29.2/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/include -I/nix/store/pj43dfd5k4zb0ivafkyqpr1blzd616ry-git-2.27.0/include -I/nix/store/za1rr3fxmgfbfl6nbigqi819m3m7nkgi-gcc-wrapper-9.3.0/include -I/nix/store/00lmw45jlcm9ln2vi1rxxdz7cblwk3y6-gmp-6.2.0-dev/include -I/nix/store/fn0kwfwaf53638xm37wl94la8dxlbjaq-zlib-1.2.11-dev/include -I/nix/store/in9vak3zphkx9c635iz639iabgrib2fl-postgresql-11.8/include -I/nix/store/qsarmp3rsyvhb7m22xl0fdpsnaf3lv6b-pcre-8.44-dev/include -I/nix/store/87w0n6hix0had2lp58i5rgmrr5dn3ghf-pkg-config-wrapper-0.29.2/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/include -I/nix/store/pj43dfd5k4zb0ivafkyqpr1blzd616ry-git-2.27.0/include -I/nix/store/za1rr3fxmgfbfl6nbigqi819m3m7nkgi-gcc-wrapper-9.3.0/include -I/nix/store/00lmw45jlcm9ln2vi1rxxdz7cblwk3y6-gmp-6.2.0-dev/include -I/nix/store/fn0kwfwaf53638xm37wl94la8dxlbjaq-zlib-1.2.11-dev/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/include -I/nix/store/pj43dfd5k4zb0ivafkyqpr1blzd616ry-git-2.27.0/include -I/nix/store/za1rr3fxmgfbfl6nbigqi819m3m7nkgi-gcc-wrapper-9.3.0/include -I/nix/store/00lmw45jlcm9ln2vi1rxxdz7cblwk3y6-gmp-6.2.0-dev/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/lib/ghc-8.8.3/bytestring-0.10.10.0/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/include -I/nix/store/pj43dfd5k4zb0ivafkyqpr1blzd616ry-git-2.27.0/include -I/nix/store/za1rr3fxmgfbfl6nbigqi819m3m7nkgi-gcc-wrapper-9.3.0/include -I/nix/store/00lmw45jlcm9ln2vi1rxxdz7cblwk3y6-gmp-6.2.0-dev/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/lib/ghc-8.8.3/base-4.13.0.0/include -I/nix/store/00lmw45jlcm9ln2vi1rxxdz7cblwk3y6-gmp-6.2.0-dev/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/lib/ghc-8.8.3/integer-gmp-1.0.2.0/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/lib/ghc-8.8.3/include -I/nix/store/l9xqrgxn4z795jivmrmjyanlb6jjq66k-libffi-3.3-dev/include -I/nix/store/qqra09ff0q8vwqicjs20fn1rvn00k6fy-ghc-8.8.3/lib/ghc-8.8.3/include/

我可以在nix-shell -p zookeeper_mt中看到 zookeeper.h 以${zookeeper}/include/zookeeper/结尾,但这就像 ubuntu package 也有 /usr/include 的这个 zookeeper 子目录,以及在安装了 ubuntu package 的非 nix 堆栈构建中很好。

我在该错误消息中看到-I/nix/store/grng8b5wmrppx2rmcsqkmjyq23bj1j38-zookeeper_mt-3.4.13/include没有额外的/zookeeper但我不确定系统的哪一部分对此负责或如何修复它因为我'我对尼克斯很陌生。 是nix包的错,堆栈的错还是别的什么?

hzk.cabal有这样的行

  include-dirs:        /usr/include/zookeeper

这对于符合 FHS 的系统来说是一个很好的帮助,只要系统分发包含 zookeeper 库。 /usr/local/opt/*中的本地安装将导致相同的问题。

Nixpkgs 像这样解决它https://github.com/NixOS/nixpkgs/blob/a8a0dfa047d9a96f832ff2be30d004ad5544bd7e/pkgs/development/haskell-modules/configuration-nix.nix#L1017-L12

为了让它在堆栈中工作,我们可以使用它的 nix-shell 集成。

stack.yaml

nix:
  packages: [] # Note that specifying both packages: and a shell-file: results in an error.
  shell-file: stack-shell.nix

stack-shell.nix

{ghc}:
let pkgs = import <nixpkgs> {};
# (side note)
# If you're pinning nixpkgs, You should probably set
# NIX_PATH=nixpkgs=... in your real `shell.nix`
# because that's where stack gets its ghc.
in
pkgs.haskell.lib.buildStackProject {
  inherit ghc;
  name = "myEnv";
  buildInputs = [ pkgs.zookeeper_mt ];
  shellHook = ''
    NIX_CFLAGS_COMPILE="-I ${pkgs.zookeeper_mt}/include/zookeeper $NIX_CFLAGS_COMPILE"
  '';
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM