1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-14 11:57:55 +00:00

fish: update plugins test

This commit is contained in:
diniamo 2024-08-07 16:51:28 +02:00
parent 64f05a5771
commit 4d52400bc6

View file

@ -1,49 +1,16 @@
{ config, lib, pkgs, ... }: { lib, pkgs, ... }:
with lib;
let let
testPlugin = pkgs.runCommandLocal "fish-test-plugin" { } ''
fooPluginSrc = pkgs.writeText "fooPluginSrc" ""; mkdir -p $out/{functions,completions,conf.d}
touch $out/{functions/test.fish,completions/test.fish,conf.d/test.fish}
generatedConfdFile = pkgs.writeText "plugin-foo.fish" ''
# Plugin foo
set -l plugin_dir ${fooPluginSrc}
# Set paths to import plugin components
if test -d $plugin_dir/functions
set fish_function_path $fish_function_path[1] $plugin_dir/functions $fish_function_path[2..-1]
end
if test -d $plugin_dir/completions
set fish_complete_path $fish_complete_path[1] $plugin_dir/completions $fish_complete_path[2..-1]
end
# Source initialization code if it exists.
if test -d $plugin_dir/conf.d
for f in $plugin_dir/conf.d/*.fish
source $f
end
end
if test -f $plugin_dir/key_bindings.fish
source $plugin_dir/key_bindings.fish
end
if test -f $plugin_dir/init.fish
source $plugin_dir/init.fish
end
''; '';
in { in {
config = { config = {
programs.fish = { programs.fish = {
enable = true; enable = true;
plugins = [{ plugins = [ testPlugin ];
name = "foo";
src = fooPluginSrc;
}];
}; };
# Needed to avoid error with dummy fish package. # Needed to avoid error with dummy fish package.
@ -54,11 +21,10 @@ in {
description = description =
"if fish.plugins set, check conf.d file exists and contents match"; "if fish.plugins set, check conf.d file exists and contents match";
script = '' script = ''
assertDirectoryExists home-files/.config/fish/conf.d assertFileExists home-files/.config/fish/functions/test.fish
assertFileExists home-files/.config/fish/conf.d/plugin-foo.fish assertFileExists home-files/.config/fish/completions/test.fish
assertFileContent home-files/.config/fish/conf.d/plugin-foo.fish ${generatedConfdFile} assertFileExists home-files/.config/fish/conf.d/test.fish
''; '';
}; };
}; };
} }