foomatic-db (cups ppd files): init at unstable/2022-10-03

`foomatic-db` contains the collected knowledge about printers,
drivers, and driver options from OpenPrinting in xml files.
It also provides thousands of ppd files.
The build process patches those files to reference executables
in the nix store and gzips them to reduce storage
(from about 670 MiB to 90 MiB installed).

In contrast to the sister package `foomatic-db-nonfree`
(packaged in a follow-up commit),
this package only includes files published under a free license.
Most files are published under the GPL,
some under the MIT license.
For details see
https://github.com/OpenPrinting/foomatic-db/blob/master/COPYING .
To encompass the different licenses, the package's
license is set to "free" as the common denominator.

ppd files can be found in `$out/share/cups/model/foomatic-db`.
The subdirectory `foomatic-db` is used to avoid conflicts
with other packages that might be combined with the package
`foomatic-db` in `config.services.printing.drivers`.

There is a daily snapshot of a source archive available at
https://www.openprinting.org/download/foomatic/ .
However, these files rotate daily and
cannot be used as a stable download source.
So we rely on OpenPrinting's Github repository
instead and pinpoint a fresh commit.

Yarny0 90a8a78e cd4c8d63

+100
+99
pkgs/misc/cups/drivers/foomatic-db/default.nix
··· 1 + { lib 2 + , stdenv 3 + , fetchFromGitHub 4 + , cups 5 + , cups-filters 6 + , ghostscript 7 + , gnused 8 + , perl 9 + , autoconf 10 + , automake 11 + , patchPpdFilesHook 12 + }: 13 + 14 + stdenv.mkDerivation { 15 + pname = "foomatic-db"; 16 + version = "unstable-2022-10-03"; 17 + 18 + src = fetchFromGitHub { 19 + # there is also a daily snapshot at the `downloadPage`, 20 + # but it gets deleted quickly and would provoke 404 errors 21 + owner = "OpenPrinting"; 22 + repo = "foomatic-db"; 23 + rev = "2a3c4d1bf7eadc42f936ce8989c1dd2973ea9669"; 24 + hash = "sha256-in0/j1nAQvM0NowBIBx3jj5WVMPIfZAeAk1SkuA3tjA="; 25 + }; 26 + 27 + buildInputs = [ cups cups-filters ghostscript gnused perl ]; 28 + 29 + nativeBuildInputs = [ autoconf automake patchPpdFilesHook perl ]; 30 + 31 + # sed-substitute indirection is more robust 32 + # against characters in paths that might need escaping 33 + postPatch = '' 34 + sed -Ei -e 's|^(S?BINSEARCHPATH=).+$|\1"@PATH@"|g' \ 35 + -e 's|^(DATASEARCHPATH=).+$|\1"@DATA@"|g' configure.ac 36 + substituteInPlace configure.ac \ 37 + --subst-var PATH \ 38 + --subst-var-by DATA "${placeholder "out"}/share" 39 + ''; 40 + 41 + preConfigure = '' 42 + mkdir -p "${placeholder "out"}/share/foomatic/db/source" 43 + ./make_configure 44 + ''; 45 + 46 + # don't let the intaller gzip ppd files as we would 47 + # have to unzip them later in order to patch them 48 + configureFlags = [ "--disable-gzip-ppds" ]; 49 + 50 + # make ppd files available to cups, 51 + # use a package-specific subdirectory to avoid 52 + # conflicts with other ppd-containing packages 53 + postInstall = '' 54 + if ! [[ -d "${placeholder "out"}/share/foomatic/db/source/PPD" ]]; then 55 + echo "failed to create share/foomatic/db/source/PPD" 56 + exit 1 57 + fi 58 + mkdir -p "${placeholder "out"}/share/cups/model" 59 + ln -s "${placeholder "out"}/share/foomatic/db/source/PPD" \ 60 + "${placeholder "out"}/share/cups/model/foomatic-db" 61 + ''; 62 + 63 + # Comments indicate the respective 64 + # package the command is contained in. 65 + ppdFileCommands = [ 66 + "cat" "date" "printf" # coreutils 67 + "rastertohp" # cups 68 + "foomatic-rip" # cups-filters or foomatic-filters 69 + "gs" # ghostscript 70 + "sed" # gnused 71 + "perl" # perl 72 + ]; 73 + 74 + # compress ppd files 75 + postFixup = '' 76 + echo 'compressing ppd files' 77 + find -H "${placeholder "out"}/share/cups/model/foomatic-db" -type f -iname '*.ppd' -print0 \ 78 + | xargs -0r -n 64 -P "$NIX_BUILD_CORES" gzip -9n 79 + ''; 80 + 81 + meta = { 82 + description = "OpenPrinting printer support database (free content)"; 83 + downloadPage = "https://www.openprinting.org/download/foomatic/"; 84 + homepage = "https://openprinting.github.io/projects/02-foomatic/"; 85 + license = lib.licenses.free; # mostly GPL and MIT, see README in source dir 86 + maintainers = [ lib.maintainers.yarny ]; 87 + # list printer manufacturers here so people 88 + # searching for ppd files can find this package 89 + longDescription = '' 90 + The collected knowledge about printers, 91 + drivers, and driver options in XML files. 92 + Besides the XML files, this package contains 93 + about 6,600 PPD files, for printers from 94 + Brother, Canon, Epson, Gestetner, HP, InfoPrint, 95 + Infotec, KONICA_MINOLTA, Kyocera, Lanier, Lexmark, NRG, 96 + Oce, Oki, Ricoh, Samsung, Savin, Sharp, Toshiba and Utax. 97 + ''; 98 + }; 99 + }
+1
pkgs/top-level/all-packages.nix
··· 36319 36319 36320 36320 epson-workforce-635-nx625-series = callPackage ../misc/drivers/epson-workforce-635-nx625-series { }; 36321 36321 36322 + foomatic-db = callPackage ../misc/cups/drivers/foomatic-db {}; 36322 36323 foomatic-db-engine = callPackage ../misc/cups/drivers/foomatic-db-engine {}; 36323 36324 36324 36325 gutenprint = callPackage ../misc/drivers/gutenprint { };