I’m trying to wrap my head around a change in 23.11 that is not allowing me installing unfree packages. According to the 23.11 release page:
Setting
nixpkgs.config
options while providing an externalpkgs
instance will now raise an error instead of silently ignoring the options. NixOS modules no longer setnixpkgs.config
to accommodate this. This specifically affectsservices.locate
,services.xserver.displayManager.lightdm.greeters.tiny
andprograms.firefox
NixOS modules. No manual intervention should be required in most cases, however, configurations relying on those modules affecting packages outside the system environment should switch to explicit overlays.
{
description = "NixOS configurations";
inputs = {
nixpkgs.url = "nixpkgs/nixos-23.11";
nixpkgs-unstable.url = "nixpkgs/master";
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, ... }@inputs:
let
mkHost = hostName: system:
nixpkgs.lib.nixosSystem {
pkgs = import nixpkgs {
inherit system;
nixpkgs.config = {
allowUnfree = true;
};
};
specialArgs = {
pkgs-unstable = import nixpkgs-unstable {
inherit system;
nixpkgs-unstable.config = {
allowUnfree = true;
};
};
inherit inputs;
};
modules = [
./modules
./shared/configuration.nix
./hosts/${hostName}
];
};
in {
nixosConfigurations = {
host = mkHost "host" "x86_64-linux";
};
};
}
# shared/configuration.nix
{ pkgs, pkgs-unstable, inputs, ... }:
let inherit (inputs) self;
in {
nixpkgs.config.allowUnfree = true;
}
Error:
error:
Failed assertions:
- Your system configures nixpkgs with an externally created instance.
`nixpkgs.config` options should be passed when creating the instance instead.
Current value:
{
__toString = <function>;
_type = "option";
declarationPositions = [
{
column = 5;
file = "/nix/store/zici691hpiy6maxz6zh1hp2if797x28d-source/nixos/modules/misc/nixpkgs.nix";
line = 148;
}
];
declarations = [
"/nix/store/zici691hpiy6maxz6zh1hp2if797x28d-source/nixos/modules/misc/nixpkgs.nix"
];
default = { };
definitions = [
{
allowUnfree = true;
}
];
definitionsWithLocations = [
{
file = "/nix/store/cyhszyf8ysvam29sji4wdrvg6bm806qy-source/shared/configuration.nix";
value = {
allowUnfree = true;
};
}
];
description = ''
The configuration of the Nix Packages collection. (For
details, see the Nixpkgs documentation.) It allows you to set
package configuration options.
Ignored when `nixpkgs.pkgs` is set.
'';
example = {
_type = "literalExpression";
text = ''
{ allowBroken = true; allowUnfree = true; }
'';
};
files = [
"/nix/store/cyhszyf8ysvam29sji4wdrvg6bm806qy-source/shared/configuration.nix"
];
highestPrio = 100;
isDefined = true;
loc = [
"nixpkgs"
"config"
];
options = [ ];
type = {
_type = "option-type";
check = <function>;
deprecationMessage = null;
description = "nixpkgs config";
descriptionClass = null;
emptyValue = { };
functor = {
binOp = <function>;
name = "nixpkgs-config";
payload = null;
type = null;
wrapped = null;
};
getSubModules = null;
getSubOptions = <function>;
merge = <function>;
name = "nixpkgs-config";
nestedTypes = { };
substSubModules = <function>;
typeMerge = <function>;
};
value = {
allowUnfree = true;
};
}
So, my main concern is how do I have to define config options when nixpkgs.pkgs is defined after 23.11?.