1 { config, lib, pkgs, ... }:
6 cfg = config.services.xserver.windowManager.i3;
7 updateSessionEnvironmentScript = ''
8 systemctl --user import-environment PATH DISPLAY XAUTHORITY DESKTOP_SESSION XDG_CONFIG_DIRS XDG_DATA_DIRS XDG_RUNTIME_DIR XDG_SESSION_ID DBUS_SESSION_BUS_ADDRESS || true
9 dbus-update-activation-environment --systemd --all || true
14 options.services.xserver.windowManager.i3 = {
15 enable = mkEnableOption "i3 window manager";
17 configFile = mkOption {
19 type = with types; nullOr path;
21 Path to the i3 configuration file.
22 If left at the default value, $HOME/.i3/config will be used.
26 updateSessionEnvironment = mkOption {
30 Whether to run dbus-update-activation-environment and systemctl import-environment before session start.
31 Required for xdg portals to function properly.
35 extraSessionCommands = mkOption {
39 Shell commands executed just before i3 is started.
43 package = mkPackageOption pkgs "i3" { };
45 extraPackages = mkOption {
46 type = with types; listOf package;
47 default = with pkgs; [ dmenu i3status i3lock ];
48 defaultText = literalExpression ''
56 Extra packages to be installed system wide.
61 config = mkIf cfg.enable {
62 services.xserver.windowManager.session = [{
65 ${cfg.extraSessionCommands}
67 ${lib.optionalString cfg.updateSessionEnvironment updateSessionEnvironmentScript}
69 ${cfg.package}/bin/i3 ${optionalString (cfg.configFile != null)
75 environment.systemPackages = [ cfg.package ] ++ cfg.extraPackages;
76 environment.etc."i3/config" = mkIf (cfg.configFile != null) {
77 source = cfg.configFile;
82 (mkRemovedOptionModule [ "services" "xserver" "windowManager" "i3-gaps" "enable" ]
83 "i3-gaps was merged into i3. Use services.xserver.windowManager.i3.enable instead.")