lf- / nix-doc

An interactive Nix documentation tool providing a CLI for function search, a Nix plugin for docs in the REPL, and a ctags implementation for Nix script
201 stars 6 forks source link

Cannot build the nix derivation #4

Closed stephane-rolland closed 4 years ago

stephane-rolland commented 4 years ago

With nixos 19.09, I cannot build the project. I git clone the project, then run nix-build.

It outputs a rust error, related to packaging.

error: failed to sync

Caused by: failed to load pkg lockfile

Caused by: failed to parse lock file at: /build/source/Cargo.lock

Caused by: invalid serialized PackageId for key package.dependencies Traceback (most recent call last): File "/nix/store/pwv46n7g6s2a5w6qy5b6sw9qn1hcw8im-cargo-vendor-normalise/bin/.cargo-vendor-normalise-wrapped", line 42, in main() File "/nix/store/pwv46n7g6s2a5w6qy5b6sw9qn1hcw8im-cargo-vendor-normalise/bin/.cargo-vendor-normalise-wrapped", line 17, in main assert list(data.keys()) == ["source"] AssertionError builder for '/nix/store/4pcd81m6nkahhf7c25yilapq5dl6m3ca-nix-doc-0.2.2-vendor.drv' failed with exit code 1 cannot build derivation '/nix/store/gyvfk26l4r9l0b0rlfdizmzj321r1n8l-nix-doc-0.2.2.drv': 1 dependencies couldn't be built error: build of '/nix/store/gyvfk26l4r9l0b0rlfdizmzj321r1n8l-nix-doc-0.2.2.drv' failed

Any idea how to fix this ?

I'm really looking forward trying nix-doc. Seems like a promising tool.

lf- commented 4 years ago

Try deleting the Cargo.lock.

lf- commented 4 years ago

It's also distinctly possible that in your Nix version, the rust version is too old. This seems implausible to me but rust moves very fast and it could have happened in the intervening near year between 19.09 and today. It's likely possible to provide an overridden nixpkgs to the default.nix with a newer rust and cargo, which is also worth a try, given we take nixpkgs as a parameter (not sure who has those packaged cuz I usually use rustup on another distro but I assume someone's done it).

And my final hypothesis is that it's possibly accidentally fixed now and you should give it another shot. ;-)

lf- commented 4 years ago

This has been built and tested with nix-build --arg nixpkgs 'import (builtins.fetchTarball "https://nixos.org/channels/nixos-19.09/nixexprs.tar.xz")' --show-trace. Let me know if it works for you.

The problem was that nixos-19.09 ships too old of a rustc and cargo, so I switched to nixpkgs-mozilla, except that ALSO has a bug preventing building on nixos-19.09, which I fixed, and I also switched to naersk. It was a whole thing. Anyway this should be resolved.

stephane-rolland commented 4 years ago

git pull to get the modifications, followed by nix-build, and then it builds nicely to /nix/store/zpm9g7qvpj67b2yv1gfwz7pdydfrki22-nix-doc-0.3.1 .

First test nix-doc callPackage /path/to/nixpkgs successful.

Thanks.