infra/flake/den/templates/examples/modules/_example/ci/user-host-conditional-os.nix

39 lines
861 B
Nix
Raw Normal View History

2025-12-01 13:23:24 +07:00
{ lib, ... }:
let
# Example: configuration that depends on both host and user. provides anytime { user, host } is in context.
user-to-host-conditional =
{ user, host, ... }:
if user.userName == "alice" && !lib.hasSuffix "darwin" host.system then
{
nixos.programs.tmux.enable = true;
}
else
{ };
in
{
# Example: user provides parametric host configuration.
den.aspects.alice.includes = [
user-to-host-conditional
];
perSystem =
{
checkCond,
rockhopper,
honeycrisp,
...
}:
{
checks.alice-os-tmux-enabled-on = checkCond "os tmux for hosts having alice" (
rockhopper.config.programs.tmux.enable
);
checks.alice-os-tmux-enabled-off = checkCond "os tmux for hosts having alice" (
!honeycrisp.config.programs.tmux.enable
);
};
}