2021-09-18 10:52:07 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitLab
|
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, pkg-config
|
|
|
|
, ronn
|
2022-07-14 12:49:19 +00:00
|
|
|
, withGeo ? true
|
|
|
|
, geoip
|
2021-09-18 10:52:07 +00:00
|
|
|
}:
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
# 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
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "ipcalc";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "1.0.3";
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
src = fetchFromGitLab {
|
|
|
|
owner = "ipcalc";
|
|
|
|
repo = "ipcalc";
|
|
|
|
rev = version;
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-9eaR1zG8tjSGlkpyY1zTHAVgN5ypuyRfeRq6ct6zsLU=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
patches = [
|
|
|
|
# disable tests which fail in NixOS sandbox (trying to access the network)
|
|
|
|
./sandbox_tests.patch
|
|
|
|
];
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
# 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"
|
2021-09-18 10:52:07 +00:00
|
|
|
];
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
doCheck = true;
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Simple IP network calculator";
|
2021-09-18 10:52:07 +00:00
|
|
|
homepage = "https://gitlab.com/ipcalc/ipcalc";
|
|
|
|
license = licenses.gpl2Plus;
|
2022-07-14 12:49:19 +00:00
|
|
|
maintainers = with maintainers; [ peterhoeg ];
|
2023-07-15 17:15:38 +00:00
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|