diff --git a/pkgs/by-name/li/libqalculate/package.nix b/pkgs/by-name/li/libqalculate/package.nix index 1df23ea66396..66fccfc6152f 100644 --- a/pkgs/by-name/li/libqalculate/package.nix +++ b/pkgs/by-name/li/libqalculate/package.nix @@ -14,7 +14,15 @@ libxml2, mpfr, icu, + # Upstream's `plot` UX is not ideal - it doesn't write a good message + # suggesting the user to install this optional dependency when they write + # `plot(..)`. Not to mention support for non-x dependent `gnuplot_qt` + # executable. Hence we hardcode a path to a gnuplot binary by default, and + # changing this is possible via putting an empty string as a `gnuplotBinary` + # - to let `libqalculate` pick it from $PATH during runtime. See also: + # https://github.com/Qalculate/libqalculate/issues/796 gnuplot, + gnuplotBinary ? lib.getExe gnuplot, }: stdenv.mkDerivation (finalAttrs: { @@ -24,7 +32,7 @@ stdenv.mkDerivation (finalAttrs: { src = fetchFromGitHub { owner = "qalculate"; repo = "libqalculate"; - rev = "v${finalAttrs.version}"; + tag = "v${finalAttrs.version}"; hash = "sha256-sjVvsgDQbKXU+N7JrA36zezDfAGcDbyQ0fn1zMThYXQ="; }; @@ -61,16 +69,11 @@ stdenv.mkDerivation (finalAttrs: { intltoolize -f ''; - patchPhase = - '' - substituteInPlace libqalculate/Calculator-plot.cc \ - --replace 'commandline = "gnuplot"' 'commandline = "${gnuplot}/bin/gnuplot"' \ - --replace '"gnuplot - ' '"${gnuplot}/bin/gnuplot - ' - '' - + lib.optionalString stdenv.cc.isClang '' - substituteInPlace src/qalc.cc \ - --replace 'printf(_("aborted"))' 'printf("%s", _("aborted"))' - ''; + postPatch = lib.optionalString (gnuplotBinary != "") '' + substituteInPlace libqalculate/Calculator-plot.cc \ + --replace-fail 'commandline = "gnuplot"' 'commandline = "${gnuplotBinary}"' \ + --replace-fail '"gnuplot - ' '"${gnuplotBinary} - ' + ''; preBuild = '' pushd docs/reference @@ -78,15 +81,15 @@ stdenv.mkDerivation (finalAttrs: { popd ''; - meta = with lib; { + meta = { description = "Advanced calculator library"; homepage = "http://qalculate.github.io"; - license = licenses.gpl2Plus; - maintainers = with maintainers; [ + license = lib.licenses.gpl2Plus; + maintainers = with lib.maintainers; [ doronbehar pentane ]; mainProgram = "qalc"; - platforms = platforms.all; + platforms = lib.platforms.all; }; })