vuls: init at 0.27.0 (#348530)
[NixPkgs.git] / pkgs / tools / misc / hdfview / default.nix
blob3274762d87c3071f111e3640979289fbeee42750
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   ant,
6   jdk,
7   hdf4,
8   hdf5,
9   makeDesktopItem,
10   copyDesktopItems,
11   strip-nondeterminism,
12   stripJavaArchivesHook,
15 stdenv.mkDerivation (finalAttrs: {
16   pname = "hdfview";
17   version = "3.3.2";
19   src = fetchFromGitHub {
20     owner = "HDFGroup";
21     repo = "hdfview";
22     rev = "refs/tags/v${finalAttrs.version}";
23     sha256 = "sha256-aJHeknkF38qDH9l+vuzdKFZZTcs/XMjtlHuu/LTF124=";
24   };
26   patches = [
27     # Hardcode isUbuntu=false to avoid calling hostname to detect os
28     ./0001-Hardcode-isUbuntu-false-to-avoid-hostname-dependency.patch
29     # Disable signing on macOS
30     ./disable-mac-signing.patch
31     # Remove timestamp comment from generated versions.properties file
32     ./remove-properties-timestamp.patch
33   ];
35   nativeBuildInputs = [
36     ant
37     jdk
38     copyDesktopItems
39     strip-nondeterminism
40     stripJavaArchivesHook
41   ];
43   HDFLIBS = (hdf4.override { javaSupport = true; }).out;
44   HDF5LIBS = (hdf5.override { javaSupport = true; }).out;
46   buildPhase =
47     let
48       arch = if stdenv.hostPlatform.isx86_64 then "x86_64" else "aarch64";
49     in
50     ''
51       runHook preBuild
53       ant createJPackage -Dmachine.arch=${arch}
55       runHook postBuild
56     '';
58   desktopItem = makeDesktopItem rec {
59     name = "HDFView";
60     desktopName = name;
61     exec = name;
62     icon = name;
63     comment = finalAttrs.finalPackage.meta.description;
64     categories = [
65       "Science"
66       "DataVisualization"
67     ];
68   };
70   installPhase =
71     ''
72       runHook preInstall
73     ''
74     + lib.optionalString stdenv.hostPlatform.isLinux ''
75       mkdir -p $out/bin $out/lib
76       cp -a build/dist/HDFView/bin/HDFView $out/bin/
77       cp -a build/dist/HDFView/lib/app $out/lib/
78       cp -a build/dist/HDFView/lib/libapplauncher.so $out/lib/
79       ln -s ${jdk}/lib/openjdk $out/lib/runtime
81       mkdir -p $out/share/applications $out/share/icons/hicolor/32x32/apps
82       cp src/HDFView.png $out/share/icons/hicolor/32x32/apps/
83     ''
84     + lib.optionalString stdenv.hostPlatform.isDarwin ''
85       mkdir -p $out/Applications
86       cp -a build/dist/HDFView.app $out/Applications/
87     ''
88     + ''
89       runHook postInstall
90     '';
92   preFixup = ''
93     # Remove build timestamp from javadoc files
94     find $out/lib/app{,/mods}/doc/javadocs -name "*.html" -exec strip-nondeterminism --type javadoc {} +
95   '';
97   meta = {
98     description = "A visual tool for browsing and editing HDF4 and HDF5 files";
99     license = lib.licenses.free; # BSD-like
100     homepage = "https://www.hdfgroup.org/downloads/hdfview";
101     downloadPage = "https://github.com/HDFGroup/hdfview";
102     platforms = lib.platforms.unix;
103     maintainers = with lib.maintainers; [ jiegec ];
104     mainProgram = "HDFView";
105     # Startup issue is described here:
106     # https://github.com/NixOS/nixpkgs/issues/340048 A possible solution is
107     # suggested here:
108     # https://forum.hdfgroup.org/t/building-hdfview-3-1-0-on-centos-6-swt-library-not-found/5698
109     # But it requires us to update swt, which is a bit hard, the swt update is tracked here:
110     # https://github.com/NixOS/nixpkgs/issues/219771
111     broken = true;
112   };