Skip to content

Mixing Fleet Data with pkgs and config

Write { host, pkgs, lib, config, ... }: directly inside any NixOS or Home Manager aspect — no specialArgs or extraSpecialArgs wiring required. Yen fills the fleet arguments it owns (host, user, settings, sinks, peers) and leaves pkgs, lib, and config open for nixpkgs.lib.nixosSystem or home-manager to supply during evaluation.

modules/fleet.nix
{
yen,
std,
...
}:
{
imports = [ std.modules.all ];
yen.host.web = {
addr = "198.51.100.20";
};
}
modules/aspects.nix
{ yen, ... }:
{
# Mix Yen's `host` data with NixOS's `pkgs` and `lib` in ONE function — zero `specialArgs`!
yen.aspects.web-tools = {
at = yen.kinds.host;
nixos =
{
host,
pkgs,
lib,
...
}:
{
networking.hostName = lib.mkDefault host.name;
environment.variables.HOST_ADDR = host.addr;
environment.systemPackages = [ pkgs.curl ];
};
};
}

When nixosSystem evaluates the module, both Yen’s fleet fields and NixOS’s pkgs/lib/config resolve seamlessly:

nix eval .#nixos.web
{
environment = {
systemPackages = [ "pkgs.curl" ];
variables = {
HOST_ADDR = "198.51.100.20";
};
};
networking = {
hostName = "web";
};
}
  • Any enclosing kind name: host, mac, user, home, machine, disk, etc.
  • Current context: scope, settings, peers (inside kits), sinks (and any individual sink name like osConfig or aiMcp).
  • Custom flake args: anything passed via yen.mkFlake { inherit inputs myLib; } ./modules.
  • Untouched NixOS/HM args: pkgs, lib, config, options, modulesPath are passed straight through to evalModules.

Plugging one host into an existing flake.nix

Section titled “Plugging one host into an existing flake.nix”

You do not have to move nixosConfigurations into Yen right away. Every evaluated fleet automatically exposes a ready-to-import NixOS/HM module per target at .#yen.targets.<kind>.<name>.module:

nixosConfigurations.web = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./hardware-configuration.nix
self.yen.targets.host.web.module
];
};

Next, see how reactive cycle components inspect the whole fleet and wrap upstream modules in Reactive Fleet Patterns & Middleware (cycle).

ContributeCommunitySponsor