tweag / opam-nix

Turn opam-based OCaml projects into Nix derivations
MIT License
111 stars 33 forks source link

bug: failed to build package cf #86

Closed jetjinser closed 6 months ago

jetjinser commented 6 months ago

Describe the bug The cf is a OCaml bindings to macOS CoreFoundation that is depends on ctypes.

When I try to build a package that depends on cf, I get a lot of errors like:

`nix log /nix/store/sc20b74lvbin9qns41fxggw5fmwwbrmn-cf-0.5.0.drv` @nix { "action": "setPhase", "phase": "unpackPhase" } unpacking sources unpacking source archive /nix/store/b1rbpaikwf7mpcgqihpway4gpdfyi393-cf-lwt-0.5.0.tbz source root is cf-lwt-0.5.0 setting SOURCE_DATE_EPOCH to timestamp 1648823425 of file cf-lwt-0.5.0/lwt/dune @nix { "action": "setPhase", "phase": "patchPhase" } patching sources @nix { "action": "setPhase", "phase": "configurePhase" } configuring patching script interpreter paths in . @nix { "action": "setPhase", "phase": "buildPhase" } building Done: 31% (18/58, 40 left) (jobs: 0)^M ^MFile "lib_gen/dune", line 27, characters 0-185: 27 | (rule 28 | (targets detect.exe) 29 | (enabled_if 30 | (= %{system} macosx)) 31 | (deps 32 | detect.c 33 | (package ctypes)) 34 | (action 35 | (run %{cc} -I %{ocaml_where} -I %{lib:ctypes:} -o %{targets} %{deps}))) Error: File unavailable: /nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/doc/ctypes/CHANGES.md Done: 31% (18/58, 40 left) (jobs: 0)^M ^MFile "lib_gen/dune", line 27, characters 0-185: 27 | (rule 28 | (targets detect.exe) 29 | (enabled_if 30 | (= %{system} macosx)) 31 | (deps 32 | detect.c 33 | (package ctypes)) 34 | (action 35 | (run %{cc} -I %{ocaml_where} -I %{lib:ctypes:} -o %{targets} %{deps}))) Error: File unavailable: /nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/doc/ctypes/LICENSE ... repeated n times similar error ... Done: 31% (18/58, 40 left) (jobs: 0)^M ^MFile "lib_gen/dune", line 27, characters 0-185: 27 | (rule 28 | (targets detect.exe) 29 | (enabled_if 30 | (= %{system} macosx)) 31 | (deps 32 | detect.c 33 | (package ctypes)) 34 | (action 35 | (run %{cc} -I %{ocaml_where} -I %{lib:ctypes:} -o %{targets} %{deps}))) Error: File unavailable: /nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/lib/stublibs/dllctypes_stubs.so Done: 31% (18/58, 40 left) (jobs: 0)^M ^MDone: 33% (35/105, 70 left, 221 failed) (jobs: 5)^M > /nix/store/j645h2bcqjww615dfkka4v4q1nyyy5m1-cctools-port-973.0.1/libexec/as/x86_64/as: this system assembler is deprecated. Please migrate to> Done: 33% (35/105, 70 left, 221 failed) (jobs: 5)^M ^MDone: 45% (51/113, 62 left, 221 failed)> /nix/store/j645h2bcqjww615dfkka4v4q1nyyy5m1-cctools-port-973.0.1/libexec/as/x86_64/as: this system assembler is deprecated. Please migrate to> Done: 45% (51/113, 62 left, 221 failed) (jobs: 3)^M ^M(cd _build/default && /nix/store/b7pfan> /nix/store/j645h2bcqjww615dfkka4v4q1nyyy5m1-cctools-port-973.0.1/libexec/as/x86_64/as: this system assembler is deprecated. Please migrate to> Done: 45% (51/113, 62 left, 221 failed) (jobs: 3)^M ^M(cd _build/default && /nix/store/b7pfan> /nix/store/j645h2bcqjww615dfkka4v4q1nyyy5m1-cctools-port-973.0.1/libexec/as/x86_64/as: this system assembler is deprecated. Please migrate to> Done: 45% (51/113, 62 left, 221 failed) (jobs: 3)^M ^MDone: 49% (56/113, 57 left, 221 failed)> clang-11: warning: argument unused during compilation: '-fno-strict-overflow' [-Wunused-command-line-argument] Done: 49% (56/113, 57 left, 221 failed) (jobs: 2)^M ^MDone: 50% (57/113, 56 left, 221 failed)> /nix/store/j645h2bcqjww615dfkka4v4q1nyyy5m1-cctools-port-973.0.1/libexec/as/x86_64/as: this system assembler is deprecated. Please migrate to> Done: 50% (57/113, 56 left, 221 failed) (jobs: 1)^M

The path /nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/doc/ctypes/CHANGES.md does not exist, I think the correct path is:

/nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0
├── lib
│  └── ocaml
├── nix-support
│  ├── is-opam-nix-package
│  ├── propagated-build-inputs
│  ├── propagated-native-build-inputs
│  └── setup-hook
└── share
   ├── doc
   └── man

And the content of nix-support/setup-hook is:

opam__ctypes__bin="${opam__ctypes__bin-/nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/bin}"
opam__ctypes__build="${opam__ctypes__build-null}"
opam__ctypes__build_id="${opam__ctypes__build_id-null}"
opam__ctypes__dev="${opam__ctypes__dev-false}"
opam__ctypes__doc="${opam__ctypes__doc-/nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/share/doc}"
opam__ctypes__enable="${opam__ctypes__enable-enable}"
opam__ctypes__etc="${opam__ctypes__etc-/nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/etc}"
opam__ctypes__hash="${opam__ctypes__hash-null}"
opam__ctypes__installed="${opam__ctypes__installed-true}"
opam__ctypes__lib="${opam__ctypes__lib-/nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/lib/ocaml/5.1.1/site-lib}"
opam__ctypes__man="${opam__ctypes__man-/nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/share/man}"
opam__ctypes__name="${opam__ctypes__name-ctypes}"
opam__ctypes__opamfile="${opam__ctypes__opamfile-null}"
opam__ctypes__pinned="${opam__ctypes__pinned-false}"
opam__ctypes__prefix="${opam__ctypes__prefix-/nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0}"
opam__ctypes__sbin="${opam__ctypes__sbin-/nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/bin}"
opam__ctypes__share="${opam__ctypes__share-/nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/share}"
opam__ctypes__version="${opam__ctypes__version-0.22.0}"
export OCAMLPATH=${OCAMLPATH-}${OCAMLPATH:+:}/nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/lib/ocaml/5.1.1/site-lib
export CAML_LD_LIBRARY_PATH=${CAML_LD_LIBRARY_PATH-}${CAML_LD_LIBRARY_PATH:+:}/nix/store/xb81cf7qgnyvsyvp9nfj15dmqchc24gk-ctypes-0.22.0/lib/ocaml/5.1.1/site-lib/stublibs

To Reproduce

nix build 'github:tweag/opam-nix#cf."0.5.0"'

OR

I made a minimal example that depends on cf: with_cf.

nix build

or only cf:

nix build .#cf

Expected behavior build successfully

Environment

Additional context Add any other context about the problem here.

jetjinser commented 6 months ago

This should be a problem with the dune file of cf...

diff --git a/lib_gen/dune b/lib_gen/dune
index 83883f0..85faa46 100644
--- a/lib_gen/dune
+++ b/lib_gen/dune
@@ -28,9 +28,7 @@
  (targets detect.exe)
  (enabled_if
   (= %{system} macosx))
- (deps
-  detect.c
-  (package ctypes))
+ (deps detect.c)
  (action
   (run %{cc} -I %{ocaml_where} -I %{lib:ctypes:} -o %{targets} %{deps})))