-
-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
Multiple allowUnfreePredicate
s should compose with or
#197325
Comments
👍 I think this is a bit cumbersome as well. I worked around this by creating this module: { config, pkgs, nixpkgs, lib, ... }:
let
inherit (lib) mkOption types;
cfg = config.allowedUnfreePackagesRegexs;
in {
options = {
allowedUnfreePackagesRegexs = mkOption {
default = [ ];
type = types.listOf types.str;
description = "List of unfree packages allowed to be installed";
example = lib.literalExpression ''[ "steam" ]'';
};
};
config = {
nixpkgs.config.allowUnfreePredicate = pkg:
let pkgName = (lib.getName pkg);
matchPackges = (reg: ! builtins.isNull (builtins.match reg pkgName));
in
builtins.any matchPackges cfg;
};
} and then I can use it like this: allowedUnfreePackagesRegexs = [ "slack" "discord" ];
# in another config file:
allowedUnfreePackagesRegexs = ["nvidia-.*"]; |
The issue, if I understand it correctly, is that |
I use this module: { lib, config, ... }:
{
options = with lib; {
nixpkgs.allowUnfreePackages = mkOption {
type = with types; listOf str;
default = [];
example = [ "steam" "steam-original" ];
};
};
config = {
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) config.nixpkgs.allowUnfreePackages;
};
} I have |
Submit PR? |
I've successfully used the module by @Majiir for some time now (thanks for sharing it ). There is a braking change though. |
I don't think that's an issue with the module, since you will need to set
|
This includes suggestions from vimjoyer the vimjoyer video about gaming on NixOS: https://www.youtube.com/watch?v=qlfm3MEbqYA In order to allow multiple modules to declare allowed unfree packages a new option needed to be introduced. This is because allowUnfreePredicate is not combined when configured in multip places, see NixOS/nixpkgs#197325
Describe the bug
Specifying
nixpkgs.config.allowUnfreePredicate
in two files, and then importing one from the other, results in only one of theallowUnfreePredicate
s taking effect. Instead, any package matching anyallowUnfreePredicate
should be allowed.Steps To Reproduce
Steps to reproduce the behavior:
imports = [./host.nix];
,fonts.fonts = [pkgs.corefonts];
, and/etc/nixos/configuration.nix
programs.steam.enable = true;
in/etc/nixos/host.nix
.nixos-rebuild
This command will fail because only the
/etc/nixos/configuration.nix
allowUnfreePredicate
is taken into account, so Steam can't be installed.Expected behavior
Both
pkgs.corefonts
andpkgs.steam
should be installed, analogous to howenvironment.systemPackages
from imported packages are joined with localenvironment.systemPackages
to install all of them.Additional context
Workaround:
Notify maintainers
Metadata
"x86_64-linux"
Linux 5.15.74, NixOS, 22.05 (Quokka), 22.05.3737.3933d8bb912
yes
yes
nix-env (Nix) 2.11.0
"home-manager-22.05.tar.gz, nixos-22.05"
""
/nix/var/nix/profiles/per-user/root/channels/nixos
The text was updated successfully, but these errors were encountered: