| 21 Oct 2022 |
@yuka:yuka.dev | this has improved a lot already recently | 08:14:40 |
Wanja Hentze | care to explain? | 08:15:07 |
@yuka:yuka.dev | there are several representations that get produced along the way:
- your colmena hive (the original representation, what you would put in hive.nix with meta and your hosts as attributes)
- somewhere in between there is also a nixos module system to eval just the meta section (let it have defaults, etc.)
- nodes attrset (which is very similar to nixosConfigurations) + some specific meta attributes
- the colmenaEval attrset, which is what the colmena cli needs to do its job
now all these transitions between the representation are currently quite entangled into one big nix function that goes all the way from your colmena hive to colmenaEval
what has improved lately is, that you can decide to call this makeHive function yourself and provide colmena a pre-processed colmenaEval attrset
this also makes it possible to write other functions that produce the same format, but from a different source format
| 08:27:04 |
@yuka:yuka.dev | and now we can write other useful functions to transform between these representations:
- pre-existing nixosConfigurations + nixos module system for metaOptions -> colmenaEval ; with this we can use the colmena cli together with a pre-existing nixosConfigurations definition. use colmena cli without the hive concept, or with a different hive mechanism
- colmena hive -> nixosConfigurations ; use colmena hives with nixos-rebuild, very simple to implement with makeHive
and so on
| 08:36:59 |
@yuka:yuka.dev | * there are several representations that get produced along the way:
- your colmena hive (the original representation, what you would put in hive.nix with meta, defaults and your hosts as attributes)
- somewhere in between there is also a nixos module system to eval just the meta section (give it type checking, default values, etc.)
- nodes attrset (which is very similar to nixosConfigurations) + some specific meta attributes
- the colmenaEval attrset, which is what the colmena cli needs to do its job
now all these transitions between the representation are currently quite entangled into one big nix function that goes all the way from your colmena hive to colmenaEval
what has improved lately is, that you can decide to call this makeHive function yourself and provide colmena a pre-processed colmenaEval attrset
this also makes it possible to write other functions that produce the same format, but from a different source format
| 08:43:42 |
Wanja Hentze | oh yes, makeHive is a major improvement already | 11:31:15 |
@yuka:yuka.dev | Yes, but colmenaEval is really just nixosConfigurations in a trench coat, and so conversion functions from/to nixosConfigurations could be useful | 11:52:20 |
@yuka:yuka.dev | so there is still room for improvement | 11:52:27 |
Wanja Hentze | I keep wanting a multi-host service abstraction | 11:52:57 |
Wanja Hentze | we have a few of these strung about in an ad-hoc manner in this codebase | 11:53:07 |
Wanja Hentze | but they're all bad in different ways | 11:53:14 |
@yuka:yuka.dev | you can already kinda do that with hive by accessing the nodes specialArgs attribute | 11:53:19 |
Wanja Hentze | yes, we have that | 11:53:28 |
Wanja Hentze | and some ad-hoc conventions on top | 11:53:33 |
Wanja Hentze | sometimes we filter nodes by name, other times by tag etc. | 11:53:55 |
@yuka:yuka.dev | I also generate a groups module arg:
_module.args.groups = let
tagNames = lib.unique (
lib.concatLists (
lib.mapAttrsToList (
name: host: host.config.deployment.tags
) args.nodes
)
);
in lib.genAttrs tagNames (
tagName: lib.filter (
host: lib.elem tagName host.config.deployment.tags
) (
lib.attrValues args.nodes
)
);
| 11:54:09 |
Wanja Hentze | o nice | 11:54:17 |
@yuka:yuka.dev | * I also generate a groups module arg:
{ ... }@attrs:
{
_module.args.groups = let
tagNames = lib.unique (
lib.concatLists (
lib.mapAttrsToList (
name: host: host.config.deployment.tags
) args.nodes
)
);
in lib.genAttrs tagNames (
tagName: lib.filter (
host: lib.elem tagName host.config.deployment.tags
) (
lib.attrValues args.nodes
)
);
}
| 11:55:28 |
@yuka:yuka.dev | * I also generate a groups module arg:
{ lib, ... }@attrs:
{
_module.args.groups = let
tagNames = lib.unique (
lib.concatLists (
lib.mapAttrsToList (
name: host: host.config.deployment.tags
) args.nodes
)
);
in lib.genAttrs tagNames (
tagName: lib.filter (
host: lib.elem tagName host.config.deployment.tags
) (
lib.attrValues args.nodes
)
);
}
| 11:55:40 |