Aspect includes fail when aspects are defined in different files loaded by import-tree
Summary
When den.aspects.X and den.aspects.Y are defined in different files loaded by import-tree, an includes = [ den.aspects.Y ] reference in X's definition does not resolve Y's homeManager content. The same include works when both aspects are defined in the same file.
Reproduction
My home-manager configuration (696 tables, 45 aspects) with homes.nix split across files:
https://codefloe.com/philipp-baumann/agentic-tooling-and-configs
Monolithic (works):
# modules/homes.nix
{ inputs, den, mypkgs, ... }: {
imports = [ inputs.den.flakeModule ];
den.aspects.home.homeManager = {
home.stateVersion = "26.05";
};
den.aspects.philipp = {
includes = [ den.aspects.home den.aspects.sops /* ... 40 more */ ];
};
den.homes.aarch64-darwin.philipp = { ... };
den.homes.x86_64-linux.philipp-linux = { ... };
}
nix eval .#homeConfigurations.spectral-cockpit.activationPackage.drvPath — succeeds, home.stateVersion resolves.
Split (fails):
# modules/homes.nix — thin wiring only
{
inputs, den, mypkgs, ...
}: {
imports = [ inputs.den.flakeModule ];
den.homes.aarch64-darwin.philipp = { ... };
den.homes.x86_64-linux.philipp-linux = { ... };
den.homes.x86_64-linux.spectral-cockpit = { ... };
}
# modules/homes-philipp.nix — separate file
{ den, ... }: {
den.aspects.philipp = {
includes = [ den.aspects.home den.aspects.sops /* ... */ ];
};
}
# modules/base.nix — unchanged
{ den, ... }: {
den.aspects.home.homeManager = {
home.stateVersion = "26.05";
};
}
nix eval .#homeConfigurations.spectral-cockpit.activationPackage.drvPath — fails with:
error: The option `home.stateVersion' was accessed but has no value defined.
Try setting the option.
What was tested
- Both files exist in the same
modules/directory, loaded by(denful-import-tree ./modules)in the flake output. den.aspects.homeis defined inbase.nixasden.aspects.home.homeManager = { home.stateVersion = "26.05"; ... }.den.aspects.philippin the separate file includesden.aspects.home— but the stateVersion does not reach the home-manager configuration.- Moving the aspect definition back into the monolithic
homes.nix(and deleting the separate file) resolves the issue immediately. - Subdirectory placement (
modules/homes/philipp.nix) vs flat (modules/homes-philipp.nix) makes no difference. - Adding
dento the file's function signature ({ den, ... }:) vs{ ... }:makes no difference.
Expected behaviour
Aspect includes should resolve references to aspects defined in other modules loaded by the same import-tree, regardless of which file each aspect is defined in.
Actual behaviour
The includes reference resolves to an empty or different aspect, so the included aspect's homeManager content (including home.stateVersion) is not contributed to the merged configuration.
I understand your report -- but there's no way that it's correct. Can you ask your LLM to to reproduce using our bogus template? This report reads like an LLM mis-reading the results of failing to git stage a new file for inclusion in your local flake environment.
Sorry for using your time for my bogous report. I will try like you suggested and trying to understand. Thanks!
The maintainer's diagnosis is correct, and this report was wrong. Closing the loop with a reproduction.
What actually happened
The failing split had new files that were never git added. Nix flakes only see tracked files, so import-tree silently never loaded them — the aspects simply didn't exist, which surfaced as the misleading home.stateVersion was accessed but has no value defined error. I misread that as a cross-file include failure.
Reproduction with the bogus template
Two cells in one run, nix flake init -t github:denful/den#bogus:
same-file-include— control:base-sameand thetuxauto-aspect inmodules/bug.nix, chainedtux -> base-same.cross-file-include—base-crossinrepro/split-base.nix,consumer-crossinrepro/split-consumer.nix(plain{ den, ... }:modules), pulled into the test via the test module'simports. Chain:tux -> consumer-cross -> base-cross.
With everything staged:
$ nix eval --json .#tests.bogus
{"cross-file-include":{"expected":"from-base","expr":"from-base"},
"same-file-include":{"expected":"from-base","expr":"from-base"}}
Cross-file aspect includes resolve correctly — den.aspects.consumer-cross.includes = [ den.aspects.base-cross ] delivers content from a differently-located file with no issue.
The negative control (why the original report looked plausible)
git rm --cached repro/split-base.nix (file present on disk, untracked in git):
error: getting status of '/nix/store/...-source/repro/split-base.nix': No such file or directory
With explicit imports this fails loudly. With import-tree it fails silently — the file is just absent from the module set, aspects referencing it evaluate empty, and the user only sees a downstream error (in our case the stateVersion one). That silent mode is what fooled me into filing this.
Apologies for the noise — thanks for the quick and accurate call. Happy to send the template-based repro above as a templates/bogus PR if it's useful as a regression cell for the "untracked file is silently invisible to import-tree" failure mode (possibly worth a diagnostics warning, e.g. import-tree detecting on-disk-but-untracked files when the flake source is a git tree).
Glad you have a root cause. I'm not an anti-AI maintainer -- but others are. I would advise you invest some more diligence and verify you understand faults yourself before letting your agent represent itself as you and file reports. It's one thing when your agent uncovers a real edge case, and quite another when it files false reports. AI in this community is already facing an uphill battle for acceptance, please don't make it harder. :)
Thanks for the feedback, I will next time try to fully apply and follow the bug reporting procedure :) Really love denful, it really brings nix configurations to the next level. :)