summaryrefslogtreecommitdiff
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
parent107c85fa9046ab03f6dde9c63665734a67e210d9 (diff)
Add iTerm2
-rw-r--r--flake.nix1
-rw-r--r--home/default.nix15
-rw-r--r--home/iterm2/default.nix20
-rw-r--r--modules/home-manager/default.nix6
-rw-r--r--modules/home-manager/iterm2/default.nix65
5 files changed, 101 insertions, 6 deletions
diff --git a/flake.nix b/flake.nix
index f2a91aa..9a0987f 100644
--- a/flake.nix
+++ b/flake.nix
@@ -100,5 +100,6 @@
# We export the generally applicable modules.
darwinModules = (import ./modules/darwin).geneal;
nixosModules = (import ./modules/nixos).general;
+ homeModules = import ./modules/home-manager;
};
}
diff --git a/home/default.nix b/home/default.nix
index 2c43efb..8184382 100644
--- a/home/default.nix
+++ b/home/default.nix
@@ -15,12 +15,15 @@
# OKAY FUCK THIS SHIT. THERE IS ONE USER. IT IS ME. LINUS. I WILL ADD
# MULTIUSER SUPPORT IF IT EVER BECOMES A REQUIREMENT.
home-manager.users.linus = {
- imports = [
- ./neovim
- ./zsh
- ./git
- ./dev-utils
- ];
+ imports =
+ [
+ ./neovim
+ ./zsh
+ ./git
+ ./dev-utils
+ ./iterm2
+ ]
+ ++ builtins.attrValues flakeOutputs.homeModules;
xdg.enable = true;
};
diff --git a/home/iterm2/default.nix b/home/iterm2/default.nix
new file mode 100644
index 0000000..a0edb7e
--- /dev/null
+++ b/home/iterm2/default.nix
@@ -0,0 +1,20 @@
+# This file configures iterm2. Note that the actual definition of iTerm2 for
+# home-manager is in `modules/home-manager/iterm2`. *That* file declares
+# `options.programs.iterm2.enable`.
+{
+ pkgs,
+ lib,
+ ...
+}: let
+ inherit (lib) mkIf;
+ inherit (pkgs.stdenv) isDarwin;
+in {
+ config = mkIf isDarwin {
+ programs.iterm2 = {
+ enable = true;
+ config = {
+ SoundForEsc = false;
+ };
+ };
+ };
+}
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
+ '';
+ };
+}