nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 144 lines 3.9 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 versionCheckHook, 19 # for 'luarocks pack' 20 zip, 21 nix-update-script, 22 # some packages need to be compiled with cmake 23 cmake, 24 installShellFiles, 25}: 26 27stdenv.mkDerivation (finalAttrs: { 28 pname = "luarocks_bootstrap"; 29 version = "3.13.0"; 30 31 src = fetchFromGitHub { 32 owner = "luarocks"; 33 repo = "luarocks"; 34 tag = "v${finalAttrs.version}"; 35 hash = "sha256-ETVoDpeFSsW7ld2z31Vog3RKsMquoxd7c8m9y7Fb1wk="; 36 }; 37 38 patches = [ 39 ./darwin-3.7.0.patch 40 ]; 41 42 postPatch = lib.optionalString stdenv.targetPlatform.isDarwin '' 43 substituteInPlace src/luarocks/core/cfg.lua --subst-var-by 'darwinMinVersion' '${stdenv.targetPlatform.darwinMinVersion}' 44 ''; 45 46 # Manually written ./configure does not support --build= or --host=: 47 # Error: Unknown flag: --build=x86_64-unknown-linux-gnu 48 configurePlatforms = [ ]; 49 50 preConfigure = '' 51 lua -e "" || { 52 luajit -e "" && { 53 export LUA_SUFFIX=jit 54 appendToVar configureFlags "--lua-suffix=$LUA_SUFFIX" 55 } 56 } 57 lua_inc="$(echo "${lua}/include"/*/)" 58 if test -n "$lua_inc"; then 59 appendToVar configureFlags "--with-lua-include=$lua_inc" 60 fi 61 ''; 62 63 nativeBuildInputs = [ 64 makeWrapper 65 installShellFiles 66 lua 67 unzip 68 versionCheckHook 69 ]; 70 71 buildInputs = [ 72 curl 73 which 74 ]; 75 76 postInstall = '' 77 sed -e "1s@.*@#! ${lua}/bin/lua$LUA_SUFFIX@" -i "$out"/bin/* 78 substituteInPlace $out/etc/luarocks/* \ 79 --replace-quiet '${lua.luaOnBuild}' '${lua}' 80 '' 81 + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' 82 installShellCompletion --cmd luarocks \ 83 --bash <($out/bin/luarocks completion bash) \ 84 --fish <($out/bin/luarocks completion fish) \ 85 --zsh <($out/bin/luarocks completion zsh) 86 87 installShellCompletion --cmd luarocks-admin \ 88 --bash <($out/bin/luarocks-admin completion bash) \ 89 --fish <($out/bin/luarocks-admin completion fish) \ 90 --zsh <($out/bin/luarocks-admin completion zsh) 91 '' 92 + '' 93 for i in "$out"/bin/*; do 94 test -L "$i" || { 95 wrapProgram "$i" \ 96 --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?.lua" \ 97 --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \ 98 --suffix LUA_CPATH ";" "$(echo "$out"/lib/lua/*/)?.so" \ 99 --suffix LUA_CPATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \ 100 --suffix PATH : ${lib.makeBinPath finalAttrs.propagatedNativeBuildInputs} 101 } 102 done 103 ''; 104 105 propagatedNativeBuildInputs = [ 106 zip 107 unzip 108 cmake 109 ]; 110 111 doInstallCheck = true; 112 versionCheckProgram = "${placeholder "out"}/bin/luarocks"; 113 114 # unpack hook for src.rock and rockspec files 115 setupHook = ./setup-hook.sh; 116 117 # cmake is just to compile packages with "cmake" buildType, not luarocks itself 118 dontUseCmakeConfigure = true; 119 120 shellHook = '' 121 export PATH="src/bin:''${PATH:-}" 122 export LUA_PATH="src/?.lua;''${LUA_PATH:-}" 123 ''; 124 125 disallowedReferences = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 126 lua.luaOnBuild 127 ]; 128 129 passthru = { 130 updateScript = nix-update-script { }; 131 }; 132 133 meta = { 134 description = "Package manager for Lua"; 135 license = lib.licenses.mit; 136 maintainers = with lib.maintainers; [ 137 raskin 138 teto 139 ]; 140 mainProgram = "luarocks"; 141 platforms = lib.platforms.linux ++ lib.platforms.darwin; 142 downloadPage = "http://luarocks.org/releases/"; 143 }; 144})