1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-23 18:29:47 +01:00

vte: add module

This abstracts out the VTE setup from the gnome-terminal module into
its own module and options.
This commit is contained in:
Robert Helgesson 2020-06-14 12:20:12 +02:00
parent 507e446475
commit bb567e20b3
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 56 additions and 7 deletions

2
.github/CODEOWNERS vendored
View file

@ -20,6 +20,8 @@
/modules/misc/tmpfiles.nix @dawidsowa
/modules/misc/vte.nix @rycee
/modules/misc/xdg-mime-apps.nix @pacien
/modules/misc/xdg-user-dirs.nix @pacien

51
modules/misc/vte.nix Normal file
View file

@ -0,0 +1,51 @@
{ config, lib, pkgs, ... }:
with lib;
{
meta.maintainers = [ maintainers.rycee ];
options.programs = let
description = ''
Whether to enable integration with terminals using the VTE
library. This will let the terminal track the current working
directory.
'';
in {
bash.enableVteIntegration = mkEnableOption "" // { inherit description; };
zsh.enableVteIntegration = mkEnableOption "" // { inherit description; };
};
config = mkMerge [
(mkIf config.programs.bash.enableVteIntegration {
# Unfortunately we have to do a little dance here to fix two
# problems with the upstream vte.sh file:
#
# - It does `PROMPT_COMMAND="__vte_prompt_command"` which
# clobbers any previously assigned prompt command.
#
# - Its `__vte_prompt_command` function runs commands that will
# overwrite the exit status of the command the user ran.
programs.bash.initExtra = ''
__HM_PROMPT_COMMAND="''${PROMPT_COMMAND:+''${PROMPT_COMMAND%;};}__hm_vte_prompt_command"
. ${pkgs.vte}/etc/profile.d/vte.sh
if [[ $(type -t __vte_prompt_command) = function ]]; then
__hm_vte_prompt_command() {
local old_exit_status=$?
__vte_prompt_command
return $old_exit_status
}
PROMPT_COMMAND="$__HM_PROMPT_COMMAND"
fi
unset __HM_PROMPT_COMMAND
'';
})
(mkIf config.programs.zsh.enableVteIntegration {
programs.zsh.initExtra = ''
. ${pkgs.vte}/etc/profile.d/vte.sh
'';
})
];
}

View file

@ -38,6 +38,7 @@ let
(loadModule ./misc/submodule-support.nix { })
(loadModule ./misc/tmpfiles.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/version.nix { })
(loadModule ./misc/vte.nix { })
(loadModule ./misc/xdg-mime.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/xdg-mime-apps.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/xdg-user-dirs.nix { condition = hostPlatform.isLinux; })

View file

@ -6,11 +6,6 @@ let
cfg = config.programs.gnome-terminal;
vteInitStr = ''
# gnome-terminal: Show current directory in the terminal window title.
. ${pkgs.vte}/etc/profile.d/vte.sh
'';
backForeSubModule = types.submodule ({ ... }: {
options = {
foreground = mkOption {
@ -217,7 +212,7 @@ in {
(n: v: nameValuePair ("${dconfPath}/profiles:/:${n}") (buildProfileSet v))
cfg.profile;
programs.bash.initExtra = mkBefore vteInitStr;
programs.zsh.initExtra = vteInitStr;
programs.bash.enableVteIntegration = true;
programs.zsh.enableVteIntegration = true;
};
}