Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling nix-env -qa results in failure on not-yet-built project #3

Open
lukateras opened this issue Aug 7, 2019 · 3 comments
Open

Comments

@lukateras
Copy link
Member

@olcai wrote on Feb 22, 2019 8:18am UTC:

While Mix to Nix is working well for building projects, I get an error while trying to use nix-env when a project has not been built yet.

We use nix-env to list all available derivations in our internal nix-overlay, so that we can make our CI server build each derivation in turn.

Now, if I create a dummy Elixir project using mix new, setup a default.nix according to the docs, and then call nix-env -f default.nix -qa --show-trace in that directory (without calling nix-build first), I get this:

error: while evaluating 'importElixir' at /nix/store/gz1a1xq552xg69r2iqsnk3hl4skdvslb-source/default.nix:240:18, called
 from /nix/store/gz1a1xq552xg69r2iqsnk3hl4skdvslb-source/default.nix:259:19:                                          
while evaluating 'importJSON' at /nix/store/nh38qpbmmrli8w3zqv00jv120chf1biz-nixos-18.09.1819.76aafbf4bf4/nixos/lib/trivial.nix:237:16, called from /nix/store/gz1a1xq552xg69r2iqsnk3hl4skdvslb-source/default.nix:240:24:                   
cannot read '/nix/store/yhhb0ih007drznbwd76h8khywbp8pyk1-elixir-term.json', since path '/nix/store/4jv30jsybmwlw9pjay3cm2a15dxkj1ki-elixir-term.json.drv' is not valid, at /nix/store/nh38qpbmmrli8w3zqv00jv120chf1biz-nixos-18.09.1819.76aafbf4bf4/nixos/lib/trivial.nix:238:24

It looks like some kind of bootstrapping problem to me, since the drv-path doesn't exist yet when we try to import it. I'm not fully understanding what to do about it, however. Any pointers? Thank you!

@lukateras
Copy link
Member Author

@yegortimoshenko wrote on Feb 22, 2019 3:24pm UTC:

I would recommend something like:

nix-instantiate --json --eval --expr 'builtins.attrNames (import ./.)'

@lukateras
Copy link
Member Author

@olcai wrote on Feb 22, 2019 9:05pm UTC:

Ah, yes. Running nix-instantiate before will of course do the trick. Thank you for helping me out and answering questions at the nix-beginner-level.

@lukateras
Copy link
Member Author

@yegortimoshenko wrote on Feb 23, 2019 2:12am UTC:

Running nix-instantiate before will of course do the trick.

nix-instantiate, by itself, won't build these paths. Mix to Nix depends on build during eval. So the way to resolve it depends on what you want to achieve.

If you want to use something in conjunction with nix-env specifically, you might have better luck with nix-build -A name 2> /dev/null || true before nix-env.

That said, unless you want to list dependencies, name/version, or other derivation metadata, you can just list attribute names and have CI using go through them using the command in previous comment, which is what I think Hydra does.

This should be probably fixed upstream in nix-env, reopening as a reminder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant