den icon indicating copy to clipboard operation
den copied to clipboard

Standalone user@host homes skip den's unfree/insecure predicates when the host has home-manager.useGlobalPkgs

Open sini opened this issue 1 week ago • 0 comments

A standalone home named <user>@<host>, for a host that's declared in den.hosts with home-manager.useGlobalPkgs = true, gets no nixpkgs.config.allowUnfreePredicate (or insecure predicate) from den's batteries, so unfree packages declared through den.batteries.unfree fail to evaluate in the home.

Cause

The standalone home is built with its own nixpkgs instance, home.pkgs, but is also handed the declared host's configuration as osConfig (nix/lib/entities/home.nix, extraSpecialArgs.osConfig, about lines 114–117).

The predicate builders decide whether the OS owns nixpkgs config by reading osConfig.home-manager.useGlobalPkgs or false:

  • modules/aspects/batteries/unfree/unfree-predicate-builder.nix:15
  • modules/aspects/batteries/insecure/insecure-predicate-builder.nix:15

That's right for home-manager nested under the host, where useGlobalPkgs means the home uses the host's pkgs. For a standalone homeManagerConfiguration it's wrong: the home doesn't use the host's pkgs, so skipping the predicate leaves nothing setting it. Any other module using the same check, such as one that adds nixpkgs.overlays unless useGlobalPkgs is on, skips its config the same way.

Reproduction

  1. Declare a host igloo with home-manager and home-manager.useGlobalPkgs = true.
  2. Declare a standalone home "tux@igloo".
  3. Add an unfree package through den.batteries.unfree to tux's homeManager content.
  4. Evaluate the standalone home's activationPackage. The expected result is a refusal as unfree, while the same content in tux's nested home on igloo evaluates.

The skipped predicate was observed in a real config, on main and on the user-registry stack (#796–#800) alike. Steps 3–4 are derived from the code above and haven't been run as a minimal case yet.

Direction

The check should mean "this home is nested under the host", not "the host has useGlobalPkgs on". A standalone home could get a marker for that, or the builders could read it from how the home was instantiated, so that useGlobalPkgs from osConfig is consulted only when the home really uses the host's pkgs.

Reported on Matrix while testing the user-registry stack.

sini avatar Nov 28 '26 03:11 sini