1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

wezterm: don't create config if extraConfig is empty, and don't create one by default (#6908)

Tests updated to check the file wasn't created when no config is
provided.
This commit is contained in:
B1kku 2025-04-25 15:11:18 +00:00 committed by GitHub
parent 98f4fef7fd
commit 542078066b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 24 deletions

View file

@ -9,6 +9,7 @@ let
inherit (lib)
literalExpression
mkIf
mkMerge
mkEnableOption
mkOption
types
@ -35,9 +36,7 @@ in
extraConfig = mkOption {
type = types.lines;
default = ''
return {}
'';
default = "";
example = literalExpression ''
-- Your lua code / config here
local mylib = require 'mylib';
@ -100,8 +99,8 @@ in
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile =
{
xdg.configFile = mkMerge [
(mkIf (cfg.extraConfig != "") {
"wezterm/wezterm.lua".text = ''
-- Generated by Home Manager.
-- See https://wezfurlong.org/wezterm/
@ -110,13 +109,14 @@ in
${cfg.extraConfig}
'';
}
// lib.mapAttrs' (
})
(lib.mapAttrs' (
name: value:
lib.nameValuePair "wezterm/colors/${name}.toml" {
source = tomlFormat.generate "${name}.toml" { colors = value; };
}
) cfg.colorSchemes;
) cfg.colorSchemes)
];
programs.bash.initExtra = mkIf cfg.enableBashIntegration shellIntegrationStr;
programs.zsh.initContent = mkIf cfg.enableZshIntegration shellIntegrationStr;

View file

@ -3,20 +3,7 @@
enable = true;
};
nmt.script =
let
expected = builtins.toFile "wezterm.lua" ''
-- Generated by Home Manager.
-- See https://wezfurlong.org/wezterm/
local wezterm = require 'wezterm'
return {}
'';
in
''
assertFileExists home-files/.config/wezterm/wezterm.lua
assertFileContent home-files/.config/wezterm/wezterm.lua ${expected}
nmt.script = ''
assertPathNotExists home-files/.config/wezterm/wezterm.lua
'';
}