summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorLinnnus <[email protected]>2023-10-07 22:17:51 +0200
committerLinnnus <[email protected]>2023-10-07 22:18:53 +0200
commit524ca88b1dc615957de144fc60b77f521f9760af (patch)
treeef60826e67c3b40c1a1f0c02b57738a6afc78434 /modules
parent107c85fa9046ab03f6dde9c63665734a67e210d9 (diff)
Add iTerm2
Diffstat (limited to 'modules')
-rw-r--r--modules/home-manager/default.nix6
-rw-r--r--modules/home-manager/iterm2/default.nix65
2 files changed, 71 insertions, 0 deletions
diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix
new file mode 100644
index 0000000..3eb61a1
--- /dev/null
+++ b/modules/home-manager/default.nix
@@ -0,0 +1,6 @@
+# This file indexes all home manager modules. Note that there is no
+# general/personal distinction here, as all personal home-manager configuration
+# goes in home/ instead.
+{
+ iterm2 = import ./iterm2;
+}
diff --git a/modules/home-manager/iterm2/default.nix b/modules/home-manager/iterm2/default.nix
new file mode 100644
index 0000000..997bc5b
--- /dev/null
+++ b/modules/home-manager/iterm2/default.nix
@@ -0,0 +1,65 @@
+{
+ 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 {
+ 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];
+
+ 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
+ '';
+ };
+}