reproduce infinite recursion

the challenge here seems to stem from a mutual dependency between imports and `inputs`:

```
  at /nix/store/zid48nap5bh52n8d2gc5kbnzhxy3cm0k-source/deployment/data-model.nix:31:7:
    30|     staticModules = [
    31|       inputs.nixops4.modules.nixops4Deployment.default
      |       ^
    32|
… while calling anonymous lambda
  at /nix/store/hjb1rqv2mfs5ny47amj2gsc8xk05x5g6-source/lib/modules.nix:513:35:
   512|       context = name: ''while evaluating the module argument `${name}' in "${key}":'';
   513|       extraArgs = mapAttrs (name: _:
      |                                   ^
   514|         addErrorContext (context name)
… while evaluating the module argument `inputs' in "/nix/store/zid48nap5bh52n8d2gc5kbnzhxy3cm0k-source/deployment/data-model.nix":
… while evaluating the attribute 'inputs'
  at /nix/store/zid48nap5bh52n8d2gc5kbnzhxy3cm0k-source/deployment/check/data-model/deployment.nix:15:17:
    14|       specialArgs = {
    15|         inherit inputs;
      |                 ^
    16|       };
… from call site
  at /nix/store/zid48nap5bh52n8d2gc5kbnzhxy3cm0k-source/deployment/check/data-model/deployment.nix:15:17:
    14|       specialArgs = {
    15|         inherit inputs;
      |                 ^
    16|       };
```
This commit is contained in:
Kiara Grouwstra 2025-08-01 20:38:43 +02:00
parent 6635a11832
commit ccf442b099
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU
3 changed files with 56 additions and 29 deletions

View file

@ -2,35 +2,60 @@
inputs,
sources,
lib,
providers,
...
}:
let
inherit (import ./constants.nix) targetMachines pathToRoot pathFromRoot;
in
eval =
module:
(lib.evalModules {
specialArgs = {
inherit inputs;
};
modules = [
module
../../data-model.nix
];
}).config;
fediversity = eval (
{ ... }:
{
config = {
environments.single-nixos-vm =
{ ... }:
{
implementation = requests: {
input = requests;
output =
{ providers, ... }:
{
providers = {
inherit (inputs.nixops4.modules.nixops4Provider) local;
};
resources = lib.genAttrs targetMachines (nodeName: {
type = providers.local.exec;
imports = [
inputs.nixops4-nixos.modules.nixops4Resource.nixos
../../data-model.nix
../../function.nix
../common/targetResource.nix
];
_module.args = { inherit inputs sources; };
inherit nodeName pathToRoot pathFromRoot;
nixos.module =
{ pkgs, ... }:
{
environment.systemPackages = [ pkgs.${nodeName} ];
};
});
};
};
};
};
}
);
in
fediversity.environments.single-nixos-vm.deployment {
enable = true;
}

View file

@ -13,8 +13,8 @@
inputs.nixops4.modules.flake.default
];
nixops4Deployments.check-deployment-basic = {
imports = [ ./deployment/check/basic/deployment.nix ];
nixops4Deployments.check-deployment-model = {
imports = [ ./deployment/check/data-model/deployment.nix ];
_module.args = { inherit inputs sources; };
};
}

View file

@ -3,9 +3,11 @@
{
_class = "nixosTest";
name = "deployment-basic";
name = "deployment-model";
sourceFileset = lib.fileset.unions [
../../data-model.nix
../../function.nix
./constants.nix
./deployment.nix
];
@ -39,7 +41,7 @@
cowsay.fail("cowsay 1>&2")
with subtest("Run the deployment"):
deployer.succeed("nixops4 apply check-deployment-basic --show-trace --no-interactive 1>&2")
deployer.succeed("nixops4 apply check-deployment-model --show-trace --no-interactive 1>&2")
with subtest("Check the deployment"):
hello.succeed("hello 1>&2")