Open joprice opened 3 years ago
Hmm, probably because of:
WARN: opam var conf-llvm:config not found...
WARN: opam var conf-cmake:cmd not found...
The manual says:
Extra variables can be defined by any package at installation time, using a
.config file with a variables {} field.
Which just seems really hard to implement, so I didn't. This is the first use case I've seen that actually depends on it.
I don't know what that variable ends up being in a real opam, you might need to override the installPhase
to pass in those values manually.
How do I get access to opam in the installPhase to set them? If I can't access it, maybe I can just modify the opam file by substituting %{conf-llvm:config}% with the path to conf-llvm and the other to cmake, but I'm not sure how to get a reference to the opam file.
opam-version: "2.0"
maintainer: "Kate <kit.ty.kate@disroot.org>"
authors: [
"whitequark <whitequark@whitequark.org>"
"The LLVM team"
]
license: "MIT"
doc: "http://llvm.moe/ocaml"
bug-reports: "http://llvm.org/bugs/"
dev-repo: "git+http://llvm.org/git/llvm.git"
homepage: "http://llvm.moe"
install: [
["bash" "-ex" "install.sh" "%{conf-llvm:config}%" lib "%{conf-cmake:cmd}%" make]
]
depends: [
"ocaml" {>= "4.00.0"}
"ctypes" {>= "0.4"}
"ounit" {with-test}
"ocamlfind" {build}
"conf-llvm" {build & = version}
"conf-python-2-7" {build}
"conf-cmake" {build}
]
patches: [
"fix-shared.patch"
]
synopsis: "The OCaml bindings distributed with LLVM"
description: "Note: LLVM should be installed first."
extra-files: [
["link-META.patch" "md5=ef4ebb8706be2ed402f31fc351d7dc75"]
["install.sh" "md5=76fb00c644110c73d04b15a2afb1aaf3"]
["fix-shared.patch" "md5=dce86b1db352332968ceb6d042b408a8"]
["META.patch" "md5=1d0af08bab7a0f831f68849b6556e414"]
]
url {
src: "https://github.com/llvm/llvm-project/releases/download/llvmorg-11.1.0/llvm-11.1.0.src.tar.xz"
checksum: "sha256=ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5"
}```
How do I get access to opam in the installPhase to set them
You wouldn't be able to access opam, opam2nix never actually uses opam. I was thinking you could do this:
{ pkgs, selection }: {
llvm = super: super.overrideAttrs (attrs: {
installPhase = ''
bash -ex install.sh "${selection.conf-llvm}/config" lib "${selection.conf-cmake}/cmd" make
'';
});
}
...but now that I write it out explicitly, that's not right because those are file paths.
You might have to scout around in the built conf-llvm
derivation, but somewhere there should be a .config
file. If you can find that, you can possibly do some hacky sed / python to pull out the values you need.
If that file doesn't end up installed, it could well be an overlayed file from the opam
repository itself (i.e. not in $out
, nor in src
). That would be... inconvenient. If that's the case, it might make sense for opam2nix to add explicit support for this kind of thing, perhaps by at least processing that file and spitting out a opam-config
directory (in $out
) with a file for each key, containing the evaluated value. I don't know how difficult this would be to implement (it depends what you need to evaluate those variables)
I was able to get it a bit further along with this:
installPhase = ''
bash -ex install.sh "${pkgs.llvmPackages_11.llvm}/bin/llvm-config" lib "${pkgs.cmake}/bin/cmake" make
'';
But it then ends up failing with the following error
+ /nix/store/zdqiff42s60mc4cqgfwm6kalc449b5xx-cmake-3.19.7/bin/cmake -P bindings/ocaml/cmake_install.cmake
-- Install configuration: "Release"
CMake Error at bindings/ocaml/llvm/cmake_install.cmake:41 (file):
file cannot create directory: /var/empty/local/lib/llvm. Maybe need
administrative privileges.
Call Stack (most recent call first):
bindings/ocaml/cmake_install.cmake:42 (include)
/var/empty/local/lib/llvm
<- that looks pretty suss, I'm not sure it has much to do with opam2nix at this point :disappointed: . I don't know what the llvm
opam package is, can you just substitute it for nixpkgs own llvm
? Or does it have particular ocaml smarts?
It's an ocaml module for llvm codegen https://llvm.moe/ocaml/index.html, https://github.com/llvm/llvm-project/tree/main/llvm/bindings/ocaml.
I was able to get it working for now by overriding llvm and ctypes. Ctypes had to be overridden due to a bincompat issue.
override = {}: {
llvm = super: ocaml-ng.ocamlPackages_4_12.llvm;
ctypes = super: ocaml-ng.ocamlPackages_4_12.ctypes;
...
I can't seem to figure out how to provide llvm_config and cmake to llvm. I tried using overrides and adding them to buildInputs, but that doesn't help.
The version in nix does work https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/ocaml-modules/llvm/default.nix, but I think it works differently because it doesn't rely on conf-llvm.