From 74838606a066f302a84beca90b275de8ed23fbf4 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Wed, 5 Mar 2025 18:57:57 +0100 Subject: [PATCH] {nixos/tests/}/cups-pdf: use `getExe` and `substituteInPlace` With `lib.getExe`, we also use "magick" instead of "convert`, and thereby avoid the ImageMagick warning message: > WARNING: The convert command is deprecated in IMv7, use "magick" instead of "convert" or "magick convert" The replacement string for the `cp` command is shortened. This is a bit risky since an update might inadvertently introduce a similar string that is then also replaced. However, the leading double-quote and trailing space seem safe enough to me. --- nixos/tests/cups-pdf.nix | 2 +- pkgs/by-name/cu/cups-pdf-to-pdf/package.nix | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nixos/tests/cups-pdf.nix b/nixos/tests/cups-pdf.nix index 69f455a67c94..00623b14a9db 100644 --- a/nixos/tests/cups-pdf.nix +++ b/nixos/tests/cups-pdf.nix @@ -37,7 +37,7 @@ machine.wait_until_succeeds(f"su - alice -c 'pdfinfo /var/spool/cups-pdf-{name}/users/alice/*.pdf'") machine.succeed(f"cp /var/spool/cups-pdf-{name}/users/alice/*.pdf /tmp/{name}.pdf") machine.copy_from_vm(f"/tmp/{name}.pdf", "") - run(f"${hostPkgs.imagemagickBig}/bin/convert -density 300 $out/{name}.pdf $out/{name}.jpeg", shell=True, check=True) + run(f"${lib.getExe hostPkgs.imagemagickBig} -density 300 $out/{name}.pdf $out/{name}.jpeg", shell=True, check=True) assert text.encode() in run(f"${lib.getExe hostPkgs.tesseract} $out/{name}.jpeg stdout", shell=True, check=True, capture_output=True).stdout ''; diff --git a/pkgs/by-name/cu/cups-pdf-to-pdf/package.nix b/pkgs/by-name/cu/cups-pdf-to-pdf/package.nix index 97ec5a226c9d..ffcc45ecd974 100644 --- a/pkgs/by-name/cu/cups-pdf-to-pdf/package.nix +++ b/pkgs/by-name/cu/cups-pdf-to-pdf/package.nix @@ -21,7 +21,8 @@ stdenv.mkDerivation { buildInputs = [ cups ]; postPatch = '' - sed -r 's|(gscall, size, ")cp |\1${coreutils}/bin/cp |' cups-pdf.c -i + substituteInPlace cups-pdf.c \ + --replace-fail '"cp ' '"${lib.getExe' coreutils "cp"} ' ''; # gcc command line is taken from original cups-pdf's README file