I made a function to generate an import function for a NixOS configuration. I needed to deep-merge several attribute sets, and so I resorted to something like
{ config, pkgs, lib, ... }: lib.mkMerge [
{ imports = [ ./something.nix ]; services.foo.enabled = true; }
(lib.mkIf useCifs { services.foo.bar = 7; })
# ...
]
(simplified for illustration purposes)
Evaluating this with NixOps gave me an error like “imports is not a configuration option”. I tried combining deep an shallow merging but that just moved the problem.
In the end I resolved it by doing
{ config, pkgs, lib, ... }: {
imports = [
./something.nix
({ config, pkgs, lib, ... }: lib.mkIf useCifs { services.foo.bar = 7; })
];
services.foo.enabled = true;
}
It seems that the NixOS configuration can’t be a {_type: 'merge', Contents: ...}
object?
(I’m typing this from memory, I’m just curious)