Skip to content

bug: nixpkgs.config.allowUnfreePackages not combining between functions #8775

@lazulyra

Description

@lazulyra

Are you following the right branch?

  • My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

When using nixpkgs.config.allowUnfreePackages within HM, values do not combine between functions (as is intended)

{
  config,
  inputs,
  lib,
  recursiveImport,
  ...
}: {
  home-manager = {
    extraSpecialArgs = {inherit inputs;};
    users = {
      lyra = lib.mkIf config.users.users.lyra.enable {
        imports =
          [
            ({...}: {nixpkgs.config.allowUnfreePackages = ["456"];})
            ({...}: {nixpkgs.config.allowUnfreePackages = ["123"];})
          ]
          ++ (recursiveImport ./lyra); # this does contain further allowUnfreePackage definitions, but these have no effect on the result
      };
    };
  };
}

results in

nix-repl> nixosConfigurations.thegosis.config.home-manager.users.lyra.nixpkgs.config.allowUnfreePackages
[ "456" ]

When used outside of home manager (in my case, NixOS configuration)
(shortened for brevity)

nixpkgs.lib.nixosSystem {
  specialArgs = {
    inherit inputs host recursiveImport;
  };
  modules =
    [./home home-manager.nixosModules.default]
    ++ [({...}: {nixpkgs.config.allowUnfreePackages = ["123"];}) ({...}: {nixpkgs.config.allowUnfreePackages = ["456"];})];
};

results in

nix-repl> nixosConfigurations.thegosis.config.nixpkgs.config.allowUnfreePackages
[
  "456"
  "123"
]

Maintainer CC

No response

System information

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.18.12, NixOS, 26.05 (Yarara), 26.05.20260217.0182a36`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.31.3`
 - nixpkgs: `/nix/store/dx2qikyb4dyb6hbdfywbmsyla0z5a1h3-source`

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtriageIssues or feature request that have not been triaged yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions