nixpkgs/pkgs/applications/misc/sweethome3d/default.nix

128 lines
4.2 KiB
Nix
Raw Normal View History

{ lib
, stdenv
, fetchurl
, fetchsvn
, makeWrapper
, makeDesktopItem
# sweethome3d 6.4.2 does not yet build with jdk 9 and later.
# this is fixed on trunk (7699?) but let's build with jdk8 until then.
, jdk8
# it can run on the latest stable jre fine though
, jre
, ant
, gtk3
, gsettings-desktop-schemas
, p7zip
, libXxf86vm
}:
let
# TODO: Should we move this to `lib`? Seems like its would be useful in many cases.
2017-02-12 19:22:35 +00:00
extensionOf = filePath:
lib.concatStringsSep "." (lib.tail (lib.splitString "." (builtins.baseNameOf filePath)));
installIcons = iconName: icons: lib.concatStringsSep "\n" (lib.mapAttrsToList (size: iconFile: ''
mkdir -p "$out/share/icons/hicolor/${size}/apps"
ln -s -T "${iconFile}" "$out/share/icons/hicolor/${size}/apps/${iconName}.${extensionOf iconFile}"
'') icons);
mkSweetHome3D =
{ pname, module, version, src, license, description, desktopName, icons }:
stdenv.mkDerivation rec {
inherit pname version src description;
2021-01-15 05:42:41 +00:00
exec = lib.toLower module;
sweethome3dItem = makeDesktopItem {
inherit exec desktopName;
name = pname;
icon = pname;
comment = description;
genericName = "Computer Aided (Interior) Design";
categories = "Graphics;2DGraphics;3DGraphics;";
};
postPatch = ''
patchelf --set-rpath ${libXxf86vm}/lib lib/java3d-1.6/linux/amd64/libnativewindow_awt.so
patchelf --set-rpath ${libXxf86vm}/lib lib/java3d-1.6/linux/amd64/libnativewindow_x11.so
patchelf --set-rpath ${libXxf86vm}/lib lib/java3d-1.6/linux/i586/libnativewindow_awt.so
patchelf --set-rpath ${libXxf86vm}/lib lib/java3d-1.6/linux/i586/libnativewindow_x11.so
'';
nativeBuildInputs = [ makeWrapper ];
2021-02-26 09:25:13 +00:00
buildInputs = [ ant jdk8 p7zip gtk3 gsettings-desktop-schemas ];
buildPhase = ''
runHook preBuild
ant furniture textures help
mkdir -p $out/share/{java,applications}
mv "build/"*.jar $out/share/java/.
ant
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp install/${module}-${version}.jar $out/share/java/.
${installIcons pname icons}
cp "${sweethome3dItem}/share/applications/"* $out/share/applications
2020-09-04 16:25:51 +01:00
# MESA_GL_VERSION_OVERRIDE is needed since the update from MESA 19.3.3 to 20.0.2:
# without it a "Profiles [GL4bc, GL3bc, GL2, GLES1] not available on device null"
# exception is thrown on startup.
# https://discourse.nixos.org/t/glx-not-recognised-after-mesa-update/6753
makeWrapper ${jre}/bin/java $out/bin/$exec \
2020-09-04 16:25:51 +01:00
--set MESA_GL_VERSION_OVERRIDE 2.1 \
--prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:${gtk3.out}/share:${gsettings-desktop-schemas}/share:$out/share:$GSETTINGS_SCHEMAS_PATH" \
--add-flags "-Dsun.java2d.opengl=true -jar $out/share/java/${module}-${version}.jar -cp $out/share/java/Furniture.jar:$out/share/java/Textures.jar:$out/share/java/Help.jar -d${toString stdenv.hostPlatform.parsed.cpu.bits}"
runHook postInstall
'';
dontStrip = true;
meta = {
homepage = "http://www.sweethome3d.com/index.jsp";
inherit description;
inherit license;
2021-01-15 05:42:41 +00:00
maintainers = [ lib.maintainers.edwtjo ];
platforms = lib.platforms.linux;
};
};
2021-01-15 05:42:41 +00:00
d2u = lib.replaceChars ["."] ["_"];
2019-08-13 22:52:01 +01:00
in {
application = mkSweetHome3D rec {
2021-01-15 05:42:41 +00:00
pname = lib.toLower module + "-application";
2020-09-04 16:25:51 +01:00
version = "6.4.2";
module = "SweetHome3D";
description = "Design and visualize your future home";
2021-01-15 05:42:41 +00:00
license = lib.licenses.gpl2Plus;
2018-12-30 01:29:37 +00:00
src = fetchsvn {
url = "https://svn.code.sf.net/p/sweethome3d/code/tags/V_" + d2u version + "/SweetHome3D/";
2020-09-04 16:25:51 +01:00
sha256 = "13rczayakwb5246hqnp8lnw61p0p7ywr2294bnlp4zwsrz1in9z4";
rev = "7504";
};
desktopName = "Sweet Home 3D";
icons = {
"32x32" = fetchurl {
url = "http://sweethome3d.cvs.sourceforge.net/viewvc/sweethome3d/SweetHome3D/deploy/SweetHome3DIcon32x32.png";
sha256 = "1r2fhfg27mx00nfv0qj66rhf719s2g1vhdis7bdc9mqk9x0mb0ir";
};
"48x48" = fetchurl {
url = "http://sweethome3d.cvs.sourceforge.net/viewvc/sweethome3d/SweetHome3D/deploy/SweetHome3DIcon48x48.png";
sha256 = "1ap6d75dyqqvx21wddvn8vw2apq3v803vmbxdriwd0dw9rq3zn4g";
};
2014-10-07 07:45:26 +01:00
};
};
}