1{
2 stdenv,
3 fetchFromGitHub,
4 buildLuarocksPackage,
5 lua,
6 pkg-config,
7 lib,
8 substituteAll,
9 zenity,
10 AppKit,
11}:
12
13buildLuarocksPackage {
14 pname = "nfd";
15 version = "scm-1";
16
17 src = fetchFromGitHub {
18 owner = "Vexatos";
19 repo = "nativefiledialog";
20 rev = "2f74a5758e8df9b27158d444953697bc13fe90d8";
21 sha256 = "1f52mb0s9zrpsqjp10bx92wzqmy1lq7fg1fk1nd6xmv57kc3b1qv";
22 fetchSubmodules = true;
23 };
24
25 # use zenity because default gtk impl just crashes
26 patches = [
27 (substituteAll {
28 src = ./zenity.patch;
29 inherit zenity;
30 })
31 ];
32 knownRockspec = "lua/nfd-scm-1.rockspec";
33
34 luarocksConfig.variables.LUA_LIBDIR = "${lua}/lib";
35 nativeBuildInputs = [ pkg-config ];
36
37 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ AppKit ];
38
39 postInstall = ''
40 find $out -name nfd_zenity.so -execdir mv {} nfd.so \;
41 '';
42
43 doInstallCheck = true;
44 installCheckInputs = [ lua.pkgs.busted ];
45 installCheckPhase = ''
46 busted lua/spec/
47 '';
48
49 meta = {
50 description = "A tiny, neat lua library that portably invokes native file open and save dialogs.";
51 homepage = "https://github.com/Alloyed/nativefiledialog/tree/master/lua";
52 license = lib.licenses.zlib;
53 maintainers = [ lib.maintainers.scoder12 ];
54 broken = lua.luaversion != "5.1";
55 };
56}