Skip to content

Bubbling unfree, Firewall, Secrets & Persist

std.modules.resources (included in std.modules.all) puts shared resource sinks directly onto every machine, user, and place. A Home Manager aspect can declare "vscode" in unfree right beside installing it, and a service aspect can declare its firewall port, /persist directory, and secret in the same file — Yen bubbles user needs upward and checks for duplicate names automatically.

modules/fleet.nix
{ yen, ... }:
{
yen.user.dev.email = "dev@example.org";
yen.host.box = {
addr = "198.51.100.10";
users = [ yen.user.dev ];
};
# A user feature declares `"vscode"` unfree right beside installing it — it bubbles to `box`!
yen.aspects.code-editor = {
at = yen.user.dev;
unfree = [ "vscode" ];
hm.programs.vscode.enable = true;
};
# A service declares its port, secret, and /persist folder all in one aspect.
yen.aspects.app-service = {
at = yen.host.box;
firewall.tcp = [ 8080 ];
persist.directories = [ "/var/lib/app" ];
services.app.port = 8080;
secrets."app-key".path = "/run/secrets/app-key";
};
}

Notice code-editor runs on yen.user.dev, yet "vscode" lands in box’s unfree list automatically:

nix eval .#unfree + .#firewall + .#persist + .#services + .#secrets
{
firewall = {
box = [ 8080 ];
};
persist = {
box = [ "/var/lib/app" ];
};
secrets = {
box = {
app-key = {
path = "/run/secrets/app-key";
};
};
};
services = {
box = {
app = {
port = 8080;
};
};
};
unfree = {
box = [ "vscode" ];
};
}

Three one-line helpers in std.lib convert those sinks into real NixOS modules (zero boilerplate per host):

yen.kinds.host.sinks = {
firewall.into.nixos = std.lib.firewallModule { from = yen.kinds.machine.sinks.firewall; };
persist.into.nixos = std.lib.persistModule { from = yen.kinds.machine.sinks.persist; };
unfree.into.nixos = std.lib.nixpkgsModule {
unfreeFrom = yen.kinds.place.sinks.unfree;
overlaysFrom = yen.kinds.place.sinks.overlays;
};
};
Sink Combine rule What it collects
unfree, insecure reduce.flat Package names whitelisted via std.lib.nixpkgsModule
overlays reduce.list (raw = true) Nixpkgs overlays attached by any host or user feature
firewall reduce.list { tcp = [...]; udp = [...]; } rules fed to std.lib.firewallModule
persist, cache reduce.list Impermanence directories and files fed to std.lib.persistModule
services, secrets reduce.keyed (x: x.name) Unique per-host registries — duplicate names fail closed (key-conflict)
persistHome, cacheHome, liveLinks User-level lists / merge Home persistence and live dotfile symlinks
homebrew reduce.merge macOS Homebrew brews and casks
fleetServices reduce.keyed Whole-fleet service directory keyed by host:name

Every std kind and sink is listed in Std Kinds & Sinks Reference.

Next, package multi-host services into reusable blueprints in Building Composable Kits & Assemblies.

ContributeCommunitySponsor