Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 140 lines 3.8 kB view raw
1/* 2 This is a minimal/manual luarocks derivation used by `buildLuarocksPackage` to install lua packages. 3 4 As a nix user, you should use the generated lua.pkgs.luarocks that contains a luarocks manifest 5 which makes it recognizable to luarocks. 6 Generating the manifest for luarocks_bootstrap seemed too hackish, which is why we end up 7 with 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 appendToVar configureFlags "--lua-suffix=$LUA_SUFFIX" 54 } 55 } 56 lua_inc="$(echo "${lua}/include"/*/)" 57 if test -n "$lua_inc"; then 58 appendToVar configureFlags "--with-lua-include=$lua_inc" 59 fi 60 ''; 61 62 nativeBuildInputs = [ 63 makeWrapper 64 installShellFiles 65 lua 66 unzip 67 ]; 68 69 buildInputs = [ 70 curl 71 which 72 ]; 73 74 postInstall = 75 '' 76 sed -e "1s@.*@#! ${lua}/bin/lua$LUA_SUFFIX@" -i "$out"/bin/* 77 substituteInPlace $out/etc/luarocks/* \ 78 --replace-quiet '${lua.luaOnBuild}' '${lua}' 79 '' 80 + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' 81 installShellCompletion --cmd luarocks \ 82 --bash <($out/bin/luarocks completion bash) \ 83 --fish <($out/bin/luarocks completion fish) \ 84 --zsh <($out/bin/luarocks completion zsh) 85 86 installShellCompletion --cmd luarocks-admin \ 87 --bash <($out/bin/luarocks-admin completion bash) \ 88 --fish <($out/bin/luarocks-admin completion fish) \ 89 --zsh <($out/bin/luarocks-admin completion zsh) 90 '' 91 + '' 92 for i in "$out"/bin/*; do 93 test -L "$i" || { 94 wrapProgram "$i" \ 95 --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?.lua" \ 96 --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \ 97 --suffix LUA_CPATH ";" "$(echo "$out"/lib/lua/*/)?.so" \ 98 --suffix LUA_CPATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \ 99 --suffix PATH : ${lib.makeBinPath finalAttrs.propagatedNativeBuildInputs} 100 } 101 done 102 ''; 103 104 propagatedNativeBuildInputs = [ 105 zip 106 unzip 107 cmake 108 ]; 109 110 # unpack hook for src.rock and rockspec files 111 setupHook = ./setup-hook.sh; 112 113 # cmake is just to compile packages with "cmake" buildType, not luarocks itself 114 dontUseCmakeConfigure = true; 115 116 shellHook = '' 117 export PATH="src/bin:''${PATH:-}" 118 export LUA_PATH="src/?.lua;''${LUA_PATH:-}" 119 ''; 120 121 disallowedReferences = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 122 lua.luaOnBuild 123 ]; 124 125 passthru = { 126 updateScript = nix-update-script { }; 127 }; 128 129 meta = with lib; { 130 description = "Package manager for Lua"; 131 license = licenses.mit; 132 maintainers = with maintainers; [ 133 raskin 134 teto 135 ]; 136 mainProgram = "luarocks"; 137 platforms = platforms.linux ++ platforms.darwin; 138 downloadPage = "http://luarocks.org/releases/"; 139 }; 140})