Closed ser closed 1 month ago
Something as simple as:
{
meta = {};
defaults = { config, pkgs, lib, modulesPath, builtins, ... }: {};
} // (import ./srv.nix)
should work. This isn't a colmena thing, but a nix thing: as "hives" are just attrsets, you can use the attrset update syntax.
Sorry, but it does not work.
error: attempt to call something which is not a function but a set
Your minimized example totally does work (up to a point, because node configurations are empty):
$ cat hive.nix
{
meta = {};
defaults = { config, pkgs, lib, modulesPath, builtins, ... }: {};
} // (import ./srv.nix)
$ cat srv.nix
{
srv1 = { config, pkgs, lib, modulesPath, builtins, ... }: {};
srv2 = { config, pkgs, lib, modulesPath, builtins, ... }: {};
}
$ colmena build -v
[INFO ] Using configuration: /home/justinas/ser/hive.nix
[INFO ] Enumerating nodes...
[INFO ] Selected all 2 nodes.
(...) | Evaluating srv1 and srv2
(...) | trace: warning: system.stateVersion is not set, defaulting to 24.05. Read why this matters on https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion.
(...) | error:
(...) | … while evaluating attribute 'srv1'
(...) |
(...) | at «none»:0: (source not available)
(...) |
(...) | … while calling the 'head' builtin
(...) |
(...) | at /nix/store/w6w8z9w6ywpfvy8pjwsky51hc8xj0ilx-6c9x72i5sf121x2r7vfm6fj57aw2sx33-nixos-24.05-2024-07-25/lib/attrsets.nix:1575:11:
(...) |
(...) | 1574| || pred here (elemAt values 1) (head values) then
(...) | 1575| head values
(...) | | ^
(...) | 1576| else
(...) |
(...) | (stack trace truncated; use '--show-trace' to show the full trace)
(...) |
(...) | error:
(...) | Failed assertions:
(...) | - The ‘fileSystems’ option does not specify your root file system.
(...) | - You must set the option ‘boot.loader.grub.devices’ or 'boot.loader.grub.mirroredBoots' to make the system bootable.
(...) | Evaluation failed: Child process exited with error code: 1
| Failed: Child process exited with error code: 1
<...>
If you are having additional errors, it is likely because of something that is in your configuration. There's no way to tell from your example.
OK, thanks for an example, now I can understand that //
is not a comment but part of nixos language - I would never expect that :-)
So yes, I was able to finally split long hive.nix in this way:
{
meta = {};
defaults = { config, pkgs, lib, modulesPath, builtins, ... }: {};
}
// ( import ./srv.nix )
// ( import ./othersrv.nix )
// ( import ./dnsserv.nix )
In my opinion Colmena documentation should include such a use case with good practices, as not every Colmena user must be a nixos expert, there are also just users like me...
Thanks.
Splitting hive.nix file into groups of hosts is not documented and I have no idea how to make it.
What i want is to have a short
hive.nix
file like this:and for example a group of hosts file
srv.nix
like this:Question is - how to properly include
srv.nix
inhive.nix
?