This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
default.nix
58 lines (52 loc) · 1.71 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ nixpkgs ? import <nixpkgs> {}
, enableLuaJit ? false
, lua ? nixpkgs.pkgs.lua
, luajit ? nixpkgs.pkgs.luajit
, readline ? nixpkgs.pkgs.readline
, extraLibraries ? []
}:
let
inherit (nixpkgs) stdenv;
ourVersion = "0.7.2";
# Build a sort of "union package" with all the native dependencies we
# have: Lua (or LuaJIT), readline, etc. Then, we can depend on this
# and refer to ${runtime} instead of ${lua}, ${readline}, etc
runtime = nixpkgs.buildEnv {
name = "urn-rt-${ourVersion}";
ignoreCollisions = true;
paths = if enableLuaJit then
[ luajit readline ]
else
[ lua ];
};
dependencies = if extraLibraries == [] then "" else "-with-libraries";
in
stdenv.mkDerivation rec {
name = "urn-${ourVersion}${dependencies}";
version = ourVersion;
src = ./.;
buildInputs = [ runtime nixpkgs.pkgs.makeWrapper ];
# any packages that depend on the compiler have a transitive
# dependency on the runtime support
propagatedBuildInputs = buildInputs;
makeFlags = ["-B"];
installPhase = ''
install -Dm755 bin/urn.lua $out/bin/urn
mkdir -p $out/lib/
cp -r lib $out/lib/urn
wrapProgram $out/bin/urn \
--add-flags "-i $out/lib/urn --prelude $out/lib/urn/prelude.lisp" \
--add-flags "${nixpkgs.lib.concatMapStringsSep " " (x: "-i ${x.libraryPath}") extraLibraries}" \
--prefix PATH : ${runtime}/bin/ \
--prefix LD_LIBRARY_PATH : ${runtime}/lib/
'';
meta = with stdenv.lib; {
homepage = https://squiddev.github.io/urn;
description = "A lean lisp implementation for Lua";
license = licenses.bsd3;
};
passthru = {
# useful for getting a nix-shell
urn-rt = runtime;
};
}