laptop: add IDEAappwrapper to set JAVA_HOME

This commit is contained in:
Lgmrszd 2025-01-28 22:45:22 +04:00
parent 317d66bab2
commit 476280c3ef
No known key found for this signature in database
GPG key ID: 9396B8BA6FBB14DE
2 changed files with 33 additions and 4 deletions

View file

@ -26,4 +26,33 @@
'';
dontBuild = true;
};
IDEAappwrapper =
{
pkgs,
inputpkg,
pkgsuffix,
libraries,
jdk
}: with pkgs; let
name = "${inputpkg.pname}-${pkgsuffix}";
in stdenv.mkDerivation {
inherit name;
inherit (inputpkg) version;
nativeBuildInputs = [ makeWrapper gnused ];
buildCommand = ''
mkdir -p $out/bin
mkdir -p $out/share/applications
cp ${inputpkg}/share/applications/${inputpkg.pname}.desktop $out/share/applications/${name}.desktop
makeWrapper ${inputpkg}/bin/${inputpkg.pname} $out/bin/${name} \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath libraries}" \
--prefix PATH : "${lib.makeBinPath [jdk]}" \
--set JAVA_HOME "${jdk}/lib/openjdk"
substituteInPlace $out/share/applications/${name}.desktop \
--replace-fail "=${inputpkg.pname}" "=${name}"
sed -i -E "s/^Name=(.*)/Name=\1 (${pkgsuffix})/g" "$out/share/applications/${name}.desktop"
echo $out/bin/${name}
'';
dontBuild = true;
};
}