summary refs log tree commit diff
path: root/nixos/modules/services/x11/window-managers/i3.nix
blob: 510997e76af81f69801f3f3c68bd733eea135b1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.xserver.windowManager.i3;
in

{
  options = {
    services.xserver.windowManager.i3 = {
      enable = mkOption {
        default = false;
        example = true;
        description = "Enable the i3 tiling window manager.";
      };

      configFile = mkOption {
        default = null;
        type = types.nullOr types.path;
        description = ''
          Path to the i3 configuration file.
          If left at the default value, $HOME/.i3/config will be used.
        '';
      };

      debug = mkOption {
        default = false;
        example = true;
        type = types.bool;
        description = "Enable debug/verbose logging (see -V option)";
      };

      logFile = mkOption {
        default = null;
        example = "$HOME/.i3/i3log";
        type = types.string;
        description = ''
          Path to a logfile for i3.
          If left at the default value, logs will appear in display-manager.service's logs.
        '';
      };
    };
  };

  config = mkIf cfg.enable {
    services.xserver.windowManager = {
      session = [{
        name = "i3";
        start = ''
          ${pkgs.i3}/bin/i3 ${optionalString (cfg.configFile != null)
            ''-c "${cfg.configFile}"''
          } ${optionalString cfg.debug
            ''-V''
          } ${optionalString (cfg.logFile != null)
            ''>> "${cfg.logFile}"''
          } &
          waitPID=$!
        '';
      }];
    };
    environment.systemPackages = [ pkgs.i3 ];
  };
}