Skip to content

Non-free nix packages with Flakes are failing to upgrade #611

@punkeel

Description

@punkeel

This is related to #389, with a twist.

Steps to reproduce

  1. Install Nix on macOS, with the Determinate Systems installer. Using the "official" installer would work, but with more steps (enable Flakes, disable nixpkgs) and I'm not an expert on that 😬
  2. Install an unfree flake: NIXPKGS_ALLOW_UNFREE=1 nix profile install --impure 'nixpkgs#_1password'
  3. Run topgrade

Erroneous Behavior

topgrade fails with the following error:

MacPro% env|grep ALLOW
NIXPKGS_ALLOW_UNFREE=1

MacPro% nix --extra-experimental-features nix-command profile upgrade '.*' --verbose

       error: Package ‘1password-cli-2.22.0’ in /nix/store/mrckm9b3v6wg2fljdp3z4pja1sz07g3z-source/pkgs/applications/misc/1password/default.nix:71 has an unfree license (‘unfree’), refusing to evaluate.

       a) To temporarily allow unfree packages, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNFREE=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

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

       Alternatively you can configure a predicate to allow specific packages:
         { nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
             "1password-cli"
           ];
         }

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

Options b/c do not work, because of Flakes (from what I understand) - and the env.var alone isn't enough, --impure must be passed.

Expected Behavior

One of:

  • Documentation to explain why this doesn't work - which I'm trying to achieve with this ticket.
  • The command used by topgrade should work out of the box.
  • Topgrade should allow setting --impure.
  • Topgrade should automagically add --impure when NIX_* environment variables are present?

Problem persists without calling from topgrade

  • Yes, but with a workaround
  • No

Additional Details

  • Operation System/Version: MacOS Sonoma
  • Topgrade version (topgrade -V): Topgrade 13.0.0, installed with Nix

Relevant code

let nix_args = ["--extra-experimental-features", "nix-command"];

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions