nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 makeWrapper,
6 ncurses,
7 readline,
8 unixtools,
9 enableReadline ? true,
10}:
11
12stdenv.mkDerivation (finalAttrs: {
13 pname = "calc";
14 version = "2.15.0.2";
15
16 src = fetchurl {
17 urls = [
18 "https://github.com/lcn2/calc/releases/download/v${finalAttrs.version}/calc-${finalAttrs.version}.tar.bz2"
19 "http://www.isthe.com/chongo/src/calc/calc-${finalAttrs.version}.tar.bz2"
20 ];
21 hash = "sha256-dPEj32SiR7RhI9fBa9ny9+EEuuiXS2WswRcDVuOMJXc=";
22 };
23
24 postPatch = ''
25 substituteInPlace Makefile.target \
26 --replace '-install_name ''${LIBDIR}/libcalc''${LIB_EXT_VERSION}' '-install_name ''${T}''${LIBDIR}/libcalc''${LIB_EXT_VERSION}' \
27 --replace '-install_name ''${LIBDIR}/libcustcalc''${LIB_EXT_VERSION}' '-install_name ''${T}''${LIBDIR}/libcustcalc''${LIB_EXT_VERSION}'
28 '';
29
30 nativeBuildInputs = [
31 makeWrapper
32 unixtools.col
33 ];
34
35 buildInputs = lib.optionals enableReadline [
36 ncurses
37 readline
38 ];
39
40 makeFlags = [
41 "T=$(out)"
42 "INCDIR="
43 "BINDIR=/bin"
44 "LIBDIR=/lib"
45 "CALC_SHAREDIR=/share/calc"
46 "CALC_INCDIR=/include"
47 "MANDIR=/share/man/man1"
48
49 # Handle LDFLAGS defaults in calc
50 "DEFAULT_LIB_INSTALL_PATH=$(out)/lib"
51 ]
52 ++ lib.optionals enableReadline [
53 "READLINE_LIB=-lreadline"
54 "USE_READLINE=-DUSE_READLINE"
55 ];
56
57 meta = {
58 homepage = "http://www.isthe.com/chongo/tech/comp/calc/";
59 description = "C-style arbitrary precision calculator";
60 mainProgram = "calc";
61 changelog = "https://github.com/lcn2/calc/blob/v${finalAttrs.version}/CHANGES";
62 # The licensing situation depends on readline (see section 3 of the LGPL)
63 # If linked against readline then GPLv2 otherwise LGPLv2.1
64 license = if enableReadline then lib.licenses.gpl2Only else lib.licenses.lgpl21Only;
65 maintainers = with lib.maintainers; [ matthewbauer ];
66 platforms = lib.platforms.all;
67 };
68})