Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.03 61 lines 1.8 kB view raw
1{ stdenv, fetchFromGitLab, buildEnv, makeWrapper, lua, luajit, readline 2, useLuaJit ? false 3, extraLibraries ? [] 4}: 5 6let 7 version = "0.7.2"; 8 # Build a sort of "union package" with all the native dependencies we 9 # have: Lua (or LuaJIT), readline, etc. Then, we can depend on this 10 # and refer to ${urn-rt} instead of ${lua}, ${readline}, etc. 11 urn-rt = buildEnv { 12 name = "urn-rt-${version}"; 13 ignoreCollisions = true; 14 paths = if useLuaJit then 15 [ luajit readline ] 16 else 17 [ lua ]; 18 }; 19 20 inherit (stdenv.lib) optionalString concatMapStringsSep; 21in 22 23stdenv.mkDerivation { 24 name = "urn-${optionalString (extraLibraries != []) "with-libraries-"}${version}"; 25 26 src = fetchFromGitLab { 27 owner = "urn"; 28 repo = "urn"; 29 rev = "v${version}"; 30 sha256 = "0nclr3d8ap0y5cg36i7g4ggdqci6m5q27y9f26b57km8p266kcpy"; 31 }; 32 33 buildInputs = [ makeWrapper ]; 34 # Any packages that depend on the compiler have a transitive 35 # dependency on the Urn runtime support. 36 propagatedBuildInputs = [ urn-rt ]; 37 38 makeFlags = ["-B"]; 39 40 installPhase = '' 41 mkdir -p $out/bin $out/lib 42 install -m 0755 bin/urn.lua $out/bin/urn 43 cp -r lib $out/lib/urn 44 wrapProgram $out/bin/urn \ 45 --add-flags "-i $out/lib/urn --prelude $out/lib/urn/prelude.lisp" \ 46 --add-flags "${concatMapStringsSep " " (x: "-i ${x.libraryPath}") extraLibraries}" \ 47 --prefix PATH : ${urn-rt}/bin/ \ 48 --prefix LD_LIBRARY_PATH : ${urn-rt}/lib/ 49 ''; 50 51 meta = with stdenv.lib; { 52 homepage = https://urn-lang.com; 53 description = "Yet another Lisp variant which compiles to Lua"; 54 license = licenses.bsd3; 55 maintainers = with maintainers; [ CrazedProgrammer ]; 56 }; 57 58 passthru = { 59 inherit urn-rt; 60 }; 61}