nixpkgs/pkgs/applications/graphics/imagej/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

84 lines
2.3 KiB
Nix

{ lib
, stdenv
, fetchurl
, glib
, jre
, unzip
, makeWrapper
, makeDesktopItem
, copyDesktopItems
, wrapGAppsHook3
}:
let
icon = fetchurl {
url = "https://imagej.net/media/icons/imagej.png";
sha256 = "sha256-nU2nWI1wxZB/xlOKsZzdUjj+qiCTjO6GwEKYgZ5Risg=";
};
in stdenv.mkDerivation rec {
pname = "imagej";
version = "153";
src = fetchurl {
url = "https://wsr.imagej.net/distros/cross-platform/ij${version}.zip";
sha256 = "sha256-MGuUdUDuW3s/yGC68rHr6xxzmYScUjdXRawDpc1UQqw=";
};
nativeBuildInputs = [ copyDesktopItems makeWrapper unzip wrapGAppsHook3 ];
buildInputs = [ glib ];
dontWrapGApps = true;
desktopItems = lib.optionals stdenv.hostPlatform.isLinux [
(makeDesktopItem {
name = "ImageJ";
desktopName = "ImageJ";
icon = "imagej";
categories = [ "Science" "Utility" "Graphics" ];
exec = "imagej";
})
];
passthru = {
inherit jre;
};
# JAR files that are intended to be used by other packages
# should go to $out/share/java.
# (Some uses ij.jar as a library not as a standalone program.)
installPhase = ''
runHook preInstall
mkdir -p $out/share/java $out/bin
# Read permisssion suffices for the jar and others.
# Simple cp shall clear suid bits, if any.
cp ij.jar $out/share/java
cp -dR luts macros plugins $out/share
runHook postInstall
'';
postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
makeWrapper ${jre}/bin/java $out/bin/imagej \
''${gappsWrapperArgs[@]} \
--add-flags "-jar $out/share/java/ij.jar -ijpath $out/share"
install -Dm644 ${icon} $out/share/icons/hicolor/128x128/apps/imagej.png
substituteInPlace $out/share/applications/ImageJ.desktop \
--replace Exec=imagej Exec=$out/bin/imagej
'';
meta = with lib; {
homepage = "https://imagej.nih.gov/ij/";
description = "Image processing and analysis in Java";
longDescription = ''
ImageJ is a public domain Java image processing program
inspired by NIH Image for the Macintosh.
It runs on any computer with a Java 1.4 or later virtual machine.
'';
sourceProvenance = with sourceTypes; [ binaryBytecode ];
license = licenses.publicDomain;
platforms = platforms.unix;
maintainers = with maintainers; [ yuriaisaka ];
mainProgram = "imagej";
};
}