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

roberth opened this issue Jun 27, 2019 · 0 comments

Exception when expression root is a list #79

roberth opened this issue Jun 27, 2019 · 0 comments


Copy link

@roberth roberth commented Jun 27, 2019


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

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-build --no-out-link --expr 'with import <nixpkgs> {}; { foo = [ hello git ]; }'


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.



Platform / Version


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
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant