Skip to content

Commit

Permalink
sweethome3d.application: 7.2 -> 7.3
Browse files Browse the repository at this point in the history
(cherry picked from commit 8b3445a)
  • Loading branch information
bigshaq9999 committed Apr 14, 2024
1 parent 6ec8515 commit ce3d279
Showing 1 changed file with 93 additions and 89 deletions.
182 changes: 93 additions & 89 deletions pkgs/applications/misc/sweethome3d/default.nix
Original file line number Diff line number Diff line change
@@ -1,117 +1,122 @@
{ lib
, stdenv
, fetchurl
, makeWrapper
, makeDesktopItem
# sweethome3d 6.5.2 does not yet fully build&run with jdk 9 and later?
, jdk8
, jre8
, ant
, gtk3
, gsettings-desktop-schemas
, p7zip
, autoPatchelfHook
, libXxf86vm
, unzip
}:

let

{
lib,
stdenv,
fetchurl,
makeWrapper,
makeDesktopItem,
# sweethome3d 6.5.2 does not yet fully build&run with jdk 9 and later?
jdk8,
jre8,
ant,
gtk3,
gsettings-desktop-schemas,
p7zip,
autoPatchelfHook,
libXxf86vm,
unzip,
}: 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;
exec = lib.toLower module;
sweethome3dItem = makeDesktopItem {
inherit exec desktopName;
name = pname;
icon = pname;
comment = description;
genericName = "Computer Aided (Interior) Design";
categories = [ "Graphics" "2DGraphics" "3DGraphics" ];
};
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;
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 = ''
addAutoPatchelfSearchPath ${jre8}/lib/openjdk/jre/lib/
autoPatchelf lib
postPatch = ''
addAutoPatchelfSearchPath ${jre8}/lib/openjdk/jre/lib/
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
'';
# 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
'';

nativeBuildInputs = [ makeWrapper unzip autoPatchelfHook ];
buildInputs = [ ant jdk8 p7zip gtk3 gsettings-desktop-schemas libXxf86vm ];
nativeBuildInputs = [makeWrapper unzip autoPatchelfHook];
buildInputs = [ant jdk8 p7zip gtk3 gsettings-desktop-schemas libXxf86vm];

buildPhase = ''
runHook preBuild
buildPhase = ''
runHook preBuild
ant furniture textures help
mkdir -p $out/share/{java,applications}
mv "build/"*.jar $out/share/java/.
ant
ant furniture textures help
mkdir -p $out/share/{java,applications}
mv "build/"*.jar $out/share/java/.
ant
runHook postBuild
'';
runHook postBuild
'';

installPhase = ''
runHook preInstall
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp install/${module}-${version}.jar $out/share/java/.
mkdir -p $out/bin
cp install/${module}-${version}.jar $out/share/java/.
${installIcons pname icons}
${installIcons pname icons}
cp "${sweethome3dItem}/share/applications/"* $out/share/applications
cp "${sweethome3dItem}/share/applications/"* $out/share/applications
# 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 ${jre8}/bin/java $out/bin/$exec \
--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}"
# 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 ${jre8}/bin/java $out/bin/$exec \
--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}"
# 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
# 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
runHook postInstall
'';
runHook postInstall
'';

dontStrip = true;
dontStrip = true;

meta = {
homepage = "http://www.sweethome3d.com/index.jsp";
inherit description;
inherit license;
maintainers = [ lib.maintainers.edwtjo ];
platforms = lib.platforms.linux;
meta = {
homepage = "http://www.sweethome3d.com/index.jsp";
inherit description;
inherit license;
maintainers = [lib.maintainers.edwtjo];
platforms = lib.platforms.linux;
};
};
};

d2u = lib.replaceStrings ["."] ["_"];

in {

application = mkSweetHome3D rec {
pname = lib.toLower module + "-application";
version = "7.2";
version = "7.3";
module = "SweetHome3D";
description = "Design and visualize your future home";
license = lib.licenses.gpl2Plus;
Expand All @@ -131,5 +136,4 @@ in {
};
};
};

}

0 comments on commit ce3d279

Please sign in to comment.