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
..
2019-06-07 13:02:51 +02:00
2020-03-26 09:28:42 +01:00
2020-02-09 21:55:27 +01:00
2020-02-09 21:55:27 +01:00
2020-01-31 20:39:12 -05:00
2019-11-18 14:52:47 +01:00
2020-01-31 20:39:12 -05:00
2019-04-29 14:05:50 +02:00
2019-10-25 17:51:09 +02:00
2020-01-31 20:39:12 -05:00
2019-10-28 21:34:55 +01:00
2019-09-08 23:38:31 +00:00
2019-09-22 18:48:07 +02:00
2019-11-03 17:24:08 +01:00
2019-09-17 00:23:51 +00:00
2019-10-12 22:25:28 +02:00
2020-01-31 20:39:12 -05:00
2020-01-31 20:39:12 -05:00