vimUtils.buildVimPlugin: derive name from pname and version

wip/yesman
Timo Kaufmann 6 years ago
parent edf8b984fa
commit 96b6396101
  1. 54
      pkgs/misc/vim-plugins/build-vim-plugin.nix
  2. 722
      pkgs/misc/vim-plugins/generated.nix
  3. 2
      pkgs/misc/vim-plugins/update.py
  4. 52
      pkgs/misc/vim-plugins/vim-utils.nix

@ -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"""
{plugin.normalized_name} = buildVimPluginFrom2Nix {{
name = "{plugin.normalized_name}-{plugin.version}";
pname = "{plugin.normalized_name}";
version = "{plugin.version}";
src = fetchFromGitHub {{
owner = "{owner}";
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" ]; };
buildVimPluginFrom2Nix = a: buildVimPlugin ({
buildPhase = ":";
configurePhase =":";
} // a);
inherit (import ./build-vim-plugin.nix { inherit stdenv rtpPath vim; }) buildVimPlugin buildVimPluginFrom2Nix;
requiredPlugins = {
packages ? {},

Loading…
Cancel
Save