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

Print error message if --arg is used with a flake #3949

Closed
matthewbauer opened this issue Aug 21, 2020 · 2 comments
Closed

Print error message if --arg is used with a flake #3949

matthewbauer opened this issue Aug 21, 2020 · 2 comments
Labels
error-messages Confusing messages and better diagnostics flakes
Milestone

Comments

@matthewbauer
Copy link
Member

matthewbauer commented Aug 21, 2020

Describe the bug

When you try to build something unfree, you get a message like this:

$ nix build nixpkgs#cudatoolkit
error: --- ThrownError --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix
Package ‘cudatoolkit-10.2.89’ in /nix/store/9xsn9g209bvbl324kska98xzsnr4ls95-source/pkgs/development/compilers/cudatoolkit/common.nix:214 has an unfree license (‘unfree’), refusing to evaluate.

a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.

(use '--show-trace' to show detailed location information)

Previously, you could pass an arg like this:

$ nix build nixpkgs#cudatoolkit --arg config '{ allowUnfree = true; }'

But now I get:

cached failure of attribute 'legacyPackages.x86_64-linux.cudatoolkit.drvPath'

I think we may need to rethink how args work w.r.t. flakes. It's unclear whether "arg" applies to the flake itself, or to the flake + attr path. In addition, there's a few things that we could fix in the new command line that have existed previously in nix-build:

  • Nix doesn't error when the arg doesn't actually exist.
  • Nested attribute names like --arg config.allowUnfree false don't work.
  • No completions for --arg names.

Version: nix-2.4pre20200622_334e26b

@edolstra
Copy link
Member

The reason for not supporting arguments in flakes is discussed here: #3843 (comment)

@matthewbauer
Copy link
Member Author

Maybe --arg should be an error on flakes then?

@edolstra edolstra added feature Feature request or proposal flakes error-messages Confusing messages and better diagnostics and removed bug labels Feb 9, 2021
@edolstra edolstra changed the title "args" not being passed to flakes properly Print error message if --arg is used with a flake Feb 9, 2021
@garbas garbas added this to the nix-2.4 milestone Feb 9, 2021
@edolstra edolstra removed the feature Feature request or proposal label Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error-messages Confusing messages and better diagnostics flakes
Projects
None yet
Development

No branches or pull requests

3 participants