24 lines
617 B
Nix
Raw Normal View History

{ lib, config, ... }:
let
cfg = config.playground.greeter;
in
{
# One option namespace keeps the example focused.
options.playground.greeter = {
enable = lib.mkEnableOption "the playground greeter";
name = lib.mkOption {
type = lib.types.str;
default = "world";
description = "Name placed in the generated /etc/greeting file.";
};
};
# `mkIf` discards the whole config block when enable is false, so a
# system that imports the module but leaves it disabled pays nothing.
config = lib.mkIf cfg.enable {
environment.etc."greeting".text = "hello, ${cfg.name}";
};
}