vimPlugins: make usage of luaPackages less confusing
right now the src is ignored in: ``` lush-nvim = buildNeovimPlugin { pname = "lush.nvim"; version = "2022-08-09"; src = fetchFromGitHub { owner = "rktjmp"; repo = "lush.nvim"; rev = "6b9f399245de7bea8dac2c3bf91096ffdedfcbb7"; sha256 = "0rb77rwmbm438bmbjfk5hwrrcn5sihsa1413bdpc27rw3rrn8v8z"; }; meta.homepage = "https://github.com/rktjmp/lush.nvim/"; }; ``` which is very confusing. With this PR, we correctly override the src and the version of the package. We introduce a rockspecVersion attribute of lua package to be able to still find the rockspec when the "version" field needs to be different than "rockspecVersion".
This commit is contained in:
parent
dbcd78e341
commit
2acce7dfdc
|
@ -1,8 +1,6 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, buildVimPluginFrom2Nix
|
||||
, buildLuarocksPackage
|
||||
, lua51Packages
|
||||
, lua
|
||||
, toVimPlugin
|
||||
}:
|
||||
let
|
||||
|
@ -19,16 +17,21 @@ in
|
|||
, ...
|
||||
}@attrs:
|
||||
let
|
||||
originalLuaDrv = lua51Packages.${luaAttr};
|
||||
luaDrv = lua51Packages.luaLib.overrideLuarocks originalLuaDrv (drv: {
|
||||
originalLuaDrv = lua.pkgs.${luaAttr};
|
||||
|
||||
luaDrv = (lua.pkgs.luaLib.overrideLuarocks originalLuaDrv (drv: {
|
||||
extraConfig = ''
|
||||
-- to create a flat hierarchy
|
||||
lua_modules_path = "lua"
|
||||
'';
|
||||
})).overrideAttrs (drv: {
|
||||
version = attrs.version;
|
||||
rockspecVersion = drv.rockspecVersion;
|
||||
});
|
||||
finalDrv = toVimPlugin (luaDrv.overrideAttrs(oa: {
|
||||
|
||||
finalDrv = toVimPlugin (luaDrv.overrideAttrs(oa: attrs // {
|
||||
nativeBuildInputs = oa.nativeBuildInputs or [] ++ [
|
||||
lua51Packages.luarocksMoveDataFolder
|
||||
lua.pkgs.luarocksMoveDataFolder
|
||||
];
|
||||
}));
|
||||
in
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{ lib
|
||||
, buildLuarocksPackage
|
||||
, callPackage
|
||||
, vimUtils
|
||||
, nodejs
|
||||
, neovim-unwrapped
|
||||
, bundlerEnv
|
||||
, ruby
|
||||
, lua
|
||||
, python3Packages
|
||||
, writeText
|
||||
, wrapNeovimUnstable
|
||||
|
@ -193,7 +193,7 @@ in
|
|||
inherit legacyWrapper;
|
||||
|
||||
buildNeovimPluginFrom2Nix = callPackage ./build-neovim-plugin.nix {
|
||||
inherit (vimUtils) buildVimPluginFrom2Nix toVimPlugin;
|
||||
inherit buildLuarocksPackage;
|
||||
inherit (vimUtils) toVimPlugin;
|
||||
inherit lua;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
, luaLib
|
||||
}:
|
||||
|
||||
{
|
||||
pname
|
||||
{ pname
|
||||
, version
|
||||
# we need rockspecVersion to find the .rockspec even when version changes
|
||||
, rockspecVersion ? version
|
||||
|
||||
# by default prefix `name` e.g. "lua5.2-${name}"
|
||||
, namePrefix ? "${lua.pname}${lua.sourceVersion.major}.${lua.sourceVersion.minor}-"
|
||||
|
@ -72,7 +73,7 @@ pname
|
|||
# Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
|
||||
|
||||
let
|
||||
generatedRockspecFilename = "${rockspecDir}/${pname}-${version}.rockspec";
|
||||
generatedRockspecFilename = "${rockspecDir}/${pname}-${rockspecVersion}.rockspec";
|
||||
|
||||
# TODO fix warnings "Couldn't load rockspec for ..." during manifest
|
||||
# construction -- from initial investigation, appears it will require
|
||||
|
@ -80,20 +81,6 @@ let
|
|||
# luarocks only looks for rockspecs in the default/system tree instead of all
|
||||
# configured trees)
|
||||
luarocks_config = "luarocks-config.lua";
|
||||
luarocks_content = let
|
||||
generatedConfig = luaLib.generateLuarocksConfig {
|
||||
externalDeps = externalDeps ++ externalDepsGenerated;
|
||||
inherit extraVariables;
|
||||
inherit rocksSubdir;
|
||||
inherit requiredLuaRocks;
|
||||
};
|
||||
in
|
||||
''
|
||||
${generatedConfig}
|
||||
${extraConfig}
|
||||
'';
|
||||
|
||||
rocksSubdir = "${attrs.pname}-${version}-rocks";
|
||||
|
||||
# Filter out the lua derivation itself from the Lua module dependency
|
||||
# closure, as it doesn't have a rock tree :)
|
||||
|
@ -106,15 +93,28 @@ let
|
|||
);
|
||||
externalDeps' = lib.filter (dep: !lib.isDerivation dep) externalDeps;
|
||||
|
||||
luarocksDrv = luaLib.toLuaModule ( lua.stdenv.mkDerivation (
|
||||
builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariables"] // {
|
||||
luarocksDrv = luaLib.toLuaModule ( lua.stdenv.mkDerivation (self: let
|
||||
|
||||
name = namePrefix + pname + "-" + version;
|
||||
rocksSubdir = "${self.pname}-${self.version}-rocks";
|
||||
luarocks_content = let
|
||||
generatedConfig = luaLib.generateLuarocksConfig {
|
||||
externalDeps = externalDeps ++ externalDepsGenerated;
|
||||
inherit extraVariables rocksSubdir requiredLuaRocks;
|
||||
};
|
||||
in
|
||||
''
|
||||
${generatedConfig}
|
||||
${extraConfig}
|
||||
'';
|
||||
in builtins.removeAttrs attrs ["disabled" "externalDeps" "extraVariables"] // {
|
||||
|
||||
name = namePrefix + pname + "-" + self.version;
|
||||
inherit rockspecVersion;
|
||||
|
||||
nativeBuildInputs = [
|
||||
wrapLua
|
||||
luarocks
|
||||
] ++ lib.optionals doCheck ([ luarocksCheckHook ] ++ checkInputs);
|
||||
] ++ lib.optionals doCheck ([ luarocksCheckHook ] ++ self.checkInputs);
|
||||
|
||||
buildInputs = buildInputs
|
||||
++ (map (d: d.dep) externalDeps');
|
||||
|
|
|
@ -5,7 +5,7 @@ echo "Sourcing luarocks-move-data-hook.sh"
|
|||
luarocksMoveDataHook () {
|
||||
echo "Executing luarocksMoveDataHook"
|
||||
if [ -d "$out/$rocksSubdir" ]; then
|
||||
cp -rfv "$out/$rocksSubdir/$pname/$version/." "$out"
|
||||
cp -rfv "$out/$rocksSubdir/$pname/$rockspecVersion/." "$out"
|
||||
fi
|
||||
|
||||
echo "Finished executing luarocksMoveDataHook"
|
||||
|
|
|
@ -32314,7 +32314,7 @@ with pkgs;
|
|||
};
|
||||
|
||||
neovimUtils = callPackage ../applications/editors/neovim/utils.nix {
|
||||
inherit (lua51Packages) buildLuarocksPackage;
|
||||
lua = lua5_1;
|
||||
};
|
||||
neovim = wrapNeovim neovim-unwrapped { };
|
||||
|
||||
|
|
Loading…
Reference in a new issue