diff options
author | Frederik Rietdijk <fridh@fridh.nl> | 2019-01-02 21:08:27 +0100 |
---|---|---|
committer | Frederik Rietdijk <fridh@fridh.nl> | 2019-01-02 21:08:27 +0100 |
commit | 092e3b50a8ff501a6ad1caf20165d2284d1ad5cb (patch) | |
tree | 6de2bf3a88d2fcf4d947312ccfabebcf5651dbed /pkgs/misc | |
parent | 070290bda7972072a531c7e79a29bd005ebb84df (diff) | |
parent | 82f679c269e504d00b02ef79a88934de7165dc8c (diff) |
Merge master into staging-next
Diffstat (limited to 'pkgs/misc')
-rw-r--r-- | pkgs/misc/vim-plugins/generated.nix | 10 | ||||
-rw-r--r-- | pkgs/misc/vim-plugins/vim-plugin-names | 1 | ||||
-rw-r--r-- | pkgs/misc/vim-plugins/vim-utils.nix | 70 |
3 files changed, 61 insertions, 20 deletions
diff --git a/pkgs/misc/vim-plugins/generated.nix b/pkgs/misc/vim-plugins/generated.nix index b8573a9367a8b..00d07ef9236b2 100644 --- a/pkgs/misc/vim-plugins/generated.nix +++ b/pkgs/misc/vim-plugins/generated.nix @@ -3115,6 +3115,16 @@ let }; }; + vim-parinfer = buildVimPluginFrom2Nix { + name = "vim-parinfer-2018-08-31"; + src = fetchFromGitHub { + owner = "bhurlow"; + repo = "vim-parinfer"; + rev = "d599e41dd1b9034059524af8156dcbebe68d96d2"; + sha256 = "0h4zw1yfnrbb3w5brcsy2l43jk7569dhslpkahczqxj6wr6hsxcc"; + }; + }; + vim-pathogen = buildVimPluginFrom2Nix { pname = "vim-pathogen"; version = "2018-12-13"; diff --git a/pkgs/misc/vim-plugins/vim-plugin-names b/pkgs/misc/vim-plugins/vim-plugin-names index 119a996b5bd1e..49a0230de9340 100644 --- a/pkgs/misc/vim-plugins/vim-plugin-names +++ b/pkgs/misc/vim-plugins/vim-plugin-names @@ -16,6 +16,7 @@ bazelbuild/vim-bazel bbchung/clighter8 benekastah/neomake benmills/vimux +bhurlow/vim-parinfer bitc/vim-hdevtools bling/vim-bufferline bronson/vim-trailing-whitespace diff --git a/pkgs/misc/vim-plugins/vim-utils.nix b/pkgs/misc/vim-plugins/vim-utils.nix index 61e89521c8c96..6e867dfc9661c 100644 --- a/pkgs/misc/vim-plugins/vim-utils.nix +++ b/pkgs/misc/vim-plugins/vim-utils.nix @@ -1,5 +1,7 @@ -{stdenv, vim, vimPlugins, vim_configurable, neovim, buildEnv, writeText, writeScriptBin -, nix-prefetch-hg, nix-prefetch-git }: +{ stdenv, vim, vimPlugins, vim_configurable, neovim, buildEnv, writeText, writeScriptBin +, nix-prefetch-hg, nix-prefetch-git +, fetchFromGitHub +}: /* @@ -150,20 +152,23 @@ vim_with_plugins can be installed like any other application within Nix. let inherit (stdenv) lib; - # transitive closure of plugin dependencies - transitiveClosure = knownPlugins: plugin: - let - # vam puts out a list of strings as the dependency list, we need to be able to deal with that. - # Because of that, "plugin" may be a string or a derivation. If it is a string, it is resolved - # using `knownPlugins`. Otherwise `knownPlugins` can be null. - knownPlugins' = if knownPlugins == null then vimPlugins else knownPlugins; - pluginDrv = if builtins.isString plugin then knownPlugins'.${plugin} else plugin; - in - [ pluginDrv ] ++ ( - lib.unique (builtins.concatLists (map (transitiveClosure knownPlugins) pluginDrv.dependencies or [])) + # make sure a plugin is a derivation. If plugin already is a derivation, this + # is a no-op. If it is a string, it is looked up in knownPlugins. + pluginToDrv = knownPlugins: plugin: + if builtins.isString plugin then + # make sure `pname` is set to that we are able to convert the derivation + # back to a string. + ( knownPlugins.${plugin} // { pname = plugin; }) + else + plugin; + + # transitive closure of plugin dependencies (plugin needs to be a derivation) + transitiveClosure = plugin: + [ plugin ] ++ ( + lib.unique (builtins.concatLists (map transitiveClosure plugin.dependencies or [])) ); - findDependenciesRecursively = knownPlugins: plugins: lib.concatMap (transitiveClosure knownPlugins) plugins; + findDependenciesRecursively = plugins: lib.concatMap transitiveClosure plugins; attrnamesToPlugins = { knownPlugins, names }: map (name: if builtins.isString name then knownPlugins.${name} else name) knownPlugins; @@ -195,7 +200,7 @@ let (let knownPlugins = pathogen.knownPlugins or vimPlugins; - plugins = findDependenciesRecursively knownPlugins pathogen.pluginNames; + plugins = findDependenciesRecursively (map (pluginToDrv knownPlugins) pathogen.pluginNames); pluginsEnv = buildEnv { name = "pathogen-plugin-env"; @@ -240,7 +245,10 @@ let (let knownPlugins = vam.knownPlugins or vimPlugins; - plugins = findDependenciesRecursively knownPlugins (lib.concatMap vamDictToNames vam.pluginDictionaries); + # plugins specified by the user + specifiedPlugins = map (pluginToDrv knownPlugins) (lib.concatMap vamDictToNames vam.pluginDictionaries); + # plugins with dependencies + plugins = findDependenciesRecursively specifiedPlugins; # Vim almost reads JSON, so eventually JSON support should be added to Nix # TODO: proper quoting @@ -298,8 +306,8 @@ let # opposed to older implementations that have to maintain backwards # compatibility). Therefore we don't need to deal with "knownPlugins" # and can simply pass `null`. - depsOfOptionalPlugins = lib.subtractLists opt (findDependenciesRecursively null opt); - startWithDeps = findDependenciesRecursively null start; + depsOfOptionalPlugins = lib.subtractLists opt (findDependenciesRecursively opt); + startWithDeps = findDependenciesRecursively start; in ["mkdir -p $out/pack/${packageName}/start"] # To avoid confusion, even dependencies of optional plugins are added @@ -421,8 +429,8 @@ rec { if vam != null && vam ? knownPlugins then vam.knownPlugins else if pathogen != null && pathogen ? knownPlugins then pathogen.knownPlugins else vimPlugins; - pathogenPlugins = findDependenciesRecursively knownPlugins pathogen.pluginNames; - vamPlugins = findDependenciesRecursively knownPlugins (lib.concatMap vamDictToNames vam.pluginDictionaries); + pathogenPlugins = findDependenciesRecursively ((map pluginToDrv knownPlugins) pathogen.pluginNames); + vamPlugins = findDependenciesRecursively (map (pluginToDrv knownPlugins) (lib.concatMap vamDictToNames vam.pluginDictionaries)); nonNativePlugins = (lib.optionals (pathogen != null) pathogenPlugins) ++ (lib.optionals (vam != null) vamPlugins) ++ (lib.optionals (plug != null) plug.plugins); @@ -457,4 +465,26 @@ rec { test_nvim_with_vim_nix_using_pathogen = neovim.override { configure.pathogen.pluginNames = [ "vim-nix" ]; }; + + # regression test for https://github.com/NixOS/nixpkgs/issues/53112 + # The user may have specified their own plugins which may not be formatted + # exactly as the generated ones. In particular, they may not have the `pname` + # attribute. + test_vim_with_custom_plugin = vim_configurable.customize { + name = "vim_with_custom_plugin"; + vimrcConfig.vam.knownPlugins = + vimPlugins // ({ + "vim-trailing-whitespace" = buildVimPluginFrom2Nix { + name = "vim-trailing-whitespace"; + src = fetchFromGitHub { + owner = "bronson"; + repo = "vim-trailing-whitespace"; + rev = "4c596548216b7c19971f8fc94e38ef1a2b55fee6"; + sha256 = "0f1cpnp1nxb4i5hgymjn2yn3k1jwkqmlgw1g02sq270lavp2dzs9"; + }; + dependencies = []; + }; + }); + vimrcConfig.vam.pluginDictionaries = [ { names = [ "vim-trailing-whitespace" ]; } ]; + }; } |