nixpkgs/nixos/modules
Silvan Mosberger 1d0fc9729d
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.
2020-04-02 07:49:25 +02:00
..
config nixos: add freedesktop/gnome/myself maintainers 2020-04-01 20:53:09 -04:00
hardware nixos/iio: adjust formatting of option description. 2020-04-01 18:37:52 +00:00
i18n/input-method nixos/ibus: add ibus portal if portals are enabled 2020-03-28 18:09:26 -04:00
installer nixos-option: Disable on Nix >= 2.4 because it doesn't compile 2020-03-20 14:52:22 +01:00
misc services/misc/nixos-manual.nix: Remove 2020-03-24 15:25:20 +01:00
profiles Remove unused 'rogue' service 2020-03-24 15:25:20 +01:00
programs nixos: add freedesktop/gnome/myself maintainers 2020-04-01 20:53:09 -04:00
security nixos/acme: don't depend on multi-user.target inside a container 2020-03-29 19:59:52 +02:00
services nixos/treewide: Fix incorrectly rendered examples 2020-04-02 07:49:25 +02:00
system nixos/systemd: remove one DefaultBlockIOAccounting 2020-03-29 10:56:34 +02:00
tasks Merge pull request #81161 from wedens/libvirt-6.0.0 2020-03-30 13:19:00 +00:00
testing nixos/service-runner.nix: Allow quotes in commands + test 2020-02-28 14:26:29 +01:00
virtualisation nixos/treewide: Fix incorrectly rendered examples 2020-04-02 07:49:25 +02:00
module-list.nix Merge pull request #84037 from worldofpeace/remove-none.nix 2020-04-01 22:00:47 -04:00
rename.nix nixos: fix module paths in rename.nix 2020-03-11 15:59:22 +01:00