| 16 Nov 2024 |
| @rcouto:matrix.org joined the room. | 21:35:13 |
| inomena joined the room. | 22:45:18 |
inomena | 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 | I would still want to use outputs.colmena.meta and outputs.colmena.defaults in this scenario | 22:51:13 |
| 17 Nov 2024 |
inomena | 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 | 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 | I 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 else | 08:57:56 |