mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-12 03:56:17 +03:00
doc/option-types: Make attrTag example self-contained
... well, except for the ellipses, which hide unnecessary descriptions, which you should write!
This commit is contained in:
parent
c0f54d3dea
commit
fa8b46adf4
@ -323,22 +323,40 @@ If the built-in Nix value types provide enough distinction, you simplify your sy
|
||||
Example:
|
||||
|
||||
```nix
|
||||
types.attrTag {
|
||||
bounce = mkOption {
|
||||
description = "Send back a packet explaining why it wasn't forwarded.";
|
||||
type = submodule {
|
||||
options.errorMessage = mkOption { … };
|
||||
};
|
||||
{ lib, ... }:
|
||||
let inherit (lib) type mkOption;
|
||||
in {
|
||||
options.toyRouter.rules = mkOption {
|
||||
description = ''
|
||||
Rules for a fictional packet routing service.
|
||||
'';
|
||||
type = types.attrsOf (
|
||||
types.attrTag {
|
||||
bounce = mkOption {
|
||||
description = "Send back a packet explaining why it wasn't forwarded.";
|
||||
type = types.submodule {
|
||||
options.errorMessage = mkOption { … };
|
||||
};
|
||||
};
|
||||
forward = mkOption {
|
||||
description = "Forward the packet.";
|
||||
type = types.submodule {
|
||||
options.destination = mkOption { … };
|
||||
};
|
||||
};
|
||||
ignore = types.mkOption {
|
||||
description = "Drop the packet without sending anything back.";
|
||||
type = types.submodule {};
|
||||
};
|
||||
});
|
||||
};
|
||||
forward = mkOption {
|
||||
description = "Forward the packet.";
|
||||
type = submodule {
|
||||
options.destination = mkOption { … };
|
||||
config.toyRouter.rules = {
|
||||
http = {
|
||||
bounce = {
|
||||
errorMessage = "Unencrypted HTTP is banned. You must always use https://.";
|
||||
};
|
||||
};
|
||||
};
|
||||
ignore = mkOption {
|
||||
description = "Drop the packet without sending anything back.";
|
||||
type = submodule {};
|
||||
ssh = { drop = {}; };
|
||||
};
|
||||
}
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user