Repository navigation
Conversation
|
Hey @sini, test-externally-instantiated-host = denTest (
{ den, ... }:
{
imports = [
common
envTopology
];
# This is how I currently add hosts to environments and this seems working
den.policies.test-env-to-host-no-instantiate =
{ environment, ... }:
lib.concatMap (
host:
[ (resolve.to "host" { inherit host; }) ]
++ lib.optionals (host.intoAttr != [ ]) [
(instantiate host)
]
) (builtins.attrValues (den.hosts.x86_64-linux or { }));
den.schema.environment.excludes = [ den.policies.test-env-to-host ];
den.schema.environment.includes = [ den.policies.test-env-to-host-no-instantiate ];
den.hosts.x86_64-linux.shelf.intoAttr = [ ];
den.aspects.shelf.nixos =
{ environment, host, ... }:
{
environment.etc."mark-${host.name}".text = environment.name;
};
expr = marks (fromMain den.hosts.x86_64-linux.shelf).environment.etc;
expected = [
"mark-base"
"mark-shelf"
];
}
);I'm currently in the middle of migration from other framework to den and I cannot use den's host instantiation (yet), so I just pass But it's possible that I just don't understand how all this should work and probably I'm using it wrong. If so could you point me out how to achieve this correctly? |
|
Thanks, this is a real gap. Your policy resolves every host but instantiates only the placed ones, so (Edited: I first said this policy was the one in the ACL environments guide. It isn't; the guide skips unplaced hosts entirely.) |
…ts fleet delivery
A fleet that resolves every host under an environment but instantiates only
those with an `intoAttr` leaves the rest unplaced, and a config that builds
such a host itself, from its mainModule, got the host-rooted resolve: no
environment context, so a `{ environment, host, ... }` class module was
dropped. The fleet delivery index was built from instantiate specs only.
Each host scope the walk resolved directly under the parent kind with no
instantiate spec now gets a delivery bounded at that walked scope, through the
same materializer and lost-content check as an instantiated host. It feeds
mainModule only; the landing index behind hasAspect and every
nixosConfigurations are unchanged. An instantiated occurrence wins its key and
one physical scope reached twice is one occurrence. Two distinct walked scopes
of a host, from two environments or one environment with different bindings,
are refused by name when that host's mainModule is read. A host the walk never
resolves directly under that kind keeps its host-rooted resolve.
Reported in GitHub #805
1cf47e9 to
6deaa7c
Compare
…kind above hosts
With `den.schema.host.parent` set, a host's configuration is built from the
fleet walk, where content an ancestor kind delivers (a `{ environment, host,
... }` include, its `provides.to-users`, its excludes, a sibling's pipe
values) lands. mainModule was always the host's own host-rooted resolve, so it
lacked that content. A host's mainModule now imports the fleet's delivery for
that host when it has one, through the same reading nixosConfigurations uses,
keyed by den.lib.aspects.__landingKey. A host the flake doesn't instantiate,
or whose delivery is empty, keeps its host-rooted resolve, as its
configuration does. Without a kind above hosts nothing changes.
mainModule is always `{ imports = …; }` with the choice inside, so binding a
peer's mainModule or asking `? imports` during the walk forces nothing. Its
content, once forced, is a late-phase value: reading a gated peer's imports
from an include still building the fleet recurses. Den's own fallback uses a
private host-rooted accessor, never the public mainModule. Reading a gated
host's mainModule pays the fleet walk, as nixosConfigurations does, and an
error in another host's include reaches it.
Reported in GitHub #795
…ts fleet delivery
A fleet that resolves every host under an environment but instantiates only
those with an `intoAttr` leaves the rest unplaced, and a config that builds
such a host itself, from its mainModule, got the host-rooted resolve: no
environment context, so a `{ environment, host, ... }` class module was
dropped. The fleet delivery index was built from instantiate specs only.
Each host scope the walk resolved directly under the parent kind with no
instantiate spec now gets a delivery bounded at that walked scope, through the
same materializer and lost-content check as an instantiated host. It feeds
mainModule only; the landing index behind hasAspect and every
nixosConfigurations are unchanged. An instantiated occurrence wins its key and
one physical scope reached twice is one occurrence. Two distinct walked scopes
of a host, from two environments or one environment with different bindings,
are refused by name when that host's mainModule is read. A host the walk never
resolves directly under that kind keeps its host-rooted resolve.
Reported in GitHub #805
6deaa7c to
9092aad
Compare
Summary
Fixes #795. Builds on #804 for the fleet landing key.
When an entity kind sits above hosts (
den.schema.host.parent), a host's configuration is built from the fleet walk. That's where the content this kind delivers lands: a{ environment, host, ... }include, itsprovides.to-users, its excludes, and the values a sibling's pipe collects.host.mainModulewas the host's own host-rooted resolve, so it lacked all of that. On these hosts it now imports the fleet's delivery for that host. It reads that delivery through the same getter the configuration uses, keyed by name, system and class.Some cases are unchanged:
mainModule is always
{ imports = …; }. So binding a peer's mainModule, or asking? imports, during the walk still forces nothing. Reading the modules themselves is a late-phase read.That changes one pattern that used to evaluate. Under a parent kind, an include or policy might force a peer's mainModule modules while the fleet is being built. It used to get that peer's host-rooted modules, and now it gets an infinite recursion. No documented use or known configuration does this. The docs now say to read those modules from a class module, an output or the repl.
There are also three behaviour changes for a gated host's mainModule:
Hosts resolved but not placed
A host can be resolved directly under the kind above hosts without den placing it (
intoAttr = [ ]), for example when another framework builds it frommainModule. As reported in review, such a host now also gets its part of the fleet resolve as itsmainModule, so it sees that kind's context ({ environment, host, ... }). The delivery is built from each walked host scope, through the same materializer and lost-content check as an instantiated host's. It feedsmainModuleonly: the landing index behindhasAspect, and everynixosConfigurations, are unchanged.mainModuleis refused by name. That covers two environments, or one environment with different bindings. It also covers an environment resolved once per system whose host policy doesn't filter by system, a config that evaluated before.Known limit, unchanged here and present on
main: two hosts with the same name on different systems, resolved under one environment scope, share a walked scope. Walk each system's hosts in that system's environment.Validation
These results are from local runs on the same tree (now rebased onto
mainas9092aadf). The hosted test workflow hasn't run yet, because it skips draft PRs.templates/ci/modules/deadbugs/mainmodule-ancestor-kind.nixhas 26 cells and passes 26/26. The base fails 9 of the 14 cells for instantiated hosts. The first commit alone fails exactly the 8 cells for hosts that are resolved but not placed. Each cell compares mainModule's markers withnixosConfigurationsfor one ancestor delivery shape:provides.to-users, read both in NixOS and in home-manager;den.schema.environment.excludes;Further cells cover no-parent laziness, sibling poisons, the duplicate refusal, the in-walk
? importsshape read, and the fleet/rooted selection function.Mutants turn the suite red:
nixos, and keeping only the last scope per parent and host.nixosConfigurationsis unchanged. Toplevel drvs are identical to the base for the minimal, default and example templates and aprovides.to-usersfixture. They're also identical for a real fleet host that useshost.parent. That host's mainModule failed to evaluate before, and now gives the identical drv.Cost at the same demand, one host's toplevel drvPath:
nixosConfigurationsWithout a parent kind, the change is +0.003%. The resolve-only scan adds 1,515 thunks (+0.008%) at 50 hosts.
The full suite passes 2377/2377. Checkmate passes 15/15, including the
abort-on-warnchecks (2/2).