mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-01-11 14:20:23 +01:00
[FR]: Add xdg-terminal-exec Configuration #57
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DataEraserC on GitHub (May 11, 2025).
Background / 背景
I noticed that
nix-configlacks any configuration forxdg.terminal-exec. As a result, when I right-click a file in some file managers (or elsewhere) and choose “Open With → nvim”, it may launch in a terminal other than my preferred one.我发现
nix-config缺少对xdg.terminal-exec的配置。这样当我在某些文件管理器或者其他地方右键选择“使用 nvim 打开”时,可能会在一个并非我期望的终端中启动。Proposed Configuration / 建议的配置
I experimented with the NixOS
xdg.terminal-execoption and found that it fixes this problem perfectly. Here’s the module I added undermodules/nixos/desktop/xdg-terminal-exec.nix:我试验了 NixOS 的
xdg.terminal-exec选项,发现它能完美解决这个问题。以下是在modules/nixos/desktop/xdg-terminal-exec.nix中添加的 module:Questions / 报告中的疑问
File Organization
1.1. Is placing this file under
modules/nixos/desktop/xdg-terminal-exec.nixright and maintainable, or might it become hard to manage as the number of desktop modules grows?1.1 将该文件放在
modules/nixos/desktop/xdg-terminal-exec.nix目录下是否合适并且可维护?随着 desktop 模块增多,这种方式是否会变得难以管理?Conditional Terminal List
2.1. The current list is hard-coded (
foot,Alacritty,kitty,ghostty). Is there a way to automatically include only those terminals that are actually installed (e.g., via a check in the module)?2.1 现在的列表是写死的(
foot、Alacritty、kitty、ghostty)。是否有办法让它只在确认这些终端已安装后才加入?Separation Between NixOS Module and Home Packages
3.1. This config lives in a NixOS module (and the option comes from NixOS), but the terminals themselves are installed via home-manager. Is this separation problematic?
3.1 该配置写在 NixOS module 中(且选项来源于 NixOS),而终端却安装在 home-manager。这样分离是否有问题?
Possible Enhancement / 可行的改进思路
Wrap Terminal Collections
Define a top-level option such as
desktop.terminalsin the NixOS config; ifdesktop.terminals.kitty.enable = truethen automatically install and config kitty , and addkitty.desktoptoxdg.terminal-exec.settings.封装终端集合
在顶层 NixOS 配置中定义选项,例如
desktop.terminals;若desktop.terminals.kitty.enable = true,则自动安装、配置kitty,以及在xdg.terminal-exec.settings中加入kitty.desktop。(但是可能需要在nixos和home两侧均定义,并且在output里面统一enable)