-
-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Problem
When using den with NixOS configurations, nix flake check emits this warning for every NixOS configuration:
warning: Using 'builtins.derivation' to create a derivation named 'options.json' that references the store path '/nix/store/...-source' without a proper context. The resulting derivation will not have a correct store reference, so this is unreliable and may stop working in the future.
The -source store path is nixpkgs itself. The options.json derivation (NixOS options documentation) references it without proper string context, meaning nix-collect-garbage can prune it. If options.json is part of the system closure (the default when documentation.nixos.enable = true), this can make the system unbootable after gc.
Root cause
den's nixModule declares options like den.lib, den.aspects, and den.ctx with types.raw. When the NixOS module system evaluates these options to generate options.json, it serializes values that contain store path references without proper Nix string context. The resulting derivation has an informal (untracked) dependency on the nixpkgs source path.
Reproduction
Any flake using den with a NixOS configuration:
nix flake check # warning appears for each nixosConfigurationWorkaround
Disable NixOS options documentation generation on affected hosts:
documentation.enable = false;This removes options.json from the system closure, eliminating the gc risk. The warning still appears during evaluation but is no longer a runtime hazard.
Suggested fix
Mark the problematic options as internal/invisible so the documentation system skips them:
options.den.lib = lib.mkOption {
type = lib.types.attrsOf lib.types.raw;
internal = true;
visible = false;
};Or avoid declaring them as NixOS options entirely — set them as config values directly without corresponding option declarations.
Environment
- den rev:
7c2887a778e2263ab781acfb964a58c82ad0f324 - Nix: Determinate Nix 3.17.0
- nixpkgs: 25.11