1{ lib
2, stdenv
3, fetchFromSourcehut
4, pkg-config
5, zig
6, makeWrapper
7, busybox
8, curl
9, SDL2
10, SDL2_gfx
11, SDL2_image
12, SDL2_ttf
13, findutils
14, jq
15, ncurses
16, gnome
17, xorg
18, util-linux
19, gpsd
20, geoclue2-with-demo-agent
21}:
22
23stdenv.mkDerivation rec {
24 pname = "mepo";
25 version = "1.1";
26
27 src = fetchFromSourcehut {
28 owner = "~mil";
29 repo = pname;
30 rev = version;
31 hash = "sha256-OIZ617QLjiTiDwcsn0DnRussYtjDkVyifr2mdSqA98A=";
32 };
33
34 nativeBuildInputs = [ pkg-config zig makeWrapper ];
35
36 buildInputs = [
37 curl SDL2 SDL2_gfx SDL2_image SDL2_ttf jq ncurses
38 ];
39
40 preBuild = ''
41 export HOME=$TMPDIR
42 '';
43
44 doCheck = true;
45 checkPhase = ''
46 runHook preCheck
47
48 zig build test
49
50 runHook postCheck
51 '';
52
53 installPhase = ''
54 runHook preInstall
55
56 zig build -Drelease-safe=true -Dcpu=baseline --prefix $out install
57 install -d $out/share/man/man1
58 $out/bin/mepo -docman > $out/share/man/man1/mepo.1
59
60 runHook postInstall
61 '';
62
63 postInstall = ''
64 substituteInPlace $out/bin/mepo_ui_menu_user_pin_updater.sh \
65 --replace /usr/libexec/geoclue-2.0 ${geoclue2-with-demo-agent}/libexec/geoclue-2.0
66 substituteInPlace $out/bin/mepo_ui_central_menu.sh \
67 --replace "grep mepo_" "grep '^\.mepo_\|^mepo_'" \
68 --replace " ls " " ls -a " #circumvent wrapping for script detection
69 for program in $out/bin/* ; do
70 wrapProgram $program \
71 --suffix PATH : $out/bin:${lib.makeBinPath ([ jq ncurses curl busybox findutils util-linux gpsd gnome.zenity xorg.xwininfo ])}
72 done
73 '';
74
75 meta = with lib; {
76 description = "Fast, simple, and hackable OSM map viewer";
77 longDescription = ''
78 It is recommended to use the corresponding NixOS module.
79 '';
80
81 homepage = "https://mepo.milesalan.com";
82 license = licenses.gpl3Plus;
83 maintainers = with maintainers; [ sikmir McSinyx laalsaas ];
84 platforms = platforms.linux;
85 };
86}