Unverified Commit 4e1ce256 authored by Arne Keller's avatar Arne Keller Committed by GitHub
Browse files

flashlabel-yxwl: init at 1.2.1 (#350375)

parents 2b6ed25f 899c84ef
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1301,6 +1301,13 @@
    githubId = 45176912;
    name = "Tomasz Hołubowicz";
  };
  altsalt = {
    email = "salt@sal.td";
    github = "altsalt";
    githubId = 2441328;
    matrix = "@salt:sal.td";
    name = "Wm Salt Hale";
  };
  alunduil = {
    email = "alunduil@gmail.com";
    github = "alunduil";
@@ -1589,6 +1596,13 @@
    githubId = 7644264;
    name = "Andrew Gazelka";
  };
  AndrewKvalheim = {
    email = "andrew@kvalhe.im";
    github = "AndrewKvalheim";
    githubId = 1844746;
    matrix = "@andrew:kvalhe.im";
    name = "Andrew Kvalheim";
  };
  andrewrk = {
    email = "superjoe30@gmail.com";
    github = "andrewrk";
+87 −0
Original line number Diff line number Diff line
{
  autoPatchelfHook,
  cups,
  lib,
  requireFile,
  stdenv,
}:

stdenv.mkDerivation rec {
  pname = "flashlabel-yxwl";
  version = "1.2.1";

  # The source URL currently redirects through “pCloud”, a file storage service
  # that resists direct downloads.
  src = requireFile {
    name = "A4_Linux_Driver_Ver${version}.run";
    url = "https://flashlabel.net/YXWL-A4driver-linux";
    hash = "sha256-qkc3NJ1dK0nJf+Q7xL7f1/+X0COWSWMEbH4luzaFARc=";
  };

  # The driver is distributed as a self-extracting executable consisting of a
  # shell script concatenated with a gzipped tar archive. The script hard codes
  # its length in the `lines` variable, which we read to locate the archive.
  unpackPhase = ''
    lines="$(sed 's/^lines=//; t; d' "$src")"
    tail --lines "+$lines" "$src" | tar --extract --gzip --strip-components=1
  '';

  patchPhase = ''
    runHook prePatch

    # Remove model from manufacturer name
    sed --in-place 's/\(^\*Manufacturer: "YXWL\) [^"]*\("$\)/\1\2/' *.ppd

    runHook postPatch
  '';

  nativeBuildInputs = [ autoPatchelfHook ];
  buildInputs = [ cups ];

  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    runHook preInstall

    mkdir --parents $out/lib/cups/filter
    mv {A80,A80H} $out/lib/cups/filter

    mkdir --parents $out/share/cups/model
    mv *.ppd $out/share/cups/model

    runHook postInstall
  '';

  postFixup = ''
    gzip --best $out/share/cups/model/*.ppd
  '';

  meta = {
    description = "CUPS driver for FlashLabel A4 thermal printers";
    longDescription = ''
      Supported models:

        - A80
        - A80H
        - A81
        - A81H
        - C80
        - C80H
        - D80
        - D80 Pro
        - Y8
        - Y8 Pro
        - Y80
    '';
    homepage = "https://help.flashlabel.com/support/solutions/articles/150000191214";
    downloadPage = "https://flashlabel.net/YXWL-A4driver-linux";
    license = lib.licenses.unfree;
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    platforms = [ "x86_64-linux" ];
    maintainers = with lib.maintainers; [
      altsalt
      AndrewKvalheim
    ];
  };
}