Skip to content

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

Closed

Description

@matthewbauer

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

Activity

  1. edolstra commented on Aug 24, 2020

    @edolstra
    Member

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

  2. matthewbauer commented on Aug 24, 2020

    @matthewbauer
    MemberAuthor

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

  3. added
    feature
    error-messages
    and removed on Feb 9, 2021
  4. changed the title [-]"args" not being passed to flakes properly[/-] [+]Print error message if --arg is used with a flake[/+] on Feb 9, 2021
  5. added this to the nix-2.4 milestone on Feb 9, 2021
  6. removed
    feature
    on Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    error-messagesflakes

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions