2021-02-22 21:28:39 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, makeWrapper
|
|
|
|
, makeDesktopItem
|
2024-02-07 01:22:34 +00:00
|
|
|
, jdk
|
2021-02-22 21:28:39 +00:00
|
|
|
, ant
|
|
|
|
, gtk3
|
|
|
|
, gsettings-desktop-schemas
|
|
|
|
, p7zip
|
2022-05-18 14:49:53 +00:00
|
|
|
, autoPatchelfHook
|
2021-02-22 21:28:39 +00:00
|
|
|
, libXxf86vm
|
2021-05-20 23:08:51 +00:00
|
|
|
, unzip
|
2024-02-07 01:22:34 +00:00
|
|
|
, libGL
|
2021-02-22 21:28:39 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
# TODO: Should we move this to `lib`? Seems like its would be useful in many cases.
|
|
|
|
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 22:18:51 +00:00
|
|
|
exec = lib.toLower module;
|
2020-04-24 23:36:52 +00:00
|
|
|
sweethome3dItem = makeDesktopItem {
|
|
|
|
inherit exec desktopName;
|
|
|
|
name = pname;
|
|
|
|
icon = pname;
|
|
|
|
comment = description;
|
|
|
|
genericName = "Computer Aided (Interior) Design";
|
2022-03-05 16:20:37 +00:00
|
|
|
categories = [ "Graphics" "2DGraphics" "3DGraphics" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-02-22 21:28:39 +00:00
|
|
|
postPatch = ''
|
2024-02-07 01:22:34 +00:00
|
|
|
addAutoPatchelfSearchPath ${jdk}/lib/openjdk/lib/
|
2022-05-18 14:49:53 +00:00
|
|
|
autoPatchelf lib
|
|
|
|
|
|
|
|
# Nix cannot see the runtime references to the paths we just patched in
|
|
|
|
# once they've been compressed into the .jar. Scan for and remember them
|
|
|
|
# as plain text so they don't get overlooked.
|
|
|
|
find . -name '*.so' | xargs strings | { grep '/nix/store' || :; } >> ./.jar-paths
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper unzip autoPatchelfHook ];
|
2024-02-07 01:22:34 +00:00
|
|
|
buildInputs = [ ant jdk p7zip gtk3 gsettings-desktop-schemas libXxf86vm ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildPhase = ''
|
2021-02-22 21:28:39 +00:00
|
|
|
runHook preBuild
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
ant furniture textures help
|
|
|
|
mkdir -p $out/share/{java,applications}
|
|
|
|
mv "build/"*.jar $out/share/java/.
|
|
|
|
ant
|
2021-02-22 21:28:39 +00:00
|
|
|
|
|
|
|
runHook postBuild
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-02-22 21:28:39 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
mkdir -p $out/bin
|
|
|
|
cp install/${module}-${version}.jar $out/share/java/.
|
|
|
|
|
|
|
|
${installIcons pname icons}
|
|
|
|
|
|
|
|
cp "${sweethome3dItem}/share/applications/"* $out/share/applications
|
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
makeWrapper ${jdk}/bin/java $out/bin/$exec \
|
2020-04-24 23:36:52 +00:00
|
|
|
--prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:${gtk3.out}/share:${gsettings-desktop-schemas}/share:$out/share:$GSETTINGS_SCHEMAS_PATH" \
|
2024-02-07 01:22:34 +00:00
|
|
|
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libGL ]}" \
|
2020-07-18 16:06:22 +00:00
|
|
|
--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}"
|
2021-02-22 21:28:39 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
|
|
|
|
# remember the store paths found inside the .jar libraries. note that
|
|
|
|
# which file they are in does not matter in particular, just that some
|
|
|
|
# file somewhere lists them in plain-text
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
cp .jar-paths $out/nix-support/depends
|
|
|
|
|
2021-02-22 21:28:39 +00:00
|
|
|
runHook postInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = "http://www.sweethome3d.com/index.jsp";
|
|
|
|
inherit description;
|
|
|
|
inherit license;
|
2021-01-15 22:18:51 +00:00
|
|
|
maintainers = [ lib.maintainers.edwtjo ];
|
|
|
|
platforms = lib.platforms.linux;
|
2024-02-07 01:22:34 +00:00
|
|
|
mainProgram = exec;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
d2u = lib.replaceStrings ["."] ["_"];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
application = mkSweetHome3D rec {
|
2021-01-15 22:18:51 +00:00
|
|
|
pname = lib.toLower module + "-application";
|
2023-10-19 13:55:26 +00:00
|
|
|
version = "7.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
module = "SweetHome3D";
|
|
|
|
description = "Design and visualize your future home";
|
2021-01-15 22:18:51 +00:00
|
|
|
license = lib.licenses.gpl2Plus;
|
2021-05-20 23:08:51 +00:00
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://sourceforge/sweethome3d/${module}-${version}-src.zip";
|
2023-10-19 13:55:26 +00:00
|
|
|
sha256 = "sha256-Io3HfussfSy6CLHE0JCAk0gjBAla/u+pS1Gan8BxozY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
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";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|