!UKDpaKNNsBpOPfLWfX:zhaofeng.li

Colmena

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

You have reached the beginning of time (for this room).


SenderMessageTime
16 Nov 2024
@rcouto:matrix.org@rcouto:matrix.org joined the room.21:35:13
@inomena:matrix.orginomena joined the room.22:45:18
@inomena:matrix.orginomena hi, looking at the docs w/flakes each host is defined in outputs.colmena.<hostname> similar to nixosConfigurations, but is it possible to instead read each host's configuration from separate files?
e.g. instead of outputs.colmena.host-a and outputs.colmena.host-b I could refer to files hosts/host-a.nix and hosts/host-b.nix (and all possible hosts within the hosts/ directory without specifying each one in flake.nix)
22:49:07
@inomena:matrix.orginomena I would still want to use outputs.colmena.meta and outputs.colmena.defaults in this scenario 22:51:13
17 Nov 2024
@inomena:matrix.orginomena

think I figured it out, or atleast it seems to work:

outputs = {nixpkgs, ...}:
  let
    hosts = nixpkgs.lib.mapAttrs'
      (filename: _: {
        name = nixpkgs.lib.nameFromURL filename ".";
        value = [ ./hosts/${filename} ];
      })
      (builtins.readDir ./hosts);
  in {
    colmena = hosts // {
      # ...
    };
};
08:39:26
@ibizaman:matrix.orgibizaman
In reply to @inomena:matrix.org

think I figured it out, or atleast it seems to work:

outputs = {nixpkgs, ...}:
  let
    hosts = nixpkgs.lib.mapAttrs'
      (filename: _: {
        name = nixpkgs.lib.nameFromURL filename ".";
        value = [ ./hosts/${filename} ];
      })
      (builtins.readDir ./hosts);
  in {
    colmena = hosts // {
      # ...
    };
};
Oh nice you went the extra mile with readDir. I was going to suggest plain imports but that works well!
08:57:01
@inomena:matrix.orginomenaI wanted it to be fully dynamic, so that the only thing I need to do to add a new host to the hive is to define a single <hostname>.nix file in the hosts dir and nothing else08:57:56

Show newer messages


Back to Room ListRoom Version: 6