Flake outputs
yen does not know what a flake is. The root kind declares an out sink,
and yen.flake gives the flake’s outputs. Each sink with an out key gives its part.
# The `out` sink of the root is the flake: `yen.flake` gives it.{ yen, ... }:{ yen.kinds.fleet = { spawns.host = _: yen.host; sinks.out.reduce = yen.lib.reduce.merge; # (1) }; yen.kinds.host.sinks.services.out = # (2) { host, services, ... }: { services.${host.name} = services; }; yen.fleet.main = { }; yen.host.web = { }; yen.host.db = { }; yen.flake = { out, ... }: out; # (3)}(1) declares the out sink of the root, and it merges what it receives. (2) is a sink with an out key:
it gives services to the flake. (3) makes the flake the value of that out sink.
Read the outputs
Section titled “Read the outputs”The out arg is the flake itself, read lazily. An aspect can build on other outputs without inputs.self:
{ yen, lib, ... }:{ yen.aspects.nginx = { at = yen.host.web; services = "nginx"; }; yen.aspects.postgres = { at = yen.host.db; services = "postgres"; }; # the `out` arg: an element reads the flake outputs, lazily. No `inputs.self`. yen.aspects.inventory = { at = yen.kinds.fleet; out = { out, ... }: # (1) { inventory = lib.concatLists (lib.attrValues out.services); # (2) }; };}(1) asks for out, the arg that holds the flake. (2) reads the services output of the hosts.
This is the flake:
{ checks = { aarch64-darwin = { yen-lean = <derivation yen-lean-verdict>; }; aarch64-linux = { yen-lean = <derivation yen-lean-verdict>; }; x86_64-linux = { yen-lean = <derivation yen-lean-verdict>; }; }; inventory = [ "postgres" "nginx" ]; services = { db = [ "postgres" ]; web = [ "nginx" ]; };}checks.<system>.yen-lean is in every flake whose inputs has nixpkgs: the Lean checker on the
fleet’s verdict, so nix flake check always checks the rules.
With or without flakes
Section titled “With or without flakes”(import yen).lib.mkFlake sinks module gives the flake outputs. (import yen).lib.eval module gives every query,
and flake is one of them. Each key of sinks is a module sink: mkFlake sinks m is the flake of a root module
that imports sinks and m, and declares each key of sinks in yen.sinks.
Project layout shows both ways in a project. The out sink above uses merge;
Sinks lists the reducers.