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