about summary refs log tree commit diff
path: root/pkgs/by-name/fo
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2024-06-02 17:58:13 +0200
committerGitHub <noreply@github.com>2024-06-02 17:58:13 +0200
commit380c5735c0295cde5c2612375ed9a1c4da13f74b (patch)
treecc3f6e457c191b0e6adab0db5014b5a30089eebb /pkgs/by-name/fo
parentda43f07f2737bd53d114bf7d28de306b72dbd81a (diff)
parenta08e26bed861e7b5b5bda25a74d6475cb4329113 (diff)
Merge pull request #309334 from Yarny0/foomatic-db-update
Diffstat (limited to 'pkgs/by-name/fo')
-rw-r--r--pkgs/by-name/fo/foomatic-db-engine/package.nix96
-rw-r--r--pkgs/by-name/fo/foomatic-db-nonfree/package.nix87
-rw-r--r--pkgs/by-name/fo/foomatic-db-ppds/package.nix122
-rw-r--r--pkgs/by-name/fo/foomatic-db/package.nix103
4 files changed, 408 insertions, 0 deletions
diff --git a/pkgs/by-name/fo/foomatic-db-engine/package.nix b/pkgs/by-name/fo/foomatic-db-engine/package.nix
new file mode 100644
index 0000000000000..5408f7eff38e5
--- /dev/null
+++ b/pkgs/by-name/fo/foomatic-db-engine/package.nix
@@ -0,0 +1,96 @@
+{ lib
+, perlPackages
+, fetchFromGitHub
+, withCupsAccess ? false  # needed to access local cups server
+, cups
+, cups-filters
+, curl
+, withSocketAccess ? false  # needed to access network printers
+, netcat-gnu
+, withSMBAccess ? false  # needed to access SMB-connected printers
+, samba
+, autoconf
+, automake
+, file
+, makeWrapper
+}:
+
+perlPackages.buildPerlPackage rec {
+  pname = "foomatic-db-engine";
+  version = "unstable-2024-02-10";
+
+  src = fetchFromGitHub {
+    # there is also a daily snapshot at the `downloadPage`,
+    # but it gets deleted quickly and would provoke 404 errors
+    owner = "OpenPrinting";
+    repo = "foomatic-db-engine";
+    rev = "a2b12271e145fe3fd34c3560d276a57e928296cb";
+    hash = "sha256-qM12qtGotf9C0cjO9IkmzlW9GWCkT2Um+6dU3mZm3DU=";
+  };
+
+  outputs = [ "out" ];
+
+  propagatedBuildInputs = [
+    perlPackages.Clone
+    perlPackages.DBI
+    perlPackages.XMLLibXML
+  ];
+
+  buildInputs =
+       [ curl ]
+       # provide some "cups-*" commands to `foomatic-{configure,printjob}`
+       # so that they can manage a local cups server (add queues, add jobs...)
+    ++ lib.optionals withCupsAccess [ cups cups-filters ]
+       # the commands `foomatic-{configure,getpjloptions}` need
+       # netcat if they are used to query or alter a network
+       # printer via AppSocket/HP JetDirect protocol
+    ++ lib.optional withSocketAccess netcat-gnu
+       # `foomatic-configure` can be used to access printers that are
+       # shared via the SMB protocol, but it needs the `smbclient` binary
+    ++ lib.optional withSMBAccess samba
+  ;
+
+  nativeBuildInputs = [ autoconf automake file makeWrapper ];
+
+  # sed-substitute indirection is more robust against
+  # characters in paths that might need escaping
+  prePatch = ''
+    sed -Ei 's|^(S?BINSEARCHPATH=).+$|\1"@PATH@"|g' configure.ac
+    substituteInPlace configure.ac --subst-var PATH
+    touch Makefile.PL  # `buildPerlPackage` fails unless this exists
+  '';
+
+  preConfigure = ''
+    ./make_configure
+  '';
+
+  configureFlags = [
+    "--sysconfdir=${placeholder "out"}/etc"
+    "LIBDIR=${placeholder "out"}/share/foomatic"
+    "PERLPREFIX=${placeholder "out"}"
+  ];
+
+  postFixup = ''
+    for bin in "${placeholder "out"}/bin"/*; do
+      test '!' -L "$bin" || continue  # skip symlink
+      wrapProgram "$bin" --set PERL5LIB "$PERL5LIB"
+    done
+  '';
+
+  doCheck = false;  # no tests, would fail
+
+  meta = {
+    changelog = "https://github.com/OpenPrinting/foomatic-db-engine/blob/${src.rev}/ChangeLog";
+    description = "OpenPrinting printer support database engine";
+    downloadPage = "https://www.openprinting.org/download/foomatic/";
+    homepage = "https://openprinting.github.io/projects/02-foomatic/";
+    license = lib.licenses.gpl2Only;
+    maintainers = [ lib.maintainers.yarny ];
+    longDescription = ''
+      Foomatic's database engine generates PPD files
+      from the data in Foomatic's XML database.
+      It also contains scripts to directly
+      generate print queues and handle jobs.
+    '';
+  };
+}
diff --git a/pkgs/by-name/fo/foomatic-db-nonfree/package.nix b/pkgs/by-name/fo/foomatic-db-nonfree/package.nix
new file mode 100644
index 0000000000000..a433b58a0ac92
--- /dev/null
+++ b/pkgs/by-name/fo/foomatic-db-nonfree/package.nix
@@ -0,0 +1,87 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, autoconf
+, automake
+, perl
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "foomatic-db-nonfree";
+  version = "unstable-2015-06-05";
+
+  src = fetchFromGitHub {
+    # there is also a daily snapshot at the `downloadPage`,
+    # but it gets deleted quickly and would provoke 404 errors
+    owner = "OpenPrinting";
+    repo = "foomatic-db-nonfree";
+    rev = "6ddae02ac89240c019f8b5026cfe70e30fd2b3db";
+    hash = "sha256-cRZH0CXg03FEqUJdxaNnPVXjf8+ct86PjhL59WQbw60=";
+  };
+
+  nativeBuildInputs = [ autoconf automake perl ];
+
+  # sed-substitute indirection is more robust against
+  # characters in paths that might need escaping
+  postPatch = ''
+    sed -Ei -e 's|^(S?BINSEARCHPATH=).+$|\1"@PATH@"|g'  \
+      -e 's|^(DATASEARCHPATH=).+$|\1"@DATA@"|g' configure.ac
+    substituteInPlace configure.ac  \
+      --subst-var PATH  \
+      --subst-var-by DATA "${placeholder "out"}/share"
+  '';
+
+  preConfigure = ''
+    mkdir -p "${placeholder "out"}/share/foomatic/db/source"
+    ./make_configure
+  '';
+
+  # make ppd files available to cups,
+  # use a package-specific subdirectory to avoid
+  # conflicts with other ppd-containing packages
+  postInstall = ''
+    if ! [[ -d "${placeholder "out"}/share/foomatic/db/source/PPD" ]]; then
+        echo "failed to create share/foomatic/db/source/PPD"
+        exit 1
+    fi
+    mkdir -p "${placeholder "out"}/share/cups/model"
+    ln -s "${placeholder "out"}/share/foomatic/db/source/PPD"  \
+      "${placeholder "out"}/share/cups/model/foomatic-db-nonfree"
+  '';
+
+  # we might patch ppd file commands with `patchPpdFilesHook`,
+  # but the only command "rastertophaser6100" isn't packaged yet
+
+  # compress ppd files
+  postFixup = ''
+    echo 'compressing ppd files'
+    find -H "${placeholder "out"}/share/cups/model/foomatic-db-nonfree" -type f -iname '*.ppd' -print0  \
+      | xargs -0r -n 64 -P "$NIX_BUILD_CORES" gzip -9n
+  '';
+
+  meta = {
+    changelog = "https://github.com/OpenPrinting/foomatic-db-nonfree/blob/${finalAttrs.src.rev}/ChangeLog";
+    description = "OpenPrinting printer support database (unfree content)";
+    downloadPage = "https://www.openprinting.org/download/foomatic/";
+    homepage = "https://openprinting.github.io/projects/02-foomatic/";
+    license = lib.licenses.unfree;
+    maintainers = [ lib.maintainers.yarny ];
+    # list printer manufacturers here so people
+    # searching for ppd files can find this package
+    longDescription = ''
+      The collected knowledge about printers,
+      drivers, and driver options in XML files,
+      used by `foomatic-db-engine` to generate PPD files.
+      This is a package of PPD and Foomatic XML files
+      that may have restrictions that keep them
+      from being used on a variety of machines
+      for licensing and other non-technical reasons.
+      The XML files in this package enable `foomatic-db-ppds`
+      to create about 120 additional PPD files, for printer from
+      Dell, Genicom, Lexmark, Oce, Tektronix and Xerox.
+      Besides the XML files, this package contains
+      about 130 PPD files, for printers from
+      Dell, Genicom, Lexmark, Oce and Xerox.
+    '';
+  };
+})
diff --git a/pkgs/by-name/fo/foomatic-db-ppds/package.nix b/pkgs/by-name/fo/foomatic-db-ppds/package.nix
new file mode 100644
index 0000000000000..bdc1e0a9b5feb
--- /dev/null
+++ b/pkgs/by-name/fo/foomatic-db-ppds/package.nix
@@ -0,0 +1,122 @@
+{ lib
+, foomatic-db
+, foomatic-db-nonfree
+, buildEnv
+, foomatic-db-engine
+, stdenv
+, cups-filters
+, ghostscript
+, netpbm
+, perl
+, psutils
+, patchPpdFilesHook
+, withNonfreeDb ? false  # include foomatic-db-nonfree ppd files
+}:
+
+let
+  foomatic-db-packages = [ foomatic-db ] ++
+    lib.lists.optional withNonfreeDb foomatic-db-nonfree;
+
+  foomatic-db-combined = buildEnv {
+    name = "foomatic-db-combined";
+    paths = foomatic-db-packages;
+    pathsToLink = [ "/share/foomatic" ];
+    # `foomatic-db-combined` is a nativeBuildInput of `foomatic-db-ppds`.
+    # The setup hook defined here helps scripts in
+    # `foomatic-db-engine` to find the database.
+    postBuild = ''
+      mkdir -p "${placeholder "out"}"/{etc/cups,nix-support}
+      cat  >> "${placeholder "out"}/nix-support/setup-hook"  << eof
+      export FOOMATICDB="${placeholder "out"}/share/foomatic"
+      eof
+    '';
+  };
+
+  # the effective license is `free` if all database
+  # packages have free licenses, `unfree` otherwise
+  isFree = lib.trivial.pipe foomatic-db-packages [
+    (lib.lists.map (lib.attrsets.attrByPath [ "meta" "license" ] lib.licenses.unfree))
+    (lib.lists.all (lib.attrsets.attrByPath [ "free" ] true))
+  ];
+in
+
+stdenv.mkDerivation {
+  pname = "foomatic-db-ppds";
+  # the effective version is simply the
+  # highest version of all database packages
+  version = lib.trivial.pipe foomatic-db-packages [
+    (lib.lists.map (lib.attrsets.getAttr "version"))
+    (lib.lists.sort lib.strings.versionOlder)
+    lib.lists.reverseList
+    lib.lists.head
+  ];
+
+  buildInputs = [
+    cups-filters
+    ghostscript
+    netpbm
+    perl
+    psutils
+  ];
+
+  nativeBuildInputs = [
+    foomatic-db-combined
+    foomatic-db-engine
+    patchPpdFilesHook
+  ];
+
+  dontUnpack = true;
+
+  installPhase = ''
+    runHook preInstall
+    mkdir -p "${placeholder "out"}/share/cups/model"
+    foomatic-compiledb -j "$NIX_BUILD_CORES" -d "${placeholder "out"}/share/cups/model/foomatic-db-ppds"
+    runHook postInstall
+  '';
+
+  # Comments indicate the respective
+  # package the command is contained in.
+  ppdFileCommands = [
+    "cat" "echo"  # coreutils
+    "foomatic-rip"  # cups-filters or foomatic-filters
+    "gs"  # ghostscript
+    "pnmflip" "pnmgamma" "pnmnoraw"  # netpbm
+    "perl"  # perl
+    "psresize"  # psutils
+    # These commands aren't packaged yet.
+    # ppd files using these likely won't work.
+    #"c2050" "c2070" "cjet" "lm1100"
+    #"pbm2l2030" "pbm2lwxl" "rastertophaser6100"
+  ];
+
+  # compress ppd files
+  postFixup = ''
+    echo 'compressing ppd files'
+    find -H "${placeholder "out"}/share/cups/model/foomatic-db-ppds" -type f -iname '*.ppd' -print0  \
+      | xargs -0r -n 64 -P "$NIX_BUILD_CORES" gzip -9n
+  '';
+
+  meta = {
+    description = "OpenPrinting ppd files";
+    homepage = "https://openprinting.github.io/projects/02-foomatic/";
+    license = if isFree then lib.licenses.free else lib.licenses.unfree;
+    maintainers = [ lib.maintainers.yarny ];
+    # list printer manufacturers here so people
+    # searching for ppd files can find this package
+    longDescription = ''
+      All PPD files available in
+      OpenPrinting's Foomatic database.
+      This package contains about 8,800 PPD files,
+      for printers from
+      Alps, Anitech, Apollo, Apple, Avery, Brother, Canon,
+      Citizen, CItoh, Compaq, DEC, Dell, Dymo-CoStar, Epson,
+      Fujitsu, FujiXerox, Generic, Genicom, Gestetner,
+      Heidelberg, Hitachi, HP, IBM, Imagen, Imagistics,
+      InfoPrint, Infotec, Kodak, KONICAMINOLTA, Kyocera, Lanier,
+      Lexmark, Minolta, MinoltaQMS, Mitsubishi, NEC, NRG, Oce,
+      Oki, Olivetti, Panasonic, PCPI, Pentax, QMS, Raven, Ricoh,
+      Samsung, Savin, Seiko, Sharp, SiPix, Sony, Star, Tally,
+      Tektronix, TexasInstruments, Toshiba, Xante and Xerox.
+    '';
+  };
+}
diff --git a/pkgs/by-name/fo/foomatic-db/package.nix b/pkgs/by-name/fo/foomatic-db/package.nix
new file mode 100644
index 0000000000000..494216228a063
--- /dev/null
+++ b/pkgs/by-name/fo/foomatic-db/package.nix
@@ -0,0 +1,103 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, cups
+, cups-filters
+, ghostscript
+, gnused
+, perl
+, autoconf
+, automake
+, patchPpdFilesHook
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "foomatic-db";
+  version = "unstable-2024-05-04";
+
+  src = fetchFromGitHub {
+    # there is also a daily snapshot at the `downloadPage`,
+    # but it gets deleted quickly and would provoke 404 errors
+    owner = "OpenPrinting";
+    repo = "foomatic-db";
+    rev = "eaad4c0d2406d4cd38a6d15e5dc93d1bc8358c30";
+    hash = "sha256-A+Op1E16woNl/ppVj0QfdV4XgT1M8sbrpTXtdOz3PYk=";
+  };
+
+  buildInputs = [ cups cups-filters ghostscript gnused perl ];
+
+  nativeBuildInputs = [ autoconf automake patchPpdFilesHook perl ];
+
+  # sed-substitute indirection is more robust
+  # against characters in paths that might need escaping
+  postPatch = ''
+    sed -Ei -e 's|^(S?BINSEARCHPATH=).+$|\1"@PATH@"|g'  \
+      -e 's|^(DATASEARCHPATH=).+$|\1"@DATA@"|g' configure.ac
+    substituteInPlace configure.ac  \
+      --subst-var PATH  \
+      --subst-var-by DATA "${placeholder "out"}/share"
+  '';
+
+  preConfigure = ''
+    mkdir -p "${placeholder "out"}/share/foomatic/db/source"
+    ./make_configure
+  '';
+
+  # don't let the intaller gzip ppd files as we would
+  # have to unzip them later in order to patch them
+  configureFlags = [ "--disable-gzip-ppds" ];
+
+  # make ppd files available to cups,
+  # use a package-specific subdirectory to avoid
+  # conflicts with other ppd-containing packages
+  postInstall = ''
+    if ! [[ -d "${placeholder "out"}/share/foomatic/db/source/PPD" ]]; then
+        echo "failed to create share/foomatic/db/source/PPD"
+        exit 1
+    fi
+    mkdir -p "${placeholder "out"}/share/cups/model"
+    ln -s "${placeholder "out"}/share/foomatic/db/source/PPD"  \
+      "${placeholder "out"}/share/cups/model/foomatic-db"
+  '';
+
+  # Comments indicate the respective
+  # package the command is contained in.
+  ppdFileCommands = [
+    "cat" "date" "printf"  # coreutils
+    "rastertohp"  # cups
+    "foomatic-rip"  # cups-filters or foomatic-filters
+    "gs"  # ghostscript
+    "sed"  # gnused
+    "perl"  # perl
+  ];
+
+  # compress ppd files
+  postFixup = ''
+    echo 'compressing ppd files'
+    find -H "${placeholder "out"}/share/cups/model/foomatic-db" -type f -iname '*.ppd' -print0  \
+      | xargs -0r -n 64 -P "$NIX_BUILD_CORES" gzip -9n
+  '';
+
+  meta = {
+    changelog = "https://github.com/OpenPrinting/foomatic-db/blob/${finalAttrs.src.rev}/ChangeLog";
+    description = "OpenPrinting printer support database (free content)";
+    downloadPage = "https://www.openprinting.org/download/foomatic/";
+    homepage = "https://openprinting.github.io/projects/02-foomatic/";
+    license = lib.licenses.free;  # mostly GPL and MIT, see README in source dir
+    maintainers = [ lib.maintainers.yarny ];
+    # list printer manufacturers here so people
+    # searching for ppd files can find this package
+    longDescription = ''
+      The collected knowledge about printers,
+      drivers, and driver options in XML files,
+      used by `foomatic-db-engine` to generate PPD files.
+      PPD files generated from the XML files in this package
+      are contained in the package 'foomatic-db-ppds'.
+      Besides the XML files, this package contains
+      about 6,700 PPD files, for printers from
+      Brother, Canon, Epson, Gestetner, HP, InfoPrint,
+      Infotec, KONICA_MINOLTA, Kyocera, Lanier, Lexmark, NRG,
+      Oce, Oki, Ricoh, Samsung, Savin, Sharp, Toshiba and Utax.
+    '';
+  };
+})