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