nixpkgs/pkgs/by-name/ca/calc/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

70 lines
1.9 KiB
Nix

{ lib
, stdenv
, fetchurl
, makeWrapper
, ncurses
, readline
, unixtools
, enableReadline ? true
}:
stdenv.mkDerivation (finalAttrs: {
pname = "calc";
version = "2.15.0.2";
src = fetchurl {
urls = [
"https://github.com/lcn2/calc/releases/download/v${finalAttrs.version}/calc-${finalAttrs.version}.tar.bz2"
"http://www.isthe.com/chongo/src/calc/calc-${finalAttrs.version}.tar.bz2"
];
hash = "sha256-dPEj32SiR7RhI9fBa9ny9+EEuuiXS2WswRcDVuOMJXc=";
};
postPatch = ''
substituteInPlace Makefile.target \
--replace '-install_name ''${LIBDIR}/libcalc''${LIB_EXT_VERSION}' '-install_name ''${T}''${LIBDIR}/libcalc''${LIB_EXT_VERSION}' \
--replace '-install_name ''${LIBDIR}/libcustcalc''${LIB_EXT_VERSION}' '-install_name ''${T}''${LIBDIR}/libcustcalc''${LIB_EXT_VERSION}'
'';
nativeBuildInputs = [
makeWrapper
unixtools.col
];
buildInputs = lib.optionals enableReadline [
ncurses
readline
];
makeFlags = [
"T=$(out)"
"INCDIR="
"BINDIR=/bin"
"LIBDIR=/lib"
"CALC_SHAREDIR=/share/calc"
"CALC_INCDIR=/include"
"MANDIR=/share/man/man1"
# Handle LDFLAGS defaults in calc
"DEFAULT_LIB_INSTALL_PATH=$(out)/lib"
]
++ lib.optionals enableReadline [
"READLINE_LIB=-lreadline"
"USE_READLINE=-DUSE_READLINE"
];
meta = {
homepage = "http://www.isthe.com/chongo/tech/comp/calc/";
description = "C-style arbitrary precision calculator";
mainProgram = "calc";
changelog = "https://github.com/lcn2/calc/blob/v${finalAttrs.version}/CHANGES";
# The licensing situation depends on readline (see section 3 of the LGPL)
# If linked against readline then GPLv2 otherwise LGPLv2.1
license = if enableReadline
then lib.licenses.gpl2Only
else lib.licenses.lgpl21Only;
maintainers = with lib.maintainers; [ matthewbauer ];
platforms = lib.platforms.all;
};
})