Unverified Commit 60b7c9f8 authored by psentee's avatar psentee Committed by GitHub
Browse files

hplip: fix plugin fetch (#391529)

parent cfe28af7
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ let
  };

  plugin = fetchurl {
    url = "https://developers.hp.com/sites/default/files/${pname}-${version}-plugin.run";
    url = "https://www.openprinting.org/download/printdriver/auxfiles/HP/plugins/${pname}-${version}-plugin.run";
    hash = "sha256-Hzxr3SVmGoouGBU2VdbwbwKMHZwwjWnI7P13Z6LQxao=";
  };

@@ -79,9 +79,20 @@ assert
    || throw "HPLIP plugin not supported on ${stdenv.hostPlatform.system}";

python311Packages.buildPythonApplication {
  inherit pname version src;
  inherit pname version;
  format = "other";

  srcs = [ src ] ++ lib.optional withPlugin plugin;

  unpackCmd = lib.optionalString withPlugin ''
    if ! [[ "$curSrc" =~ -plugin\.run$ ]]; then return 1; fi # fallback to regular unpackCmdHooks

    # Unpack plugin shar
    sh "$curSrc" --noexec --keep
  '';

  sourceRoot = "${pname}-${version}";

  buildInputs =
    [
      libjpeg
@@ -247,8 +258,7 @@ python311Packages.buildPythonApplication {
      done
    ''
    + lib.optionalString withPlugin ''
      sh ${plugin} --noexec --keep
      cd plugin_tmp
      pushd $NIX_BUILD_TOP/plugin_tmp

      cp plugin.spec $out/share/hplip/

@@ -284,6 +294,8 @@ python311Packages.buildPythonApplication {

      mkdir -p $out/var/lib/hp
      cp ${hplipState} $out/var/lib/hp/hplip.state

      popd
    '';

  # The installed executables are just symlinks into $out/share/hplip,