blob: 4788e1db325cbe87eb9b19047a461fa1bf2e98d4 (
plain)
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
65
66
67
68
69
|
{
pkgs,
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption mkPackageOption mkOption;
inherit (lib.types) nullOr attrs;
inherit (lib.generators) toPlist;
cfg = config.programs.iterm2;
in {
options.programs.iterm2 = {
enable = mkEnableOption "Iterm2 terminal emulator";
package = mkPackageOption pkgs "iterm2" {};
shellIntegration = {
enableZshIntegration = mkEnableOption "Zsh integraion";
enableBashIntegration = mkEnableOption "Bash integration";
enableFishIntegration = mkEnableOption "Fish integration";
};
config = mkOption {
# FIXME: This breaks iTerm2 too much. Create a patch for iTerm2 that
# loads `$XDG_CONFIG_HOME/iterm2/iterm2.plist` in addition to the usual
# `~/Library/Preferences/com.googlecode.iterm2.plist`.
description = ''
Application preferences. If these are specified, they are serialized to
PLIST and stored in `~/Library/Preferences/com.googlecode.iterm2.plist`.
Note that iTerm2 acts weirdly in some aspects when it cannot write to
aforementioned prefrences file (such as is the case when using
home-manager to manage the file). For example, changing settings using
the GUI are not persistant between sessions. Furtherore, some iTerm2
also appears to be storing other miscellaneous non-configration state
in the folder (e.g. `NoSyncTipOfTheDayEligibilityBeganTime`).
For these reasons, the default is non-declarative management. When this
option is set to `null` (the default), no file is generated.
'';
type = nullOr attrs;
default = null;
};
};
config = mkIf cfg.enable {
home.packages = [cfg.package];
# TODO: Use the same overwriting approach as for qBittorrent.
home.file = mkIf (cfg.config != null) {
"/Library/Preferences/com.googlecode.iterm2.plist".text = toPlist {} cfg.config;
};
programs.zsh.initExtra = mkIf cfg.shellIntegration.enableZshIntegration ''
# Added by home-manager because programs.iterm2.enableZshIntegration == true.
source "${cfg.package}"/Applications/iTerm2.app/Contents/Resources/iterm2_shell_integration.zsh
'';
programs.bash.initExtra = mkIf cfg.shellIntegration.enableBashIntegration ''
# Added by home-manager because programs.iterm2.enableBashIntegration == true.
source "${cfg.package}"/Applications/iTerm2.app/Contents/Resources/iterm2_shell_integration.bash
'';
programs.fish.interactiveShellInit = mkIf cfg.shellIntegration.enableFishIntegration ''
# Added by home-manager because programs.iterm2.enableFishIntegration == true.
source "${cfg.package}"/Applications/iTerm2.app/Contents/Resources/iterm2_shell_integration.fish
'';
};
}
|