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

Allow unfree? #274

Open
DanLipsitt opened this issue Jul 2, 2023 · 2 comments
Open

Allow unfree? #274

DanLipsitt opened this issue Jul 2, 2023 · 2 comments

Comments

@DanLipsitt
Copy link

How do I enable unfree packages? When attempting to run one with nix shell, I get the following error:

       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: For `nix shell`, `nix build`, `nix develop` or any other Nix 2.4+
        (Flake) command, `--impure` must be passed in order to read this
        environment variable.

       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) [
             "vscode"
           ];
         }

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

a) doesn't apply because I want the setting to persist. b) doesn't apply because I'm on Darwin, not NixOS. c) doesn't work. ~/.config/nixpkgs/config.nix doesn't exist, and creating it with the suggested contents doesn't appear to do anything. I'm using Home Manager but it doesn't appear to have its own setting for this.

In the future, could this be configured based on a prompt from the Determinate installer?

@adamjsawicki
Copy link
Contributor

adamjsawicki commented Sep 27, 2024

Is this related to #370?

@mtalexan
Copy link

The issue is that the experimental-features = flakes effectively ignores all options related to the nixpkgs in all nix.conf files. This is mentioned all over Nix Discourse (though much less clearly).

There are two options to solve this:

  1. Set the NIXPKGS_ALLOW_UNFREE=1 and use --impure so the environment variable can affect the build (can be setup to be "permanent" with profile or shell rc files and an alias).
  2. Add a new flake registry that has allowUnfree enabled.

The first option is less than ideal, but the most directly compatible.

The second option can be done by making use of a Numtide repo designed for exactly this purpose.

nix registry add nixpkgs-unfree 'github:numtide/nixpkgs-unfree?ref=nixos-unstable'

Then unfree packages from the unstable nixpkgs repo can be installed with:

nix profile install 'nixpkgs-unfree#pkgname'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants