about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorTomaSajt <62384384+TomaSajt@users.noreply.github.com>2023-07-19 23:57:37 +0200
committerTomaSajt <62384384+TomaSajt@users.noreply.github.com>2023-08-20 03:46:05 +0200
commit04939367c9f1d418a7adfb400c35ba02aba1c497 (patch)
treeda17efcce6ff070b7ee199da645e379f465958ef /pkgs
parentdbd0bd32f956a4f8a64857da4bba61313477714b (diff)
trimage: init at 1.0.7-dev
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/graphics/trimage/default.nix70
-rw-r--r--pkgs/top-level/all-packages.nix2
2 files changed, 72 insertions, 0 deletions
diff --git a/pkgs/applications/graphics/trimage/default.nix b/pkgs/applications/graphics/trimage/default.nix
new file mode 100644
index 0000000000000..269ffa5852331
--- /dev/null
+++ b/pkgs/applications/graphics/trimage/default.nix
@@ -0,0 +1,70 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, substituteAll
+
+, python3
+, installShellFiles
+, makeWrapper
+, wrapQtAppsHook
+
+, advancecomp
+, jpegoptim
+, optipng
+, pngcrush
+}:
+
+let
+  pythonEnv = python3.withPackages (ps: with ps; [ pyqt5 ]);
+  binPath = lib.makeBinPath [
+    advancecomp
+    jpegoptim
+    optipng
+    pngcrush
+  ];
+in
+stdenv.mkDerivation {
+  pname = "trimage";
+  version = "1.0.7-dev";
+
+  src = fetchFromGitHub {
+    owner = "Kilian";
+    repo = "Trimage";
+    rev = "ad74684272a31eee6af289cc59fd90fd962d2806";
+    hash = "sha256-jdcGGTqr3f3Xnp6thYmASQYiZh9nagLUTmlFnJ5Hqmc=";
+  };
+
+  nativeBuildInputs = [
+    installShellFiles
+    makeWrapper
+    wrapQtAppsHook
+  ];
+
+  dontWrapQtApps = true;
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir $out
+    cp -R trimage $out
+
+    installManPage doc/trimage.1
+    install -Dm444 desktop/trimage.desktop -t $out/share/applications
+    install -Dm444 desktop/trimage.svg -t $out/share/icons/hicolor/scalable/apps
+
+    makeWrapper ${pythonEnv}/bin/python $out/bin/trimage \
+          --add-flags "$out/trimage/trimage.py" \
+          --prefix PATH : ${binPath} \
+          "''${qtWrapperArgs[@]}"
+
+    runHook postInstall
+  '';
+
+  meta = {
+    description = "A cross-platform tool for optimizing PNG and JPG files";
+    homepage = "https://github.com/Kilian/Trimage";
+    license = lib.licenses.mit;
+    mainProgram = "trimage";
+    maintainers = with lib.maintainers; [ tomasajt ];
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 1a27f9e0bfbe8..630027232fbd3 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -1881,6 +1881,8 @@ with pkgs;
 
   trigger-control = callPackage ../tools/games/trigger-control { };
 
+  trimage = callPackage ../applications/graphics/trimage { inherit (qt5) wrapQtAppsHook; };
+
   ttchat = callPackage ../tools/misc/ttchat { };
 
   ukmm = callPackage ../tools/games/ukmm { };