1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.xserver.windowManager.herbstluftwm;
7in
8
9{
10 options = {
11 services.xserver.windowManager.herbstluftwm = {
12 enable = mkEnableOption (lib.mdDoc "herbstluftwm");
13
14 package = mkOption {
15 type = types.package;
16 default = pkgs.herbstluftwm;
17 defaultText = literalExpression "pkgs.herbstluftwm";
18 description = lib.mdDoc ''
19 Herbstluftwm package to use.
20 '';
21 };
22
23 configFile = mkOption {
24 default = null;
25 type = with types; nullOr path;
26 description = lib.mdDoc ''
27 Path to the herbstluftwm configuration file. If left at the
28 default value, $XDG_CONFIG_HOME/herbstluftwm/autostart will
29 be used.
30 '';
31 };
32 };
33 };
34
35 config = mkIf cfg.enable {
36 services.xserver.windowManager.session = singleton {
37 name = "herbstluftwm";
38 start =
39 let configFileClause = optionalString
40 (cfg.configFile != null)
41 ''-c "${cfg.configFile}"''
42 ;
43 in "${cfg.package}/bin/herbstluftwm ${configFileClause}";
44 };
45 environment.systemPackages = [ cfg.package ];
46 };
47}