2019-09-30 07:11:36 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
fooPluginSrc = pkgs.writeText "fooPluginSrc" "";
|
|
|
|
|
|
|
|
generatedConfdFile = pkgs.writeText "plugin-foo.fish" ''
|
|
|
|
# Plugin foo
|
|
|
|
set -l plugin_dir ${fooPluginSrc}
|
|
|
|
|
|
|
|
# Set paths to import plugin components
|
2020-02-15 17:10:11 +00:00
|
|
|
if test -d $plugin_dir/functions
|
2022-12-05 01:51:03 +00:00
|
|
|
set fish_function_path $fish_function_path[1] $plugin_dir/functions $fish_function_path[2..-1]
|
2019-09-30 07:11:36 +00:00
|
|
|
end
|
|
|
|
|
2020-02-15 17:10:11 +00:00
|
|
|
if test -d $plugin_dir/completions
|
2022-12-05 01:51:03 +00:00
|
|
|
set fish_complete_path $fish_complete_path[1] $plugin_dir/completions $fish_complete_path[2..-1]
|
2019-09-30 07:11:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Source initialization code if it exists.
|
2020-02-15 17:10:11 +00:00
|
|
|
if test -d $plugin_dir/conf.d
|
2022-12-05 01:51:03 +00:00
|
|
|
for f in $plugin_dir/conf.d/*.fish
|
|
|
|
source $f
|
|
|
|
end
|
2019-09-30 07:11:36 +00:00
|
|
|
end
|
|
|
|
|
2020-02-15 17:10:11 +00:00
|
|
|
if test -f $plugin_dir/key_bindings.fish
|
2022-12-05 01:51:03 +00:00
|
|
|
source $plugin_dir/key_bindings.fish
|
2019-09-30 07:11:36 +00:00
|
|
|
end
|
|
|
|
|
2020-02-15 17:10:11 +00:00
|
|
|
if test -f $plugin_dir/init.fish
|
2022-12-05 01:51:03 +00:00
|
|
|
source $plugin_dir/init.fish
|
2019-09-30 07:11:36 +00:00
|
|
|
end
|
|
|
|
'';
|
|
|
|
|
|
|
|
in {
|
|
|
|
config = {
|
|
|
|
programs.fish = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
plugins = [{
|
|
|
|
name = "foo";
|
|
|
|
src = fooPluginSrc;
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
|
2021-08-06 21:33:19 +00:00
|
|
|
# Needed to avoid error with dummy fish package.
|
|
|
|
xdg.dataFile."fish/home-manager_generated_completions".source =
|
|
|
|
lib.mkForce (builtins.toFile "empty" "");
|
|
|
|
|
2019-09-30 07:11:36 +00:00
|
|
|
nmt = {
|
|
|
|
description =
|
|
|
|
"if fish.plugins set, check conf.d file exists and contents match";
|
|
|
|
script = ''
|
|
|
|
assertDirectoryExists home-files/.config/fish/conf.d
|
|
|
|
assertFileExists home-files/.config/fish/conf.d/plugin-foo.fish
|
|
|
|
assertFileContent home-files/.config/fish/conf.d/plugin-foo.fish ${generatedConfdFile}
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|