diff options
author | Silvan Mosberger <contact@infinisil.com> | 2020-04-02 07:39:04 +0200 |
---|---|---|
committer | Silvan Mosberger <contact@infinisil.com> | 2020-04-02 07:49:25 +0200 |
commit | 1d0fc9729dd8564dc75b5fd020da6bd61e0346c0 (patch) | |
tree | 10ee602ed08d5ace4f98cf310cd78fca7e098d0d /nixos/modules/services/network-filesystems | |
parent | f75c11cfdfff3448623250e151cb47df70d4f224 (diff) | |
download | nixpkgs-1d0fc9729dd8564dc75b5fd020da6bd61e0346c0.tar nixpkgs-1d0fc9729dd8564dc75b5fd020da6bd61e0346c0.tar.gz nixpkgs-1d0fc9729dd8564dc75b5fd020da6bd61e0346c0.tar.bz2 nixpkgs-1d0fc9729dd8564dc75b5fd020da6bd61e0346c0.tar.lz nixpkgs-1d0fc9729dd8564dc75b5fd020da6bd61e0346c0.tar.xz nixpkgs-1d0fc9729dd8564dc75b5fd020da6bd61e0346c0.tar.zst nixpkgs-1d0fc9729dd8564dc75b5fd020da6bd61e0346c0.zip |
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.
Diffstat (limited to 'nixos/modules/services/network-filesystems')
-rw-r--r-- | nixos/modules/services/network-filesystems/netatalk.nix | 5 | ||||
-rw-r--r-- | nixos/modules/services/network-filesystems/rsyncd.nix | 5 | ||||
-rw-r--r-- | nixos/modules/services/network-filesystems/samba.nix | 5 |
3 files changed, 9 insertions, 6 deletions
diff --git a/nixos/modules/services/network-filesystems/netatalk.nix b/nixos/modules/services/network-filesystems/netatalk.nix index 1dd869043f0..5422d4dd4e2 100644 --- a/nixos/modules/services/network-filesystems/netatalk.nix +++ b/nixos/modules/services/network-filesystems/netatalk.nix @@ -98,13 +98,14 @@ in Set of AFP volumes to export. See <literal>man apf.conf</literal> for more information. ''; - example = + example = literalExample '' { srv = { path = "/srv"; "read only" = true; "hosts allow" = "10.1.0.0/16 10.2.1.100 2001:0db8:1234::/48"; }; - }; + } + ''; }; extmap = mkOption { diff --git a/nixos/modules/services/network-filesystems/rsyncd.nix b/nixos/modules/services/network-filesystems/rsyncd.nix index b17ec3aa930..ccad64cfdb2 100644 --- a/nixos/modules/services/network-filesystems/rsyncd.nix +++ b/nixos/modules/services/network-filesystems/rsyncd.nix @@ -74,13 +74,14 @@ in See <command>man rsyncd.conf</command> for options. ''; type = types.attrsOf (types.attrsOf types.str); - example = + example = literalExample '' { srv = { path = "/srv"; "read only" = "yes"; comment = "Public rsync share."; }; - }; + } + ''; }; user = mkOption { diff --git a/nixos/modules/services/network-filesystems/samba.nix b/nixos/modules/services/network-filesystems/samba.nix index a3c22ce6948..a115590ccaa 100644 --- a/nixos/modules/services/network-filesystems/samba.nix +++ b/nixos/modules/services/network-filesystems/samba.nix @@ -189,7 +189,7 @@ in See <command>man smb.conf</command> for options. ''; type = types.attrsOf (types.attrsOf types.unspecified); - example = + example = literalExample '' { public = { path = "/srv/public"; "read only" = true; @@ -197,7 +197,8 @@ in "guest ok" = "yes"; comment = "Public samba share."; }; - }; + } + ''; }; }; |