den icon indicating copy to clipboard operation
den copied to clipboard

den.batteries.unfree no longer reaches the host when the aspect is delivered through provides.to-users (#694 release branch)

Open tomwrw opened this issue 4 weeks ago • 1 comments

Description

On the #694 release branch (PR #753 head bc9b0f6, stacked on #749, #751, #752, #746 and #747), unfree package names declared by an aspect that a host hands to its users through provides.to-users no longer reach the host's unfree.packages.

With Home Manager's useGlobalPkgs = true, the host's allowUnfreePredicate is the one that applies, so the host fails to evaluate:

error: Refusing to evaluate package 'vscode-extension-anthropic-claude-code-2.1.314' in …/pkgs/applications/editors/vscode/extensions/anthropic.claude-code/default.nix:50 because it has an unfree license (‘unfree’)

This happens with the transition defaults on (no den.migrations.user-host-content.acknowledged). The config breaks as soon as den is upgraded, not on 2027-01-01.

Reproduction

The shape that triggers it:

den.aspects.vscodium.includes = [ (den.batteries.unfree [ "vscode-extension-anthropic-claude-code" ]) ];

# A role that gives its user half to every user on the host
den.aspects.dev.provides.to-users.includes = [ den.aspects.vscodium ];

den.aspects.igloo.includes = [ den.aspects.dev ];
den.hosts.x86_64-linux.igloo.users.tux = { };   # classes = [ "homeManager" "user" ]

Then evaluate nixosConfigurations.igloo.config.unfree.packages.

Expected

The same list as on main: names from to-users-delivered aspects are included.

Actual

Same config, with only the den input changed:

den unfree.packages on the host
main bf2504f vscode-extension-anthropic-claude-code, cursor, claude-code, spotify, spicetify-stylix, obsidian, xone-dongle-firmware, steam, steam-unwrapped
#753 bc9b0f6 spotify, spicetify-stylix, obsidian, xone-dongle-firmware, steam, steam-unwrapped

The three missing names are exactly the ones declared by aspects delivered through provides.to-users. These still arrive:

  • names from aspects the user includes directly (spotify, obsidian)
  • names from aspects the host includes (steam, xone-dongle-firmware)

Likely cause

PR #753 changes modules/aspects/batteries/unfree/unfree.nix:

  • Before: the host half was emitted directly as ${host.class}.unfree.packages.
  • After: it's a nested __isPolicy include that calls den.lib.policy.provide { class = host.class; receiver = host; … }.

That nested policy doesn't seem to fire when the aspect is reached through host-to-users.

Workaround

Also include the battery on the host side, e.g. in the role's own includes:

den.aspects.dev.includes = [
  (den.batteries.unfree [ "claude-code" "cursor" "vscode-extension-anthropic-claude-code" ])
];

Environment

  • den: main bf2504f (works) vs PR #753 bc9b0f6 (fails)
  • nixpkgs: nixos-unstable (26.11.20261101)
  • home-manager: useGlobalPkgs = true, useUserPackages = true

Related: #694, discussion #750

LLM disclosure

Discovered with Claude Opus 5.5 against my own config while planning a migration on discussion #750.

tomwrw avatar Nov 08 '26 09:11 tomwrw

Fixed in v0.20.0. The late-dispatch fix landed in #746 (b89368b), and the to-hosts and provenance parts landed in #753 (22b2097).

The cause: an aspect that reaches a scope after that scope's own policy dispatch carried a nested policy, and late dispatch dropped it. Late arrivals include provides.to-users, provides.<user>, provides.to-hosts, provides.<host>, and an aspect a host or user policy includes. A policy written { host, ... }: that arrived at a user is one example. Late dispatch's entity-kind filter exists for an ancestor's own policies, and it removed these too. So den.batteries.unfree's host half, which this release nests in such a policy, never reached the host for an aspect delivered through provides.to-users. Author policies of the same shape were dropped through the same paths before this release.

The fix:

  • It makes a policy registered at a scope by a late include fire there, once. Its host-class part goes to the entity that registered it: the host, for to-users, provides.<user> and a host policy.
  • It makes a policy nested in provides.to-hosts or provides.<host> part of what mutual-provider delivers, like that provide's static content. It needs the battery, and excluding the battery stops it.
  • Den records the provider itself while it walks the provide, and never reads it from an aspect name. An aspect named with den's internal marker is refused.

Cells (templates/ci/modules/deadbugs/):

  • issue-754-nested-policy-late-delivery.nix: the late-delivery grid over delivery path, policy shape and nesting depth, with transition defaults on.
  • issue-754-nested-policy-late-delivery-end-state.nix: the same grid in the end state.
  • issue-754-nested-policy-fires-once.nix: a nested policy that reaches a user through more than one path fires there once.
  • issue-754-to-users-nested-host-policy.nix (#746): a { host } policy nested in a to-users aspect fires at the host.
  • issue-754-ancestor-host-policy-stays-at-host.nix (#746): an ancestor's own host policy still doesn't fire at the user.
  • issue-754-to-hosts-nested-policy-provenance.nix: a policy nested in to-hosts is delivered with the provide, and stops when the battery is excluded.
  • issue-754-provenance-den-only.nix: provenance can't be forged by naming an aspect.

In den's own templates nothing changes: the same policies fire and every drv is identical to v0.19's.

sini avatar Nov 09 '26 19:11 sini