lol
1{ lib
2, stdenv
3, fetchFromGitLab
4, meson
5, ninja
6, pkg-config
7, ronn
8, withGeo ? true
9, geoip
10}:
11
12# In order for the geoip part to work, you need to set up a link from
13# geoip.dataDir to a directory containing the data files This would typically be
14# /var/lib/geoip-databases pointing to geoip-legacy/share/GeoIP
15
16stdenv.mkDerivation rec {
17 pname = "ipcalc";
18 version = "1.0.3";
19
20 src = fetchFromGitLab {
21 owner = "ipcalc";
22 repo = "ipcalc";
23 rev = version;
24 hash = "sha256-9eaR1zG8tjSGlkpyY1zTHAVgN5ypuyRfeRq6ct6zsLU=";
25 };
26
27 patches = [
28 # disable tests which fail in NixOS sandbox (trying to access the network)
29 ./sandbox_tests.patch
30 ];
31
32 # technically not needed as we do not support the paid maxmind databases, but
33 # keep it around if someone wants to add support and /usr/share/GeoIP is
34 # broken anyway
35 postPatch = ''
36 substituteInPlace ipcalc-maxmind.c \
37 --replace /usr/share/GeoIP /var/lib/GeoIP
38 '';
39
40 nativeBuildInputs = [ meson ninja pkg-config ronn ];
41
42 buildInputs = [ geoip ];
43
44 mesonFlags = [
45 "-Duse_geoip=${if withGeo then "en" else "dis"}abled"
46 "-Duse_maxminddb=disabled"
47 # runtime linking doesn't work on NixOS anyway
48 "-Duse_runtime_linking=disabled"
49 ];
50
51 doCheck = true;
52
53 meta = with lib; {
54 description = "Simple IP network calculator";
55 homepage = "https://gitlab.com/ipcalc/ipcalc";
56 license = licenses.gpl2Plus;
57 maintainers = with maintainers; [ peterhoeg ];
58 platforms = platforms.unix;
59 };
60}