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

Exception when expression root is a list #79

Open
roberth opened this issue Jun 27, 2019 · 0 comments

Comments

@roberth
Copy link
Contributor

commented Jun 27, 2019

Description

The agent reports an attribute error when the root of the expression (such as ci.nix) evaluates to a list.

To Reproduce

Evaluate a project with ci.nix like https://github.com/utdemir/distributed-dataset/blob/547c76153624edd0f2ea5ca8f7afa5fa5d4167dd/ci.nix

Expected behavior

nix-build supports this, and we said we do what nix-build does, so

$ nix-build --no-out-link --expr 'with import <nixpkgs> {}; [ hello git ]'
/nix/store/06vykrz1hmxgxir8i74fwjl6r9bb2gpg-hello-2.10
/nix/store/n2sxgms8b7kg3rnc41sh6rkjv5v94cfp-git-2.19.2

$ nix-build --no-out-link --expr 'with import <nixpkgs> {}; { foo = [ hello git ]; }'

[nothing]

However, we should recommend against using lists this way, for two main reasons:

  • Lists have surprising behavior in nix-build. Being able to put them in an attrset seems like a reasonable expectation, but there's no way to make that build in nix-build.
  • Subjectively, an expression returning a list is a dead end. Taking elements out of a list can be done, but is error prone. The only 'good' way to use a list of derivations is to use all of them at once, like in buildInputs.

Logs

hercules-ci/support#21

Platform / Version

Any

Suggested fix

  • Don't use last (or use last from Protolude)
  • Add an error message specifically when ignoring values at the expression root.
    • In particular when it's a list, recommend an attrset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.