nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 21.05 69 lines 2.0 kB view raw
1{ lib, stdenv, lua, buildEnv, makeWrapper 2, extraLibs ? [] 3, extraOutputsToInstall ? [] 4, postBuild ? "" 5, ignoreCollisions ? false 6, requiredLuaModules 7, makeWrapperArgs ? [] 8}: 9 10# Create a lua executable that knows about additional packages. 11let 12 env = let 13 paths = requiredLuaModules (extraLibs ++ [ lua ] ); 14 in (buildEnv { 15 name = "${lua.name}-env"; 16 17 inherit paths; 18 inherit ignoreCollisions; 19 extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall; 20 21 # we create wrapper for the binaries in the different packages 22 postBuild = '' 23 if [ -L "$out/bin" ]; then 24 unlink "$out/bin" 25 fi 26 mkdir -p "$out/bin" 27 28 addToLuaPath "$out" 29 30 # take every binary from lua packages and put them into the env 31 for path in ${lib.concatStringsSep " " paths}; do 32 nix_debug "looking for binaries in path = $path" 33 if [ -d "$path/bin" ]; then 34 cd "$path/bin" 35 for prg in *; do 36 if [ -f "$prg" ]; then 37 rm -f "$out/bin/$prg" 38 if [ -x "$prg" ]; then 39 nix_debug "Making wrapper $prg" 40 makeWrapper "$path/bin/$prg" "$out/bin/$prg" --suffix LUA_PATH ';' "$LUA_PATH" --suffix LUA_CPATH ';' "$LUA_CPATH" ${lib.concatStringsSep " " makeWrapperArgs} 41 fi 42 fi 43 done 44 fi 45 done 46 '' + postBuild; 47 48 inherit (lua) meta; 49 50 passthru = lua.passthru // { 51 interpreter = "${env}/bin/lua"; 52 inherit lua; 53 env = stdenv.mkDerivation { 54 name = "interactive-${lua.name}-environment"; 55 nativeBuildInputs = [ env ]; 56 57 buildCommand = '' 58 echo >&2 "" 59 echo >&2 "*** lua 'env' attributes are intended for interactive nix-shell sessions, not for building! ***" 60 echo >&2 "" 61 exit 1 62 ''; 63 }; 64 }; 65 }).overrideAttrs (_: { 66 # Add extra deps needed for postBuild hook. 67 nativeBuildInputs = [ makeWrapper lua ]; 68 }); 69in env