From e03c9c3f1be4994c63b27ce60d41f13ebfeb3cad Mon Sep 17 00:00:00 2001 From: Matthieu Coudron <886074+teto@users.noreply.github.com> Date: Fri, 24 Nov 2023 00:08:45 +0100 Subject: [PATCH] buildLuarocksPackage: save luarocks config as derivation (#269402) * buildLuarocksPackage: save luarocks config as derivation while debugging luarocks packages, it's exhausting to have to build them, look at what random folder they've been built to finally look for their config. With this you can run nix build lua51Packages.plenary-nvim.configFile -f . and infer what luarocks will do. * Update pkgs/development/interpreters/lua-5/build-luarocks-package.nix Co-authored-by: Marc Jakobi --------- Co-authored-by: Marc Jakobi --- .../interpreters/lua-5/build-luarocks-package.nix | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkgs/development/interpreters/lua-5/build-luarocks-package.nix b/pkgs/development/interpreters/lua-5/build-luarocks-package.nix index 3b49b60ca5d3..c388d0eef8c1 100644 --- a/pkgs/development/interpreters/lua-5/build-luarocks-package.nix +++ b/pkgs/development/interpreters/lua-5/build-luarocks-package.nix @@ -3,6 +3,7 @@ , lua , wrapLua , luarocks +, writeTextFile # Whether the derivation provides a lua module or not. , luarocksCheckHook @@ -83,7 +84,7 @@ let __structuredAttrs = true; env = { - LUAROCKS_CONFIG="$PWD/${luarocks_config}"; + LUAROCKS_CONFIG = self.configFile; } // attrs.env or {}; generatedRockspecFilename = "${rockspecDir}/${pname}-${rockspecVersion}.rockspec"; @@ -111,6 +112,12 @@ let # explicitly inherit this for it to be available as a shell variable in the # builder rocksSubdir = "${self.pname}-${self.version}-rocks"; + + configFile = writeTextFile { + name = pname + "-luarocks-config.lua"; + text = self.luarocks_content; + }; + luarocks_content = let externalDepsGenerated = lib.filter (drv: !drv ? luaModule) (self.nativeBuildInputs ++ self.propagatedBuildInputs ++ self.buildInputs); @@ -131,12 +138,6 @@ let configurePhase = '' runHook preConfigure - - cat > ${luarocks_config} <