vimUtils.buildVimPlugin: derive name from pname and version
This commit is contained in:
parent
edf8b984fa
commit
96b6396101
54
pkgs/misc/vim-plugins/build-vim-plugin.nix
Normal file
54
pkgs/misc/vim-plugins/build-vim-plugin.nix
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
{ stdenv
|
||||||
|
, rtpPath ? "share/vim-plugins"
|
||||||
|
, vim
|
||||||
|
}:
|
||||||
|
|
||||||
|
rec {
|
||||||
|
addRtp = path: attrs: derivation:
|
||||||
|
derivation // { rtp = "${derivation}/${path}"; } // {
|
||||||
|
overrideAttrs = f: buildVimPlugin (attrs // f attrs);
|
||||||
|
};
|
||||||
|
|
||||||
|
buildVimPlugin = attrs@{
|
||||||
|
name ? "${attrs.pname}-${attrs.version}",
|
||||||
|
namePrefix ? "vimplugin-",
|
||||||
|
src,
|
||||||
|
unpackPhase ? "",
|
||||||
|
configurePhase ? "",
|
||||||
|
buildPhase ? "",
|
||||||
|
preInstall ? "",
|
||||||
|
postInstall ? "",
|
||||||
|
path ? (builtins.parseDrvName name).name,
|
||||||
|
addonInfo ? null,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // {
|
||||||
|
name = namePrefix + name;
|
||||||
|
|
||||||
|
inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
target=$out/${rtpPath}/${path}
|
||||||
|
mkdir -p $out/${rtpPath}
|
||||||
|
cp -r . $target
|
||||||
|
|
||||||
|
# build help tags
|
||||||
|
if [ -d "$target/doc" ]; then
|
||||||
|
${vim}/bin/vim -N -u NONE -i NONE -n -E -s -c "helptags $1/doc" +quit! || echo "docs to build failed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$addonInfo" ]; then
|
||||||
|
echo "$addonInfo" > $target/addon-info.json
|
||||||
|
fi
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
}));
|
||||||
|
|
||||||
|
buildVimPluginFrom2Nix = attrs: buildVimPlugin ({
|
||||||
|
buildPhase = ":";
|
||||||
|
configurePhase =":";
|
||||||
|
} // attrs);
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -309,8 +309,8 @@ def generate_nix(plugins: List[Tuple[str, str, Plugin]]):
|
|||||||
f.write(
|
f.write(
|
||||||
f"""
|
f"""
|
||||||
{plugin.normalized_name} = buildVimPluginFrom2Nix {{
|
{plugin.normalized_name} = buildVimPluginFrom2Nix {{
|
||||||
name = "{plugin.normalized_name}-{plugin.version}";
|
|
||||||
pname = "{plugin.normalized_name}";
|
pname = "{plugin.normalized_name}";
|
||||||
|
version = "{plugin.version}";
|
||||||
src = fetchFromGitHub {{
|
src = fetchFromGitHub {{
|
||||||
owner = "{owner}";
|
owner = "{owner}";
|
||||||
repo = "{repo}";
|
repo = "{repo}";
|
||||||
|
@ -403,59 +403,9 @@ rec {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
vimHelpTags = ''
|
|
||||||
vimHelpTags(){
|
|
||||||
if [ -d "$1/doc" ]; then
|
|
||||||
${vim}/bin/vim -N -u NONE -i NONE -n -E -s -c "helptags $1/doc" +quit! || echo "docs to build failed"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
|
|
||||||
addRtp = path: attrs: derivation:
|
|
||||||
derivation // { rtp = "${derivation}/${path}"; } // {
|
|
||||||
overrideAttrs = f: buildVimPlugin (attrs // f attrs);
|
|
||||||
};
|
|
||||||
|
|
||||||
buildVimPlugin = a@{
|
|
||||||
name,
|
|
||||||
namePrefix ? "vimplugin-",
|
|
||||||
src,
|
|
||||||
unpackPhase ? "",
|
|
||||||
configurePhase ? "",
|
|
||||||
buildPhase ? "",
|
|
||||||
preInstall ? "",
|
|
||||||
postInstall ? "",
|
|
||||||
path ? (builtins.parseDrvName name).name,
|
|
||||||
addonInfo ? null,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
addRtp "${rtpPath}/${path}" a (stdenv.mkDerivation (a // {
|
|
||||||
name = namePrefix + name;
|
|
||||||
|
|
||||||
inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
|
|
||||||
target=$out/${rtpPath}/${path}
|
|
||||||
mkdir -p $out/${rtpPath}
|
|
||||||
cp -r . $target
|
|
||||||
${vimHelpTags}
|
|
||||||
vimHelpTags $target
|
|
||||||
if [ -n "$addonInfo" ]; then
|
|
||||||
echo "$addonInfo" > $target/addon-info.json
|
|
||||||
fi
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
}));
|
|
||||||
|
|
||||||
vim_with_vim2nix = vim_configurable.customize { name = "vim"; vimrcConfig.vam.pluginDictionaries = [ "vim-addon-vim2nix" ]; };
|
vim_with_vim2nix = vim_configurable.customize { name = "vim"; vimrcConfig.vam.pluginDictionaries = [ "vim-addon-vim2nix" ]; };
|
||||||
|
|
||||||
buildVimPluginFrom2Nix = a: buildVimPlugin ({
|
inherit (import ./build-vim-plugin.nix { inherit stdenv rtpPath vim; }) buildVimPlugin buildVimPluginFrom2Nix;
|
||||||
buildPhase = ":";
|
|
||||||
configurePhase =":";
|
|
||||||
} // a);
|
|
||||||
|
|
||||||
requiredPlugins = {
|
requiredPlugins = {
|
||||||
packages ? {},
|
packages ? {},
|
||||||
|
Loading…
Reference in New Issue
Block a user