luarocks: patch sw_vers and gcc on darwin

The sw_vers binary is not part of the stdenv and it would make builds
impure based on what macOS version they where built on.
This commit is contained in:
Daiderd Jordan 2019-02-11 21:10:30 +01:00
parent 1a88aa9e0c
commit be1291e11b
No known key found for this signature in database
GPG Key ID: D02435D05B810C96
2 changed files with 39 additions and 10 deletions

View File

@ -0,0 +1,27 @@
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 55cd4c9..060a6f1 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -587,9 +587,9 @@ if cfg.platforms.macosx then
defaults.external_lib_extension = "dylib"
defaults.arch = "macosx-"..cfg.target_cpu
defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load"
- defaults.variables.STAT = "/usr/bin/stat"
+ defaults.variables.STAT = "stat"
defaults.variables.STATFLAG = "-f '%A'"
- local version = io.popen("sw_vers -productVersion"):read("*l")
+ local version = "10.10"
version = tonumber(version and version:match("^[^.]+%.([^.]+)")) or 3
if version >= 10 then
version = 8
@@ -598,8 +598,8 @@ if cfg.platforms.macosx then
else
defaults.gcc_rpath = false
end
- defaults.variables.CC = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." gcc"
- defaults.variables.LD = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." gcc"
+ defaults.variables.CC = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." clang"
+ defaults.variables.LD = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." clang"
defaults.web_browser = "open"
end

View File

@ -6,6 +6,7 @@
# some packages need to be compiled with cmake
, cmake
}:
let
s = # Generated upstream information
rec {
@ -20,12 +21,14 @@ let
lua curl makeWrapper which unzip
];
in
stdenv.mkDerivation {
inherit (s) name version;
inherit buildInputs;
src = fetchurl {
inherit (s) url sha256;
};
patches = [ ./darwin.patch ];
preConfigure = ''
lua -e "" || {
luajit -e "" && {
@ -47,7 +50,6 @@ stdenv.mkDerivation {
--suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \
--suffix LUA_CPATH ";" "$(echo "$out"/lib/lua/*/)?.so" \
--suffix LUA_CPATH ";" "$(echo "$out"/share/lua/*/)?/init.lua"
}
done
'';