1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

fish: plugins concated to 99plugins.fish

This change allows the entire repo to be imported directly. Some plugins (such
as oh-my-fish's vi-mode) have extra files that are referenced by the plugin
itself. This means we cannot create a generic plugin file structure out of the
plugins that exist currently.
This commit is contained in:
Ryan Orendorff 2019-09-24 01:21:34 -07:00 committed by Robert Helgesson
parent f5b24635b6
commit 639f6fea8c
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -288,32 +288,37 @@ in
end end
'';}; '';};
}) cfg.functions; }) cfg.functions;
} (
let
wrappedPkgVersion = lib.getVersion pkgs.fish;
wrappedPkgName = lib.removeSuffix "-${wrappedPkgVersion}" pkgs.fish.name;
dependencies = concatMap (p: p.dependencies) cfg.plugins;
combinedPluginDrv = pkgs.buildEnv {
name = "${wrappedPkgName}-plugins-${wrappedPkgVersion}";
paths = cfg.plugins;
postBuild = ''
touch $out/setup.fish
if [ -d $out/functions ]; then }
echo "set fish_function_path \$fish_function_path[1] $out/functions \$fish_function_path[2..-1]" >> $out/setup.fish
fi
if [ -d $out/completions ]; then # Plugins are all sources together in a conf.d file as this allows
echo "set fish_complete_path \$fish_complete_path[1] $out/completions \$fish_complete_path[2..-1]" >> $out/setup.fish # the original source to be undisturbed.
fi (mkIf (length cfg.plugins > 0) {
xdg.configFile."fish/conf.d/99plugins.fish".text = concatStrings
(map (plugin: ''
# Plugin ${plugin.name}
if test -d ${plugin.src}/functions
set fish_function_path $fish_function_path[1] ${plugin.src}/functions $fish_function_path[2..-1]
end
if [ -d $out/conf.d ]; then if test -d ${plugin.src}/completions
echo "source $out/conf.d/*.fish" >> $out/setup.fish set fish_complete_path $fish_function_path[1] ${plugin.src}/completions $fish_complete_path[2..-1]
fi end
'';
}; if test -d ${plugin.src}/conf.d
in mkIf (length cfg.plugins > 0) { source ${plugin.src}/conf.d/*.fish
xdg.configFile."fish/conf.d/99plugins.fish".source = "${combinedPluginDrv}/setup.fish"; end
home.packages = dependencies;
})]); if test -f ${plugin.src}/key_bindings.fish
source ${plugin.src}/key_bindings.fish
end
if test -f ${plugin.src}/init.fish
source ${plugin.src}/init.fish
end
''
) cfg.plugins);
})
]);
} }