den icon indicating copy to clipboard operation
den copied to clipboard

Parametized Aspects incorrectly de-duplicated when parameter isn't a context entity

Open sini opened this issue 7 months ago • 1 comments

Description There is a regression in v0.16.0 where parametrized aspects that are not fed by the context pipeline (such as the unfree battery) are aggressively and incorrectly de-duplicated, preventing them from evaluating properly when called multiple times with different arguments.

Originally reported via discussion #459.

Root Cause We recently updated aspects to give them a proper identity based on their declaration path and name. When the tree of all aspects is expanded via their includes, we de-duplicate them based on this identity (e.g., if desktop includes zsh and develop includes zsh, zsh is only pulled in once).

The problem arises with parametrized aspects. If we consider an aspect as a function F, de-duplication works perfectly. However, a call like den._.unfree [ "drawio" ] is actually F(X). If another aspect includes den._.unfree [ "steam" ], that is F(Y).

Currently, the de-duplication logic identifies both F(X) and F(Y) simply as F. It strips the parameters from the identity check, meaning only the very first unfree invocation survives de-duplication, and all subsequent usages are silently dropped.

Steps to Reproduce

  1. Create a configuration that calls den._.unfree (or another non-context parameterized aspect) from at least two different aspects with different arguments.
  2. Attempt to evaluate or build.
  3. Observe that only the first package is permitted, and Nix throws an unfree license evaluation error for the second.

(A minimal reproducible flake is pending from the original reporter, but this can likely be reproduced locally based on the above conditions).

Proposed Resolution Update the de-duplication logic to correctly distinguish and preserve parametrized aspects. The identity check needs to account for the arguments being passed, so that F(X) and F(Y) are treated as distinct inclusions. Due to the way aspect identity is currently tracked, this may require a deeper structural fix rather than a simple patch.

sini avatar Apr 16 '26 17:04 sini

Confirmed fixed.

sini avatar Apr 17 '26 18:04 sini