forked from mirrors/nixpkgs
nixos/treewide: Fix incorrectly rendered examples
Many options define their example to be a Nix value without using literalExample. This sometimes gets rendered incorrectly in the manual, causing confusion like in https://github.com/NixOS/nixpkgs/issues/25516 This fixes it by using literalExample for such options. The list of option to fix was determined with this expression: let nixos = import ./nixos { configuration = {}; }; lib = import ./lib; valid = d: { # escapeNixIdentifier from https://github.com/NixOS/nixpkgs/pull/82461 set = lib.all (n: lib.strings.escapeNixIdentifier n == n) (lib.attrNames d) && lib.all (v: valid v) (lib.attrValues d); list = lib.all (v: valid v) d; }.${builtins.typeOf d} or true; optionList = lib.optionAttrSetToDocList nixos.options; in map (opt: { file = lib.elemAt opt.declarations 0; loc = lib.options.showOption opt.loc; }) (lib.filter (opt: if opt ? example then ! valid opt.example else false) optionList) which when evaluated will output all options that use a Nix identifier that would need escaping as an attribute name.
This commit is contained in:
parent
f75c11cfdf
commit
1d0fc9729d
|
@ -63,9 +63,11 @@ in {
|
||||||
javaProperties = mkOption {
|
javaProperties = mkOption {
|
||||||
type = types.attrs;
|
type = types.attrs;
|
||||||
default = { };
|
default = { };
|
||||||
example = {
|
example = literalExample ''
|
||||||
|
{
|
||||||
"java.net.preferIPv4Stack" = "true";
|
"java.net.preferIPv4Stack" = "true";
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
apply = attrs: {
|
apply = attrs: {
|
||||||
"activemq.base" = "${cfg.baseDir}";
|
"activemq.base" = "${cfg.baseDir}";
|
||||||
"activemq.data" = "${cfg.baseDir}/data";
|
"activemq.data" = "${cfg.baseDir}/data";
|
||||||
|
|
|
@ -138,7 +138,11 @@ in {
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
default = {};
|
default = {};
|
||||||
example."pool/test".target = "root@target:pool/test";
|
example = literalExample ''
|
||||||
|
{
|
||||||
|
"pool/test".target = "root@target:pool/test";
|
||||||
|
}
|
||||||
|
'';
|
||||||
description = "Syncoid commands to run.";
|
description = "Syncoid commands to run.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,33 +7,41 @@ with lib;
|
||||||
options.services.hadoop = {
|
options.services.hadoop = {
|
||||||
coreSite = mkOption {
|
coreSite = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
example = {
|
example = literalExample ''
|
||||||
|
{
|
||||||
"fs.defaultFS" = "hdfs://localhost";
|
"fs.defaultFS" = "hdfs://localhost";
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
description = "Hadoop core-site.xml definition";
|
description = "Hadoop core-site.xml definition";
|
||||||
};
|
};
|
||||||
|
|
||||||
hdfsSite = mkOption {
|
hdfsSite = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
example = {
|
example = literalExample ''
|
||||||
|
{
|
||||||
"dfs.nameservices" = "namenode1";
|
"dfs.nameservices" = "namenode1";
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
description = "Hadoop hdfs-site.xml definition";
|
description = "Hadoop hdfs-site.xml definition";
|
||||||
};
|
};
|
||||||
|
|
||||||
mapredSite = mkOption {
|
mapredSite = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
example = {
|
example = literalExample ''
|
||||||
|
{
|
||||||
"mapreduce.map.cpu.vcores" = "1";
|
"mapreduce.map.cpu.vcores" = "1";
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
description = "Hadoop mapred-site.xml definition";
|
description = "Hadoop mapred-site.xml definition";
|
||||||
};
|
};
|
||||||
|
|
||||||
yarnSite = mkOption {
|
yarnSite = mkOption {
|
||||||
default = {};
|
default = {};
|
||||||
example = {
|
example = literalExample ''
|
||||||
|
{
|
||||||
"yarn.resourcemanager.ha.id" = "resourcemanager1";
|
"yarn.resourcemanager.ha.id" = "resourcemanager1";
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
description = "Hadoop yarn-site.xml definition";
|
description = "Hadoop yarn-site.xml definition";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -98,13 +98,14 @@ in
|
||||||
Set of AFP volumes to export.
|
Set of AFP volumes to export.
|
||||||
See <literal>man apf.conf</literal> for more information.
|
See <literal>man apf.conf</literal> for more information.
|
||||||
'';
|
'';
|
||||||
example =
|
example = literalExample ''
|
||||||
{ srv =
|
{ srv =
|
||||||
{ path = "/srv";
|
{ path = "/srv";
|
||||||
"read only" = true;
|
"read only" = true;
|
||||||
"hosts allow" = "10.1.0.0/16 10.2.1.100 2001:0db8:1234::/48";
|
"hosts allow" = "10.1.0.0/16 10.2.1.100 2001:0db8:1234::/48";
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
extmap = mkOption {
|
extmap = mkOption {
|
||||||
|
|
|
@ -74,13 +74,14 @@ in
|
||||||
See <command>man rsyncd.conf</command> for options.
|
See <command>man rsyncd.conf</command> for options.
|
||||||
'';
|
'';
|
||||||
type = types.attrsOf (types.attrsOf types.str);
|
type = types.attrsOf (types.attrsOf types.str);
|
||||||
example =
|
example = literalExample ''
|
||||||
{ srv =
|
{ srv =
|
||||||
{ path = "/srv";
|
{ path = "/srv";
|
||||||
"read only" = "yes";
|
"read only" = "yes";
|
||||||
comment = "Public rsync share.";
|
comment = "Public rsync share.";
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
user = mkOption {
|
user = mkOption {
|
||||||
|
|
|
@ -189,7 +189,7 @@ in
|
||||||
See <command>man smb.conf</command> for options.
|
See <command>man smb.conf</command> for options.
|
||||||
'';
|
'';
|
||||||
type = types.attrsOf (types.attrsOf types.unspecified);
|
type = types.attrsOf (types.attrsOf types.unspecified);
|
||||||
example =
|
example = literalExample ''
|
||||||
{ public =
|
{ public =
|
||||||
{ path = "/srv/public";
|
{ path = "/srv/public";
|
||||||
"read only" = true;
|
"read only" = true;
|
||||||
|
@ -197,7 +197,8 @@ in
|
||||||
"guest ok" = "yes";
|
"guest ok" = "yes";
|
||||||
comment = "Public samba share.";
|
comment = "Public samba share.";
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -334,10 +334,12 @@ in {
|
||||||
nsrecord = mkOption {
|
nsrecord = mkOption {
|
||||||
type = types.attrsOf types.str;
|
type = types.attrsOf types.str;
|
||||||
default = { };
|
default = { };
|
||||||
example = {
|
example = literalExample ''
|
||||||
|
{
|
||||||
"files.local" = "192.168.1.12";
|
"files.local" = "192.168.1.12";
|
||||||
"site.local" = "192.168.1.43";
|
"site.local" = "192.168.1.43";
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
description = "Adds static nsrecords.";
|
description = "Adds static nsrecords.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -61,10 +61,12 @@ in {
|
||||||
Table of {hostname: server} pairs to use as authoritative servers for hosts (and subhosts).
|
Table of {hostname: server} pairs to use as authoritative servers for hosts (and subhosts).
|
||||||
If entry for @ is not specified predefined list of root servers is used.
|
If entry for @ is not specified predefined list of root servers is used.
|
||||||
'';
|
'';
|
||||||
example = {
|
example = literalExample ''
|
||||||
|
{
|
||||||
"@" = ["8.8.8.8" "8.8.4.4"];
|
"@" = ["8.8.8.8" "8.8.4.4"];
|
||||||
"example.com" = ["192.168.100.100"];
|
"example.com" = ["192.168.100.100"];
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
forwardOnly = mkOption {
|
forwardOnly = mkOption {
|
||||||
|
|
|
@ -142,7 +142,11 @@ in {
|
||||||
messages, and respond to them according to a set of rules.
|
messages, and respond to them according to a set of rules.
|
||||||
'';
|
'';
|
||||||
default = {};
|
default = {};
|
||||||
example = { eth0.rules."1111::/64" = {}; };
|
example = literalExample ''
|
||||||
|
{
|
||||||
|
eth0.rules."1111::/64" = {};
|
||||||
|
}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ let
|
||||||
|
|
||||||
inherit (builtins) toFile;
|
inherit (builtins) toFile;
|
||||||
inherit (lib) concatMapStringsSep concatStringsSep mapAttrsToList
|
inherit (lib) concatMapStringsSep concatStringsSep mapAttrsToList
|
||||||
mkIf mkEnableOption mkOption types;
|
mkIf mkEnableOption mkOption types literalExample;
|
||||||
|
|
||||||
cfg = config.services.strongswan;
|
cfg = config.services.strongswan;
|
||||||
|
|
||||||
|
@ -79,7 +79,8 @@ in
|
||||||
connections = mkOption {
|
connections = mkOption {
|
||||||
type = types.attrsOf (types.attrsOf types.str);
|
type = types.attrsOf (types.attrsOf types.str);
|
||||||
default = {};
|
default = {};
|
||||||
example = {
|
example = literalExample ''
|
||||||
|
{
|
||||||
"%default" = {
|
"%default" = {
|
||||||
keyexchange = "ikev2";
|
keyexchange = "ikev2";
|
||||||
keyingtries = "1";
|
keyingtries = "1";
|
||||||
|
@ -91,7 +92,8 @@ in
|
||||||
leftsubnet = "10.1.0.0/16";
|
leftsubnet = "10.1.0.0/16";
|
||||||
right = "%any";
|
right = "%any";
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
description = ''
|
description = ''
|
||||||
A set of connections and their options for the ‘conn xxx’
|
A set of connections and their options for the ‘conn xxx’
|
||||||
sections of the <filename>ipsec.conf</filename> file.
|
sections of the <filename>ipsec.conf</filename> file.
|
||||||
|
|
|
@ -169,12 +169,14 @@ in {
|
||||||
description = ''
|
description = ''
|
||||||
folders which should be shared by syncthing.
|
folders which should be shared by syncthing.
|
||||||
'';
|
'';
|
||||||
example = {
|
example = literalExample ''
|
||||||
|
{
|
||||||
"/home/user/sync" = {
|
"/home/user/sync" = {
|
||||||
id = "syncme";
|
id = "syncme";
|
||||||
devices = [ "bigbox" ];
|
devices = [ "bigbox" ];
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
type = types.attrsOf (types.submodule ({ name, ... }: {
|
type = types.attrsOf (types.submodule ({ name, ... }: {
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,11 @@ in
|
||||||
https://www.jetbrains.com/help/youtrack/standalone/YouTrack-Java-Start-Parameters.html
|
https://www.jetbrains.com/help/youtrack/standalone/YouTrack-Java-Start-Parameters.html
|
||||||
for more information.
|
for more information.
|
||||||
'';
|
'';
|
||||||
example = {
|
example = literalExample ''
|
||||||
|
{
|
||||||
"jetbrains.youtrack.overrideRootPassword" = "tortuga";
|
"jetbrains.youtrack.overrideRootPassword" = "tortuga";
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
type = types.attrsOf types.str;
|
type = types.attrsOf types.str;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -609,9 +609,11 @@ in
|
||||||
bindMounts = mkOption {
|
bindMounts = mkOption {
|
||||||
type = with types; loaOf (submodule bindMountOpts);
|
type = with types; loaOf (submodule bindMountOpts);
|
||||||
default = {};
|
default = {};
|
||||||
example = { "/home" = { hostPath = "/home/alice";
|
example = literalExample ''
|
||||||
|
{ "/home" = { hostPath = "/home/alice";
|
||||||
isReadOnly = false; };
|
isReadOnly = false; };
|
||||||
};
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
description =
|
description =
|
||||||
''
|
''
|
||||||
|
|
Loading…
Reference in a new issue