nixpkgs.config.allowUnfree not working for for unstable in users.users.user-name.packages

Created on 24 Sep 2019  Â·  4Comments  Â·  Source: NixOS/nixpkgs

Describe the bug

I have defined 2 channels in /root/.nix-channels

https://nixos.org/channels/nixos-19.09 nixos
https://nixos.org/channels/nixos-unstable unstable

in my configuration.nix I have

let
  unstable = import <unstable> {};
in
{
  nixpkgs.config.allowUnfree = true; 
  users = {
    mutableUsers = false;
    users.user-name = {
      isNormalUser = true;
      home = "/home/user-name";
      shell = "/run/current-system/sw/bin/fish";
      extraGroups = [ "wheel" "docker" "audio" "video" "networkmanager" ];
      hashedPassword = "$6$XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
      packages = with pkgs; [
        name-package
        unstable.name-package
      ];
    };
  };
environment.systemPackages = with pkgs; [
  name-package
  unstable.name-package
  ];
}

if name-package is Unfree package I am getting the error during

nixos-rebuild switch --upgrade                                                                                               
unpacking channels...
building Nix...
building the system configuration...
error: Package ‘xmind-8-update8’ in /nix/store/dzf50lqjswbm33gh48hxw0bqdqai1pkl-unstable-20.03pre193781.d484f2b7fc0/unstable/pkgs/applications/misc/xmind/default.nix:72 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)

error is for both users.users.user-name.packages and environment.systemPackages

If I do replace

let
  unstable = import <unstable> {};
in

with

let
  unstableTarball =
    fetchTarball
      https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz;
in
{
  nixpkgs.config = {
    packageOverrides = pkgs: {
      unstable = import unstableTarball {
        config = config.nixpkgs.config;
      };
    };
  };

The package is installed without an issue

To Reproduce
Follow the above configuration changes

Expected behavior
Package Unfree should be deployed using both methods.

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 5.3.0, NixOS, 19.09beta317.88f32cca5a4 (Loris)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3`
 - channels(root): `"nixos-19.09beta317.88f32cca5a4, unstable-20.03pre193781.d484f2b7fc0"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Above method is based on a tutorial from
https://functor.tokyo/blog/2018-02-18-install-packages-from-nixos-unstable

bug

All 4 comments

I think you need

unstable = import <unstable> { config.allowUnfree = true; };

Don't think this is a bug. nixpkgs.config refers to the config for only the nixos channel I believe.

@alexarice Thx for the solution I didn't realize the option is not applied to nixos unstable looking back seems obvious. Would make more sense to see apply to unstable as well.

import can work on any nix file. I don't really see why it should be expected to notice that the thing you have imported is a version of nixpkgs and pass the config in because of it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lverns picture lverns  Â·  3Comments

rzetterberg picture rzetterberg  Â·  3Comments

copumpkin picture copumpkin  Â·  3Comments

grahamc picture grahamc  Â·  3Comments

matthiasbeyer picture matthiasbeyer  Â·  3Comments