!UKDpaKNNsBpOPfLWfX:zhaofeng.li

Colmena

329 Members
A simple, stateless NixOS deployment tool - https://github.com/zhaofengli/colmena116 Servers

Load older messages


SenderMessageTime
21 Oct 2022
@yuka:yuka.dev@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
@whentze:matrix.orgWanja Hentze oh yes, makeHive is a major improvement already 11:31:15
@yuka:yuka.dev@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@yuka:yuka.devso there is still room for improvement11:52:27
@whentze:matrix.orgWanja HentzeI keep wanting a multi-host service abstraction11:52:57
@whentze:matrix.orgWanja Hentzewe have a few of these strung about in an ad-hoc manner in this codebase11:53:07
@whentze:matrix.orgWanja Hentzebut they're all bad in different ways11:53:14
@yuka:yuka.dev@yuka:yuka.devyou can already kinda do that with hive by accessing the nodes specialArgs attribute11:53:19
@whentze:matrix.orgWanja Hentzeyes, we have that11:53:28
@whentze:matrix.orgWanja Hentzeand some ad-hoc conventions on top11:53:33
@whentze:matrix.orgWanja Hentzesometimes we filter nodes by name, other times by tag etc.11:53:55
@yuka:yuka.dev@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
@whentze:matrix.orgWanja Hentzeo nice11:54:17
@yuka:yuka.dev@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@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@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@yuka:yuka.devmakes some of the modules way cleaner11:56:02
@whentze:matrix.orgWanja Hentzethis just makes one group per tag, right?11:56:32
@yuka:yuka.dev@yuka:yuka.devyes11:56:43
@yuka:yuka.dev@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
@whentze:matrix.orgWanja HentzeI might steal this ┏ʕ •ᴥ•ʔ┛11:58:52
@yuka:yuka.dev@yuka:yuka.devfeel free to11:59:07
@yuka:yuka.dev@yuka:yuka.devbut also I'll try to get my module based hive thing into shape and make a repo somewhere11:59:36
@yuka:yuka.dev@yuka:yuka.devnot sure really what modules would work better on that layer11:59:50
@yuka:yuka.dev@yuka:yuka.dev Wanja Hentze: do you have an idea for a name for the module system hive thingy? 12:37:56
@whentze:matrix.orgWanja Hentze😬12:38:08
@yuka:yuka.dev@yuka:yuka.devcoming up with names is hard12:38:14
@whentze:matrix.orgWanja Hentzeoh no, my sole weakness12:38:18
@yuka:yuka.dev@yuka:yuka.devbut I need a name to publish it in a repo12:38:22
@yuka:yuka.dev@yuka:yuka.devcurrently it is hive-modules/yuka-hive.nix12:38:34

Show newer messages


Back to Room ListRoom Version: 6