From 75211154ede76acdf5d8f7ba10ad9b67045df8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Go=C5=82=C4=99biewski?= Date: Sun, 24 Feb 2019 05:05:31 +0100 Subject: [PATCH] vim: Allow independent setting of executable names * Allow settign gvim wrapper name independently of vim wrapper name. * Allow setting vim wrapper name independently of derivation name. * Refactor multiple places where name was checked for null with default value. --- pkgs/misc/vim-plugins/vim-utils.nix | 32 ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/pkgs/misc/vim-plugins/vim-utils.nix b/pkgs/misc/vim-plugins/vim-utils.nix index 62e0d9e8bcc7..3e9fb7facf71 100644 --- a/pkgs/misc/vim-plugins/vim-utils.nix +++ b/pkgs/misc/vim-plugins/vim-utils.nix @@ -359,20 +359,31 @@ rec { inherit vimrcFile; # shell script with custom name passing [-u vimrc] [-U gvimrc] to vim - vimWithRC = {vimExecutable, gvimExecutable, vimManPages, wrapManual, wrapGui, name ? null, vimrcFile ? null, gvimrcFile ? null}: + vimWithRC = { + vimExecutable, + gvimExecutable, + vimManPages, + wrapManual, + wrapGui, + name ? "vim", + vimrcFile ? null, + gvimrcFile ? null, + vimExecutableName, + gvimExecutableName, + }: let rcOption = o: file: stdenv.lib.optionalString (file != null) "-${o} ${file}"; - vimWrapperScript = writeScriptBin (if name == null then "vim" else name) '' + vimWrapperScript = writeScriptBin vimExecutableName '' #!${stdenv.shell} exec ${vimExecutable} ${rcOption "u" vimrcFile} ${rcOption "U" gvimrcFile} "$@" ''; - gvimWrapperScript = writeScriptBin (if name == null then "gvim" else (lib.concatStrings [ "g" name ])) '' + gvimWrapperScript = writeScriptBin gvimExecutableName '' #!${stdenv.shell} exec ${gvimExecutable} ${rcOption "u" vimrcFile} ${rcOption "U" gvimrcFile} "$@" ''; in buildEnv { - name = vimWrapperScript.name; + inherit name; paths = [ vimWrapperScript ] ++ lib.optional wrapGui gvimWrapperScript @@ -382,13 +393,20 @@ rec { # add a customize option to a vim derivation makeCustomizable = vim: vim // { - customize = { name, vimrcConfig, wrapManual ? true, wrapGui ? false }: vimWithRC { + customize = { + name, + vimrcConfig, + wrapManual ? true, + wrapGui ? false, + vimExecutableName ? name, + gvimExecutableName ? (lib.concatStrings [ "g" name ]), + }: vimWithRC { vimExecutable = "${vim}/bin/vim"; gvimExecutable = "${vim}/bin/gvim"; - inherit name wrapManual wrapGui; + inherit name wrapManual wrapGui vimExecutableName gvimExecutableName; vimrcFile = vimrcFile vimrcConfig; vimManPages = buildEnv { - name = "${name}-doc"; + name = "vim-doc"; paths = [ vim ]; pathsToLink = [ "/share/man" ]; };