From 3b287569b249bc0aae0744745ede1536995b4a13 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Mon, 9 Dec 2024 19:28:07 +0800 Subject: [PATCH] users/foo-dogsquared/programs/terminal-emulator: set up custom desktop entries --- .../modules/programs/terminal-emulator.nix | 73 ++++++++++++------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/configs/home-manager/foo-dogsquared/modules/programs/terminal-emulator.nix b/configs/home-manager/foo-dogsquared/modules/programs/terminal-emulator.nix index a7fea071..a3496844 100644 --- a/configs/home-manager/foo-dogsquared/modules/programs/terminal-emulator.nix +++ b/configs/home-manager/foo-dogsquared/modules/programs/terminal-emulator.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, ... }@attrs: let userCfg = config.users.foo-dogsquared; @@ -8,36 +8,55 @@ let source ${pkgs.bash-preexec}/share/bash/bash-preexec.sh source ${config.programs.wezterm.package}/etc/profile.d/wezterm.sh ''; + + hasNixosModuleEnable = attrs.nixosConfig.programs.wezterm.enable or false; in { options.users.foo-dogsquared.programs.terminal-emulator.enable = lib.mkEnableOption "foo-dogsquared's terminal emulator setup"; - config = lib.mkIf cfg.enable { - programs.bash.initExtra = shellIntegrationFragment; - programs.zsh.initExtra = shellIntegrationFragment; + config = lib.mkIf cfg.enable (lib.mkMerge [ + { + # We're just making a version of Wezterm with the default arguments if + # the user has them. + home.packages = + let + inherit (pkgs) wezterm hiPrio; + weztermUserDefaultDesktop = pkgs.makeDesktopItem { + name = "org.wezfurlong.wezterm"; + desktopName = "WezTerm (user)"; + comment = "Wez's Terminal Emulator"; + keywords = [ "shell" "prompt" "command" "commandline" "cmd" ]; + icon = "org.wezfurlong.wezterm"; + startupWMClass = "org.wezfurlong.wezterm"; + tryExec = "wezterm"; + exec = "wezterm"; + type = "Application"; + categories = [ "System" "TerminalEmulator" "Utility" ]; + }; + weztermTypicalDesktop = pkgs.makeDesktopItem { + name = "wezterm-start"; + desktopName = "WezTerm"; + comment = "Wez's Terminal Emulator"; + keywords = [ "shell" "prompt" "command" "commandline" "cmd" ]; + icon = "org.wezfurlong.wezterm"; + startupWMClass = "org.wezfurlong.wezterm"; + tryExec = "wezterm"; + exec = "wezterm start --cwd ."; + type = "Application"; + categories = [ "System" "TerminalEmulator" "Utility" ]; + }; + in + [ + wezterm + (hiPrio weztermUserDefaultDesktop) + weztermTypicalDesktop + ]; + } - # We're just making a version of Wezterm with the default arguments if - # the user has them. - home.packages = - let - inherit (pkgs) wezterm; - weztermUserDefaultDesktop = pkgs.makeDesktopItem { - name = "wezterm-user-default-args"; - desktopName = "WezTerm (user)"; - comment = "Wez's Terminal Emulator"; - keywords = [ "shell" "prompt" "command" "commandline" "cmd" ]; - icon = "org.wezfurlong.wezterm"; - startupWMClass = "org.wezfurlong.wezterm"; - tryExec = "wezterm"; - exec = "wezterm"; - type = "Application"; - categories = [ "System" "TerminalEmulator" "Utility" ]; - }; - in - [ - wezterm - weztermUserDefaultDesktop - ]; - }; + (lib.mkIf (!hasNixosModuleEnable) { + programs.bash.initExtra = shellIntegrationFragment; + programs.zsh.initExtra = shellIntegrationFragment; + }) + ]); }