pkgs.callPackage vs pkgs.<lua>.pkgs.callPackage
-
Regular Lua modules (no pkgs dependencies): use
pkgs.<lua>.pkgs.callPackagefrompkgs/development/lua-modules/generated-packages.nix -
Lua modules depending on pkgs packages: use
pkgs/top-level/lua-packages.nixThe
callPackageinherited here is stillcallPackage(from pkgs), for these reasons:-
In
pkgs/development/interpreters/lua-5/default.nix:luaPackagesFun = callPackage ../../../top-level/lua-packages.nix { lua = self; };Here
callPackagerefers topkgs.callPackage. -
luaPackagesFunis then passed to:makeScopeWithSplicing' { inherit otherSplices; f = lib.extends extensions luaPackagesFun; }
⚠️ Caution: The
makeScopeWithSplicing'used here comes frompkgs/top-level/splice.nix— it already includespkgs.newScopeand only accepts a single attrset{otherSplices, f, ...}.This is easy to confuse with
lib/customisation.nix'smakeScopeWithSplicing', which accepts two attr parameters.Therefore, Lua's
makeScopeWithSplicing'call extends the original pkgs scope. -