mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
fish: support theme plugins
Allows for linking fish plugin theme files to [fish's themes folder](https://fishshell.com/docs/current/cmds/fish_config.html#theme-files). Fully allowing for theme plugins to properly be installed declaratively. Fixes nix-community/home-manager#3724
This commit is contained in:
parent
dcf52ade95
commit
5a21f4819e
3 changed files with 63 additions and 0 deletions
|
|
@ -765,6 +765,30 @@ in
|
||||||
}) cfg.plugins
|
}) cfg.plugins
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
(
|
||||||
|
let
|
||||||
|
themes = lib.foldl (
|
||||||
|
themeList: plugin:
|
||||||
|
if lib.pathIsDirectory "${plugin.src}/themes" then
|
||||||
|
themeList ++ lib.filesystem.listFilesRecursive "${plugin.src}/themes"
|
||||||
|
else
|
||||||
|
themeList
|
||||||
|
) [ ] cfg.plugins;
|
||||||
|
in
|
||||||
|
(mkIf (lib.length themes > 0) {
|
||||||
|
xdg.configFile = lib.mkMerge (
|
||||||
|
map (
|
||||||
|
theme:
|
||||||
|
let
|
||||||
|
basename = lib.last (builtins.split "/" (toString theme));
|
||||||
|
in
|
||||||
|
{
|
||||||
|
"fish/themes/${basename}".source = theme;
|
||||||
|
}
|
||||||
|
) themes
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,5 @@
|
||||||
fish-plugins = ./plugins.nix;
|
fish-plugins = ./plugins.nix;
|
||||||
fish-manpage = ./manpage.nix;
|
fish-manpage = ./manpage.nix;
|
||||||
fish-binds = ./binds.nix;
|
fish-binds = ./binds.nix;
|
||||||
|
fish-themes = ./themes.nix;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
38
tests/modules/programs/fish/themes.nix
Normal file
38
tests/modules/programs/fish/themes.nix
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
dummy-theme-plugin = pkgs.runCommandLocal "theme" { } ''
|
||||||
|
mkdir -p "$out"/themes
|
||||||
|
echo "fish_color_normal 575279" > "$out/themes/dummy-theme-plugin.theme"
|
||||||
|
'';
|
||||||
|
|
||||||
|
copied-theme = pkgs.writeText "theme.theme" ''
|
||||||
|
fish_color_normal 575279
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
programs.fish = {
|
||||||
|
enable = true;
|
||||||
|
plugins = [
|
||||||
|
{
|
||||||
|
name = "foo";
|
||||||
|
src = dummy-theme-plugin;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Needed to avoid error with dummy fish package.
|
||||||
|
xdg.dataFile."fish/home-manager_generated_completions".source = lib.mkForce (
|
||||||
|
builtins.toFile "empty" ""
|
||||||
|
);
|
||||||
|
|
||||||
|
nmt = {
|
||||||
|
description = "if fish plugin contains themes directory copy the themes";
|
||||||
|
script = ''
|
||||||
|
assertDirectoryExists home-files/.config/fish/themes
|
||||||
|
assertFileExists home-files/.config/fish/themes/dummy-theme-plugin.theme
|
||||||
|
assertFileContent home-files/.config/fish/themes/dummy-theme-plugin.theme ${copied-theme}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue