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.
This commit is contained in:
parent
b623da79e4
commit
75211154ed
@ -359,20 +359,31 @@ rec {
|
|||||||
inherit vimrcFile;
|
inherit vimrcFile;
|
||||||
|
|
||||||
# shell script with custom name passing [-u vimrc] [-U gvimrc] to vim
|
# 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
|
let
|
||||||
rcOption = o: file: stdenv.lib.optionalString (file != null) "-${o} ${file}";
|
rcOption = o: file: stdenv.lib.optionalString (file != null) "-${o} ${file}";
|
||||||
vimWrapperScript = writeScriptBin (if name == null then "vim" else name) ''
|
vimWrapperScript = writeScriptBin vimExecutableName ''
|
||||||
#!${stdenv.shell}
|
#!${stdenv.shell}
|
||||||
exec ${vimExecutable} ${rcOption "u" vimrcFile} ${rcOption "U" gvimrcFile} "$@"
|
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}
|
#!${stdenv.shell}
|
||||||
exec ${gvimExecutable} ${rcOption "u" vimrcFile} ${rcOption "U" gvimrcFile} "$@"
|
exec ${gvimExecutable} ${rcOption "u" vimrcFile} ${rcOption "U" gvimrcFile} "$@"
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
buildEnv {
|
buildEnv {
|
||||||
name = vimWrapperScript.name;
|
inherit name;
|
||||||
paths = [
|
paths = [
|
||||||
vimWrapperScript
|
vimWrapperScript
|
||||||
] ++ lib.optional wrapGui gvimWrapperScript
|
] ++ lib.optional wrapGui gvimWrapperScript
|
||||||
@ -382,13 +393,20 @@ rec {
|
|||||||
|
|
||||||
# add a customize option to a vim derivation
|
# add a customize option to a vim derivation
|
||||||
makeCustomizable = vim: vim // {
|
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";
|
vimExecutable = "${vim}/bin/vim";
|
||||||
gvimExecutable = "${vim}/bin/gvim";
|
gvimExecutable = "${vim}/bin/gvim";
|
||||||
inherit name wrapManual wrapGui;
|
inherit name wrapManual wrapGui vimExecutableName gvimExecutableName;
|
||||||
vimrcFile = vimrcFile vimrcConfig;
|
vimrcFile = vimrcFile vimrcConfig;
|
||||||
vimManPages = buildEnv {
|
vimManPages = buildEnv {
|
||||||
name = "${name}-doc";
|
name = "vim-doc";
|
||||||
paths = [ vim ];
|
paths = [ vim ];
|
||||||
pathsToLink = [ "/share/man" ];
|
pathsToLink = [ "/share/man" ];
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user