Describe the bug
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
];
}
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
let
unstable = import <unstable> {};
in
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
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