15 # some packages need to be compiled with cmake
20 stdenv.mkDerivation (finalAttrs: {
24 src = fetchFromGitHub {
27 rev = "v${finalAttrs.version}";
28 hash = "sha256-mSwwBuLWoMT38iYaV/BTdDmmBz4heTRJzxBHC0Vrvc4=";
35 postPatch = lib.optionalString stdenv.targetPlatform.isDarwin ''
36 substituteInPlace src/luarocks/core/cfg.lua --subst-var-by 'darwinMinVersion' '${stdenv.targetPlatform.darwinMinVersion}'
39 # Manually written ./configure does not support --build= or --host=:
40 # Error: Unknown flag: --build=x86_64-unknown-linux-gnu
41 configurePlatforms = [ ];
47 configureFlags="$configureFlags --lua-suffix=$LUA_SUFFIX"
50 lua_inc="$(echo "${lua}/include"/*/)"
51 if test -n "$lua_inc"; then
52 configureFlags="$configureFlags --with-lua-include=$lua_inc"
56 nativeBuildInputs = [ makeWrapper installShellFiles lua unzip ];
58 buildInputs = [ curl which ];
61 sed -e "1s@.*@#! ${lua}/bin/lua$LUA_SUFFIX@" -i "$out"/bin/*
62 substituteInPlace $out/etc/luarocks/* \
63 --replace '${lua.luaOnBuild}' '${lua}'
65 + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
66 installShellCompletion --cmd luarocks \
67 --bash <($out/bin/luarocks completion bash) \
68 --fish <($out/bin/luarocks completion fish) \
69 --zsh <($out/bin/luarocks completion zsh)
71 installShellCompletion --cmd luarocks-admin \
72 --bash <($out/bin/luarocks-admin completion bash) \
73 --fish <($out/bin/luarocks-admin completion fish) \
74 --zsh <($out/bin/luarocks-admin completion zsh)
77 for i in "$out"/bin/*; do
80 --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?.lua" \
81 --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \
82 --suffix LUA_CPATH ";" "$(echo "$out"/lib/lua/*/)?.so" \
83 --suffix LUA_CPATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \
84 --suffix PATH : ${lib.makeBinPath ([ unzip ] ++
85 lib.optionals (finalAttrs.pname == "luarocks-nix") [ file nix-prefetch-git ])}
90 propagatedBuildInputs = [ zip unzip cmake ];
92 # unpack hook for src.rock and rockspec files
93 setupHook = ./setup-hook.sh;
95 # cmake is just to compile packages with "cmake" buildType, not luarocks itself
96 dontUseCmakeConfigure = true;
99 export PATH="src/bin:''${PATH:-}"
100 export LUA_PATH="src/?.lua;''${LUA_PATH:-}"
103 disallowedReferences = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
108 updateScript = nix-update-script { };
112 description = "A package manager for Lua";
113 license = licenses.mit;
114 maintainers = with maintainers; [ raskin teto ];
115 platforms = platforms.linux ++ platforms.darwin;
116 downloadPage = "http://luarocks.org/releases/";