Hello,
I’m using nixops to deploy servers and also use nixos-containers to further isolate services, this is all in a flake.
I’m running into an infinite recursion error when using one of the flake input, in my case simple-nixos-mailserver ; but I suspect it would do the same with another.
It is caused by using the input flake’s module in the container’s inputs.
I narrowed it down to this minimal example:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-23.11";
};
outputs = { self, nixpkgs, simple-nixos-mailserver, ... }: {
devShells.x86_64-linux.default =
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in pkgs.mkShell {
packages = [
pkgs.nixops_unstable
];
};
nixopsConfigurations.default = {
inherit nixpkgs;
network.storage.legacy = {};
testhost = {...}: {
imports = [
({...}: {
fileSystems."/" = { device = "/dev/disk/by-label/nixos"; fsType = "ext4"; };
boot.loader.grub.device = "/dev/vda"; #lib.mkDefault "/dev/vda";
containers.mail.config = { pkgs, simple-nixos-mailserver, ... }: {
imports = [ simple-nixos-mailserver.nixosModule ];
};
})
];
};
};
};
}
And building that with nixops fails with the infinite recursive error:
nix develop
nixops deploy --build-only
...
… while calling the 'derivationStrict' builtin
at /builtin/derivation.nix:9:12: (source not available)
… while evaluating derivation 'nixops-machines'
whose name attribute is located at /nix/store/l6ymqz1y4fiy57xh6f3y23zwp0i9lr4f-source/pkgs/stdenv/generic/make-derivation.nix:348:7
… while evaluating attribute 'buildCommand' of derivation 'nixops-machines'
at /nix/store/l6ymqz1y4fiy57xh6f3y23zwp0i9lr4f-source/pkgs/build-support/trivial-builders/default.nix:87:14:
86| enableParallelBuilding = true;
87| inherit buildCommand name;
| ^
88| passAsFile = [ "buildCommand" ]
...
… while evaluating the module argument `simple-nixos-mailserver' in ":anon-1541:anon-1":
error: infinite recursion encountered
at /nix/store/l6ymqz1y4fiy57xh6f3y23zwp0i9lr4f-source/lib/modules.nix:506:28:
505| builtins.addErrorContext (context name)
506| (args.${name} or config._module.args.${name})
| ^
507| ) (lib.functionArgs f);
I’m new to Nix, and I feel using flakes in containers is probably quite common. What am I doing wrong ?
Regards