Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 124 lines 3.7 kB view raw
1/* 2This is a minimal/manual luarocks derivation used by `buildLuarocksPackage` to install lua packages. 3 4As a nix user, you should use the generated lua.pkgs.luarocks that contains a luarocks manifest 5which makes it recognizable to luarocks. 6Generating the manifest for luarocks_bootstrap seemed too hackish, which is why we end up 7with two "luarocks" derivations. 8 9*/ 10{ lib 11, stdenv 12, fetchFromGitHub 13, curl 14, makeWrapper 15, which 16, unzip 17, lua 18 # for 'luarocks pack' 19, zip 20, nix-update-script 21 # some packages need to be compiled with cmake 22, cmake 23, installShellFiles 24}: 25 26stdenv.mkDerivation (finalAttrs: { 27 pname = "luarocks_bootstrap"; 28 version = "3.11.1"; 29 30 src = fetchFromGitHub { 31 owner = "luarocks"; 32 repo = "luarocks"; 33 rev = "v${finalAttrs.version}"; 34 hash = "sha256-GglygI8HP+aDFEuucOkjQ2Pgfv4+jW+og+2vL3KoZCQ="; 35 }; 36 37 patches = [ 38 ./darwin-3.7.0.patch 39 ]; 40 41 postPatch = lib.optionalString stdenv.targetPlatform.isDarwin '' 42 substituteInPlace src/luarocks/core/cfg.lua --subst-var-by 'darwinMinVersion' '${stdenv.targetPlatform.darwinMinVersion}' 43 ''; 44 45 # Manually written ./configure does not support --build= or --host=: 46 # Error: Unknown flag: --build=x86_64-unknown-linux-gnu 47 configurePlatforms = [ ]; 48 49 preConfigure = '' 50 lua -e "" || { 51 luajit -e "" && { 52 export LUA_SUFFIX=jit 53 configureFlags="$configureFlags --lua-suffix=$LUA_SUFFIX" 54 } 55 } 56 lua_inc="$(echo "${lua}/include"/*/)" 57 if test -n "$lua_inc"; then 58 configureFlags="$configureFlags --with-lua-include=$lua_inc" 59 fi 60 ''; 61 62 nativeBuildInputs = [ makeWrapper installShellFiles lua unzip ]; 63 64 buildInputs = [ curl which ]; 65 66 postInstall = '' 67 sed -e "1s@.*@#! ${lua}/bin/lua$LUA_SUFFIX@" -i "$out"/bin/* 68 substituteInPlace $out/etc/luarocks/* \ 69 --replace-fail '${lua.luaOnBuild}' '${lua}' 70 '' 71 + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' 72 installShellCompletion --cmd luarocks \ 73 --bash <($out/bin/luarocks completion bash) \ 74 --fish <($out/bin/luarocks completion fish) \ 75 --zsh <($out/bin/luarocks completion zsh) 76 77 installShellCompletion --cmd luarocks-admin \ 78 --bash <($out/bin/luarocks-admin completion bash) \ 79 --fish <($out/bin/luarocks-admin completion fish) \ 80 --zsh <($out/bin/luarocks-admin completion zsh) 81 '' 82 + '' 83 for i in "$out"/bin/*; do 84 test -L "$i" || { 85 wrapProgram "$i" \ 86 --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?.lua" \ 87 --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \ 88 --suffix LUA_CPATH ";" "$(echo "$out"/lib/lua/*/)?.so" \ 89 --suffix LUA_CPATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \ 90 --suffix PATH : ${lib.makeBinPath finalAttrs.propagatedBuildInputs} 91 } 92 done 93 ''; 94 95 propagatedBuildInputs = [ zip unzip cmake ]; 96 97 # unpack hook for src.rock and rockspec files 98 setupHook = ./setup-hook.sh; 99 100 # cmake is just to compile packages with "cmake" buildType, not luarocks itself 101 dontUseCmakeConfigure = true; 102 103 shellHook = '' 104 export PATH="src/bin:''${PATH:-}" 105 export LUA_PATH="src/?.lua;''${LUA_PATH:-}" 106 ''; 107 108 disallowedReferences = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 109 lua.luaOnBuild 110 ]; 111 112 passthru = { 113 updateScript = nix-update-script { }; 114 }; 115 116 meta = with lib; { 117 description = "Package manager for Lua"; 118 license = licenses.mit; 119 maintainers = with maintainers; [ raskin teto ]; 120 mainProgram = "luarocks"; 121 platforms = platforms.linux ++ platforms.darwin; 122 downloadPage = "http://luarocks.org/releases/"; 123 }; 124})