nixpkgs/nixos/modules/services/x11/window-managers/i3.nix
pennae 2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00

78 lines
2 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.xserver.windowManager.i3;
in
{
options.services.xserver.windowManager.i3 = {
enable = mkEnableOption "i3 window manager";
configFile = mkOption {
default = null;
type = with types; nullOr path;
description = lib.mdDoc ''
Path to the i3 configuration file.
If left at the default value, $HOME/.i3/config will be used.
'';
};
extraSessionCommands = mkOption {
default = "";
type = types.lines;
description = lib.mdDoc ''
Shell commands executed just before i3 is started.
'';
};
package = mkOption {
type = types.package;
default = pkgs.i3;
defaultText = literalExpression "pkgs.i3";
example = literalExpression "pkgs.i3-gaps";
description = lib.mdDoc ''
i3 package to use.
'';
};
extraPackages = mkOption {
type = with types; listOf package;
default = with pkgs; [ dmenu i3status i3lock ];
defaultText = literalExpression ''
with pkgs; [
dmenu
i3status
i3lock
]
'';
description = lib.mdDoc ''
Extra packages to be installed system wide.
'';
};
};
config = mkIf cfg.enable {
services.xserver.windowManager.session = [{
name = "i3";
start = ''
${cfg.extraSessionCommands}
${cfg.package}/bin/i3 ${optionalString (cfg.configFile != null)
"-c /etc/i3/config"
} &
waitPID=$!
'';
}];
environment.systemPackages = [ cfg.package ] ++ cfg.extraPackages;
environment.etc."i3/config" = mkIf (cfg.configFile != null) {
source = cfg.configFile;
};
};
imports = [
(mkRemovedOptionModule [ "services" "xserver" "windowManager" "i3-gaps" "enable" ]
"Use services.xserver.windowManager.i3.enable and set services.xserver.windowManager.i3.package to pkgs.i3-gaps to use i3-gaps.")
];
}