vimUtils.buildVimPlugin: derive name from pname and version

This commit is contained in:
Timo Kaufmann 2018-12-27 10:34:14 +01:00
parent edf8b984fa
commit 96b6396101
4 changed files with 417 additions and 413 deletions

View 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

View File

@ -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}";

View File

@ -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 ? {},