ploticus: Modernize

- Split pname & version.
- Format the expression.
- Do not use custom builder, the generic one is good enough.
- Install the man pages to datadir instead of $out, where they would be moved anyway.
– Allowing us to drop the postFixup.
- Use patch instead of wrapper for pointing to prefabs. This is what Debian does and it will also apply to the pl binary, not just the ploticus alias.
- Since the wrapping is no longer necessary, let’s create the alias using a symlink.

+56 -44
-33
pkgs/tools/graphics/ploticus/builder.sh
··· 1 - source $stdenv/setup 2 - 3 - preBuild() { 4 - cd src 5 - } 6 - 7 - preInstall() { 8 - mkdir -p $out/bin 9 - } 10 - 11 - postInstall() { 12 - # Install the "prefabs". 13 - mkdir -p $out/share/ploticus/prefabs && \ 14 - cd .. && \ 15 - cp -rv prefabs/* $out/share/ploticus/prefabs 16 - 17 - # Create a wrapper that knows where to find them. Debian's package 18 - # does something similar by patching directly the C file that looks 19 - # for `$PLOTICUS_PREFABS'. 20 - cat > $out/bin/ploticus <<EOF 21 - #! $SHELL -e 22 - PLOTICUS_PREFABS="$out/share/ploticus/prefabs" 23 - export PLOTICUS_PREFABS 24 - exec "$out/bin/pl" \$@ 25 - EOF 26 - chmod +x $out/bin/ploticus 27 - 28 - # Install the man pages. 29 - cp -rv man $out 30 - ln -s "$out/man/man1/pl.1" "$out/man/man1/ploticus.1" 31 - } 32 - 33 - genericBuild
···
+46 -11
pkgs/tools/graphics/ploticus/default.nix
··· 1 - {lib, stdenv, fetchurl, zlib, libX11, libpng}: 2 3 stdenv.mkDerivation { 4 - name = "ploticus-2.42"; 5 6 - builder = ./builder.sh; 7 src = fetchurl { 8 url = "mirror://sourceforge/ploticus/ploticus/2.41/pl241src.tar.gz"; 9 sha256 = "1065r0nizjixi9sxxfxrnwg10r458i6fgsd23nrxa200rypvdk7c"; 10 }; 11 12 - buildInputs = [ zlib libX11 libpng ]; 13 14 hardeningDisable = [ "format" ]; 15 16 - patches = [ ./ploticus-install.patch ]; 17 18 - # Make the symlink relative instead of absolute. 19 - # Otherwise it breaks when auto-moved to $out/share. 20 - preFixup = '' 21 - ln -sf pl.1 "$out"/man/man1/ploticus.1 22 ''; 23 24 meta = with lib; { 25 description = "A non-interactive software package for producing plots and charts"; 26 - longDescription = ''Ploticus is a free, GPL'd, non-interactive 27 software package for producing plots, charts, and graphics from 28 data. Ploticus is good for automated or just-in-time graph 29 generation, handles date and time data nicely, and has basic 30 statistical capabilities. It allows significant user control 31 - over colors, styles, options and details.''; 32 license = licenses.gpl2Plus; 33 maintainers = with maintainers; [ pSub ]; 34 homepage = "http://ploticus.sourceforge.net/";
··· 1 + { lib 2 + , stdenv 3 + , fetchurl 4 + , zlib 5 + , libX11 6 + , libpng 7 + }: 8 9 stdenv.mkDerivation { 10 + pname = "ploticus"; 11 + version = "2.42"; 12 13 src = fetchurl { 14 url = "mirror://sourceforge/ploticus/ploticus/2.41/pl241src.tar.gz"; 15 sha256 = "1065r0nizjixi9sxxfxrnwg10r458i6fgsd23nrxa200rypvdk7c"; 16 }; 17 18 + patches = [ 19 + # Replace hardcoded FHS path with $out. 20 + ./ploticus-install.patch 21 + 22 + # Set the location of the PREFABS directory. 23 + ./set-prefabs-dir.patch 24 + ]; 25 + 26 + buildInputs = [ 27 + zlib 28 + libX11 29 + libpng 30 + ]; 31 32 hardeningDisable = [ "format" ]; 33 34 + preBuild = '' 35 + cd src 36 + ''; 37 38 + preInstall = '' 39 + mkdir -p "$out/bin" 40 + ''; 41 + 42 + postInstall = '' 43 + cd .. 44 + 45 + # Install the “prefabs”. 46 + mkdir -p "$out/share/ploticus/prefabs" 47 + cp -rv prefabs/* "$out/share/ploticus/prefabs" 48 + 49 + # Install the man pages. 50 + cp -rv man $out/share 51 + 52 + # Add aliases for backwards compatibility. 53 + ln -s "pl.1" "$out/share/man/man1/ploticus.1" 54 + ln -s "pl" "$out/bin/ploticus" 55 ''; 56 57 meta = with lib; { 58 description = "A non-interactive software package for producing plots and charts"; 59 + longDescription = '' 60 + Ploticus is a free, GPL'd, non-interactive 61 software package for producing plots, charts, and graphics from 62 data. Ploticus is good for automated or just-in-time graph 63 generation, handles date and time data nicely, and has basic 64 statistical capabilities. It allows significant user control 65 + over colors, styles, options and details. 66 + ''; 67 license = licenses.gpl2Plus; 68 maintainers = with maintainers; [ pSub ]; 69 homepage = "http://ploticus.sourceforge.net/";
+10
pkgs/tools/graphics/ploticus/set-prefabs-dir.patch
···
··· 1 + --- a/src/Makefile 2 + +++ b/src/Makefile 3 + @@ -133,6 +133,6 @@ 4 + #### To set a hard-coded directory for prefabs files, uncomment & edit the following.. 5 + #### If done, users won't be required to have PLOTICUS_PREFABS environment variable defined. 6 + #### This option not available for win32 7 + -# PREFABS_DIR = "/usr/lib/ploticus/prefabs" 8 + +PREFABS_DIR = "$(out)/share/ploticus/prefabs" 9 + 10 +