nixpkgs/pkgs/by-name/ip/ipcalc/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

62 lines
1.5 KiB
Nix

{ 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";
};
}