| 21 Oct 2022 |
@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 |
@yuka:yuka.dev | * I also generate a groups module arg:
{ lib, ... }@args:
{
_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:52 |
@yuka:yuka.dev | makes some of the modules way cleaner | 11:56:02 |
Wanja Hentze | this just makes one group per tag, right? | 11:56:32 |
@yuka:yuka.dev | yes | 11:56:43 |
@yuka:yuka.dev | like the wireguard module just adds deployment.tags = [ "wireguard" ]; and then accesses groups.wireguard to get all the hosts that have the module enabled (it should mesh to) | 11:57:13 |
Wanja Hentze | I might steal this ┏ʕ •ᴥ•ʔ┛ | 11:58:52 |
@yuka:yuka.dev | feel free to | 11:59:07 |
@yuka:yuka.dev | but also I'll try to get my module based hive thing into shape and make a repo somewhere | 11:59:36 |
@yuka:yuka.dev | not sure really what modules would work better on that layer | 11:59:50 |
@yuka:yuka.dev | Wanja Hentze: do you have an idea for a name for the module system hive thingy? | 12:37:56 |
Wanja Hentze | 😬 | 12:38:08 |
@yuka:yuka.dev | coming up with names is hard | 12:38:14 |
Wanja Hentze | oh no, my sole weakness | 12:38:18 |
@yuka:yuka.dev | but I need a name to publish it in a repo | 12:38:22 |
@yuka:yuka.dev | currently it is hive-modules/yuka-hive.nix | 12:38:34 |