about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/networking/ipcalc/default.nix
blob: e45a2162dd3af1e44af14623d66ecba443db1c7d (plain) (blame)
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
59
60
61
{ lib
, stdenv
, fetchFromGitLab
, meson
, ninja
, pkg-config
, ronn
, withGeo ? true
, geoip
}:

# In order for the geoip part to work, you need to set up a link from
# geoip.dataDir to a directory containing the data files This would typically be
# /var/lib/geoip-databases pointing to geoip-legacy/share/GeoIP

stdenv.mkDerivation rec {
  pname = "ipcalc";
  version = "1.0.3";

  src = fetchFromGitLab {
    owner = "ipcalc";
    repo = "ipcalc";
    rev = version;
    hash = "sha256-9eaR1zG8tjSGlkpyY1zTHAVgN5ypuyRfeRq6ct6zsLU=";
  };

  patches = [
    # disable tests which fail in NixOS sandbox (trying to access the network)
    ./sandbox_tests.patch
  ];

  # technically not needed as we do not support the paid maxmind databases, but
  # keep it around if someone wants to add support and /usr/share/GeoIP is
  # broken anyway
  postPatch = ''
    substituteInPlace ipcalc-maxmind.c \
      --replace /usr/share/GeoIP /var/lib/GeoIP
  '';

  nativeBuildInputs = [ meson ninja pkg-config ronn ];

  buildInputs = [ geoip ];

  mesonFlags = [
    "-Duse_geoip=${if withGeo then "en" else "dis"}abled"
    "-Duse_maxminddb=disabled"
    # runtime linking doesn't work on NixOS anyway
    "-Duse_runtime_linking=disabled"
  ];

  doCheck = true;

  meta = with lib; {
    description = "Simple IP network calculator";
    homepage = "https://gitlab.com/ipcalc/ipcalc";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ peterhoeg ];
    platforms = platforms.unix;
    mainProgram = "ipcalc";
  };
}