timbertson / opam2nix

Generate nix expressions from opam packages
MIT License
93 stars 28 forks source link

Is it meant to also work just with Nix (not NixOS)? #43

Closed Coda-Coda closed 3 years ago

Coda-Coda commented 3 years ago

Is opam2nix meant to work with the nix package manager installed on non-NixOS distros?

I am debugging a complex(ish) derivation that is failing on Ubuntu and Arch but works fine on NixOS and am wondering if this is the culprit. It's this shell.nix.

I see errors like:

fatal error: parsePL.hpp: No such file or directory
timbertson commented 3 years ago

I don't use NixOS either, so yep it's definitely supposed to work outside.

I can't access that link, my guess is it might just be a bug with a particular package. If you can share the shell.nix and the full log, I can take a look and see if there's something strange with that package.

Coda-Coda commented 3 years ago

Ok that's good to hear, thanks. The issue is probably related to the referenced .nix files in https://github.com/Coda-Coda/archetype-lang/ which is my attempt to get the opam package archetype working via opam2nix.

Here are the logs, they are quite long, I imagine the last section is the most relevant.

Also, if I've gone about this the wrong way please feel free to suggest an alternate way. My only goal is to get archetype working using Nix.

Thanks for the help!

Here's the shell.nix (sorry it was in a private repo).


with import <nixpkgs> {};
let
  extensions = (with pkgs.vscode-extensions; [

      ])
      ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [{
      name = "archetype";
      publisher = "edukera";
      version = "0.34.0";
      sha256 = "573bb2405c2bb3557666de9a9732cf94ccbee28c518629b8879aa0ab3f57747e";}]
      ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [{
      name = "gitlens";
      publisher = "eamodio";
      version = "10.2.2";
      sha256 = "ab22b88129b348fb0412615a8988d23ac0aff0be5c64fe8d34996199fe35d701";}]
      ;
  vscode-with-extensions = pkgs.vscode-with-extensions.override {
      vscodeExtensions = extensions;
    };
in
let archetypeSrc = ( pkgs.fetchFromGitHub {
    owner  = "Coda-Coda";
    repo   = "archetype-lang";
    rev    = "b3b41d6da3581e915f4aecf4f9395e0d105b4dfa";
    sha256 = "0y7mx9d031177wj053rhny1bpm8rxnjzg03zz6821ws4hz2qgrx0"; } );
in
stdenv.mkDerivation {

  name = "archetype-env";

  buildInputs =
    [
        git
        vscode-with-extensions
        (import ./why3)
        coq_8_9
        alt-ergo
        cvc3
        cvc4
        z3
        (import "${archetypeSrc}")
    ]
    ;
  postBuild = ''
    echo OK
    why3 config --detect-provers
  '';

}
Coda-Coda commented 3 years ago

In case it is relevant, here is the referenced why3 import: why3.zip

timbertson commented 3 years ago

Aha, looks the same as https://github.com/timbertson/opam2nix/issues/31#issuecomment-683225868. This is because you are using a version of opam2nix before #35 was merged, alongside a recent version of nixpkgs (after the ocamlgraph arguments changed).

I've just tagged the head of the v1 branch as version-1.2.0, give that a try :crossed_fingers:

timbertson commented 3 years ago

Oh er... sorry. The above was the error I got while trying to reproduce, which means I'm on a newer version of nixpkgs than you.

The build log shows a backtrace of:

builder for '/nix/store/caakrmqy90qfh8gaf4k5n90m95v12gq7-cvc3-2.4.1.drv' failed with exit code 2
error: build of '/nix/store/4nvdir1hgksyp8az26yizsh22b0x3xbg-vscode-with-extensions-1.48.2.drv', '/nix/store/66ljz3vnvyx2vnl5jpgpss10h67m7f0p-archetype-development.drv', '/nix/store/bhdxnh1bx2cix4gakd4lzqc56wqqpmqw-why3-1.3.2.drv', '/nix/store/caakrmqy90qfh8gaf4k5n90m95v12gq7-cvc3-2.4.1.drv', '/nix/store/lgm44196b0rafawlg0haa2dcn7gbn07n-ocaml4.10.0-alt-ergo-2.3.3.drv' failed

That doesn't look like it's opam / oaml related, unless cvc3 is coming from opam?

Coda-Coda commented 3 years ago

Hi @timbertson, thanks for the reply - sorry for my delayed response. You're right that cvc3 is causing an error, however even when I change the shell.nix to only involve the opam archetype package I still get an error.

I'm now using this shell.nix:

with import <nixpkgs> {};

let archetypeSrc = ( pkgs.fetchFromGitHub {
    owner  = "Coda-Coda";
    repo   = "archetype-lang";
    rev    = "b3b41d6da3581e915f4aecf4f9395e0d105b4dfa";
    sha256 = "0y7mx9d031177wj053rhny1bpm8rxnjzg03zz6821ws4hz2qgrx0"; } );
in
stdenv.mkDerivation {

  name = "archetype-env";

  buildInputs =
    [
        (import "${archetypeSrc}")
    ]
    ;

}

Here's the full log, I think the error is stemming from cp: cannot stat 'dgraph/dgraph.opt': No such file or directory, while installing ocamlgraph-1.8.8.

timbertson commented 3 years ago

OK, yep so now you're running into https://github.com/timbertson/opam2nix/issues/31#issuecomment-683225868 as well.

If you update https://github.com/Coda-Coda/archetype-lang/blob/master/opam2nix.nix to reference version-1.2.0 (and then update your import of the archetype repo), that should fix the dgraph error.

Coda-Coda commented 3 years ago

Thanks! yes that works... for Ubuntu. But not macOS. I'm now getting the error I mentioned here: https://github.com/timbertson/opam2nix/issues/38 but I can't go back to 1.1.0 or 1.1.1 because I need 1.2.0 to fix this issue.

error: anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixpkgs/pkgs/development/ocaml-modules/ocamlgraph/default.nix:1:1 called with unexpected argument 'gtkSupport', at /nix/store/h76bs0f6bv8d2c7q19axd30b8f58jan8-nixpkgs-20.03pre211462.0c960262d15/nixpkgs/lib/customisation.nix:69:16

Here's the full log, currently using the unstable channel, though I did try a bit with other channels without success. macos_archetype_nix_log.txt

Thanks for the help.

timbertson commented 3 years ago

That's essentially the same problem in reverse. I think if you update your nixpkgs channel on mac, it should work. Assuming you're using nixpkgs-unstable.

The current nixpkgs-unstable hash is 89281dd1dfed6839610f0ccad0c0e493606168fe89281dd1dfed6839610f0ccad0c0e493606168fe, and that has the gtkSupport argument: https://github.com/NixOS/nixpkgs/blob/89281dd1dfed6839610f0ccad0c0e493606168fe/pkgs/development/ocaml-modules/ocamlgraph/default.nix#L2

Coda-Coda commented 3 years ago

I'm still having the same issue (on macOS). I'm pretty sure I'm on nixpkgs-unstable but may be doing something wrong. Here's what happens:

% nix-channel --list
nixos-unstable https://nixos.org/channels/nixos-unstable
nixpkgs-unstable https://nixos.org/channels/nixpkgs-unstable
% nix-channel --update
unpacking channels...
% sudo nix-channel --update
Password:
unpacking channels...
% nix-shell
trace: [wrangle] Providing source self (git-local) from /nix/store/xb276c098xn9i7n8pw9j36wmlfkjlbwn-35fi699l3w0j8gcb3ag3gjp6zyp7ra6v-source
trace: [wrangle] Providing source cudf (url) from /nix/store/xdlhvc9bwxlz6qncm254yc5ka0cgqkij-cudf-0.9-1.tar.gz
error: anonymous function at /nix/var/nix/profiles/per-user/root/channels/nixpkgs/pkgs/development/ocaml-modules/ocamlgraph/default.nix:1:1 called with unexpected argument 'gtkSupport', at /nix/store/h76bs0f6bv8d2c7q19axd30b8f58jan8-nixpkgs-20.03pre211462.0c960262d15/nixpkgs/lib/customisation.nix:69:16
(use '--show-trace' to show detailed location information)

I did try reverting the 'disable gtk' commit and that went further with the build but still failed. Here is some of that log file:

...
/nix/store/20km04201n770mf8g6vzbwdv33p9ny7i-ocaml-4.10.0+beta1/lib/ocaml/caml/compatibility.h:283:19: note: expanded from macro 'young_ptr'
#define young_ptr caml_young_ptr
                  ^
/nix/store/20km04201n770mf8g6vzbwdv33p9ny7i-ocaml-4.10.0+beta1/lib/ocaml/caml/compatibility.h:30:25: note: expanded from macro 'caml_young_ptr'
#define caml_young_ptr (Caml_state_field(young_ptr))
                        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[1]: *** [Makefile:128: curl-helper.o] Error 2
make[1]: Leaving directory '/private/tmp/nix-build-ocurl-0.9.0.drv-0/ocurl-0.9.0'
make: *** [Makefile:61: all] Error 2
builder for '/nix/store/2krmlz4lmpf9r2d059n6h31lxhrgfxjr-ocurl-0.9.0.drv' failed with exit code 2
cannot build derivation '/nix/store/61my9zafd07gr8hr6wfcryrcr8zawz4q-opam2nix-1.1.0.drv': 1 dependencies couldn't be built
building '/nix/store/76gls5g2pbhjr5rkrababi9jq3zfn678-source.drv'...
cannot build derivation '/nix/store/x9dfgznwqf8qk6i3wxx60yrcp8phh16s-archetype-development.drv': 1 dependencies couldn't be built
error: build of '/nix/store/x9dfgznwqf8qk6i3wxx60yrcp8phh16s-archetype-development.drv' failed

This is taking longer than I expected to get working, but I really do appreciate your help with it :)

Coda-Coda commented 3 years ago

It actually works on macOS, using a shell.nix before the recent changes... (This shell.nix works: https://github.com/timbertson/opam2nix/issues/43#issuecomment-705861483). (But it does not work on Ubuntu).

Coda-Coda commented 3 years ago

Now, the following shell.nix (which should be pinned to 89281dd1dfed6839610f0ccad0c0e493606168fe of unstable and uses opam2nix 1.2.0) works on Ubuntu but does not work on macOS. macOS gives the unexpected argument 'gtkSupport' error.

with import <nixpkgs> {};

let archetypeSrc = ( pkgs.fetchFromGitHub {
    owner  = "Coda-Coda";
    repo   = "archetype-lang";
    rev    = "ba601d05759a59f3d70f7230cd8e529fa2f74066";
    sha256 = "1hafkgyjwjaxb3rg34y2pkmrqqlbis9ad96jhx35p7da59vz6xcn"; } );
in
stdenv.mkDerivation {

  name = "archetype-env";

  buildInputs =
    [
        (import "${archetypeSrc}")
    ]
    ;

}
Coda-Coda commented 3 years ago

Ok, turns out it can be tricky to change channels on macOS, now that I have successfully done so it seems to be OK (it is currently building Archetype on macOS). I'm still curious about how to pin nixpkgs, as I thought this commit and/or this commit would have successfully pinned nixpkgs, regardless of my system setting, but assuming this builds successfully, this particular issue is resolved 😀.

Coda-Coda commented 3 years ago

I can confirm it works on both Ubuntu and macOS using nixpkgs unstable and opam2nix 1.2.0. Here is the working shell.nix:

with import <nixpkgs> {};

let archetypeSrc = ( pkgs.fetchFromGitHub {
    owner  = "Coda-Coda";
    repo   = "archetype-lang";
    rev    = "106cdb1012d82a064ee6a38968664222636cea83";
    sha256 = "1hafkgyjwjaxb3rg34y2pkmrqqlbis9ad96jhx35p7da59vz6xcn"; } );
in
stdenv.mkDerivation {

  name = "archetype-env";

  buildInputs =
    [
        (import "${archetypeSrc}")
    ]
    ;

}

Thanks very much @timbertson and @joprice for the help.

timbertson commented 3 years ago

:partying_face: glad to hear it. Sucks about the root issue on OSX, I've been lucky enough never to hit that one myself...

Coda-Coda commented 3 years ago

Just wanted to note that it works with 20.09 too:

nix-shell -I nixpkgs=https://channels.nixos.org/nixpkgs-20.09-darwin/nixexprs.tar.xz

With the same shell.nix