nixpkgs/pkgs/applications/editors/jetbrains/bin/linux.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

162 lines
4.3 KiB
Nix

{
stdenv,
lib,
makeDesktopItem,
makeWrapper,
patchelf,
writeText,
coreutils,
gnugrep,
which,
git,
unzip,
libsecret,
libnotify,
udev,
e2fsprogs,
python3,
autoPatchelfHook,
vmopts ? null,
glibcLocales,
}:
{
pname,
product,
productShort ? product,
version,
src,
wmClass,
buildNumber,
jdk,
meta,
libdbm,
fsnotifier,
extraLdPath ? [ ],
extraWrapperArgs ? [ ],
extraBuildInputs ? [ ],
}@args:
let
loName = lib.toLower productShort;
hiName = lib.toUpper productShort;
vmoptsName = loName + lib.optionalString stdenv.hostPlatform.is64bit "64" + ".vmoptions";
in
with stdenv;
lib.makeOverridable mkDerivation (
rec {
inherit pname version src;
passthru.buildNumber = buildNumber;
meta = args.meta // {
mainProgram = pname;
};
desktopItem = makeDesktopItem {
name = pname;
exec = pname;
comment = lib.replaceStrings [ "\n" ] [ " " ] meta.longDescription;
desktopName = product;
genericName = meta.description;
categories = [ "Development" ];
icon = pname;
startupWMClass = wmClass;
};
vmoptsIDE = if hiName == "WEBSTORM" then "WEBIDE" else hiName;
vmoptsFile = lib.optionalString (vmopts != null) (writeText vmoptsName vmopts);
nativeBuildInputs = [
makeWrapper
patchelf
unzip
autoPatchelfHook
];
buildInputs = extraBuildInputs;
postPatch = ''
rm -rf jbr
# When using the IDE as a remote backend using gateway, it expects the jbr directory to contain the jdk
ln -s ${jdk.home} jbr
if [ -d "plugins/remote-dev-server" ]; then
patch -F3 -p1 < ${../patches/jetbrains-remote-dev.patch}
fi
vmopts_file=bin/linux/${vmoptsName}
if [[ ! -f $vmopts_file ]]; then
vmopts_file=bin/${vmoptsName}
if [[ ! -f $vmopts_file ]]; then
echo "ERROR: $vmopts_file not found"
exit 1
fi
fi
echo -Djna.library.path=${
lib.makeLibraryPath ([
libsecret
e2fsprogs
libnotify
# Required for Help -> Collect Logs
# in at least rider and goland
udev
])
} >> $vmopts_file
'';
installPhase = ''
runHook preInstall
mkdir -p $out/{bin,$pname,share/pixmaps,share/icons/hicolor/scalable/apps}
cp -a . $out/$pname
[[ -f $out/$pname/bin/${loName}.png ]] && ln -s $out/$pname/bin/${loName}.png $out/share/pixmaps/${pname}.png
[[ -f $out/$pname/bin/${loName}.svg ]] && ln -s $out/$pname/bin/${loName}.svg $out/share/pixmaps/${pname}.svg \
&& ln -s $out/$pname/bin/${loName}.svg $out/share/icons/hicolor/scalable/apps/${pname}.svg
cp ${libdbm}/lib/libdbm.so $out/$pname/bin/libdbm.so
cp ${fsnotifier}/bin/fsnotifier $out/$pname/bin/fsnotifier
jdk=${jdk.home}
item=${desktopItem}
launcher="$out/$pname/bin/${loName}"
if [ -e "$launcher" ]; then
rm "$launcher".sh # We do not wrap the old script-style launcher anymore.
else
launcher+=.sh
fi
wrapProgram "$launcher" \
--prefix PATH : "${
lib.makeBinPath [
jdk
coreutils
gnugrep
which
git
]
}" \
--suffix PATH : "${lib.makeBinPath [ python3 ]}" \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath extraLdPath}" \
${lib.concatStringsSep " " extraWrapperArgs} \
--set-default JDK_HOME "$jdk" \
--set-default ANDROID_JAVA_HOME "$jdk" \
--set-default JAVA_HOME "$jdk" \
--set-default JETBRAINS_CLIENT_JDK "$jdk" \
--set-default ${hiName}_JDK "$jdk" \
--set-default LOCALE_ARCHIVE "${glibcLocales}/lib/locale/locale-archive" \
--set-default ${vmoptsIDE}_VM_OPTIONS ${vmoptsFile}
ln -s "$launcher" $out/bin/$pname
rm -rf $out/$pname/plugins/remote-dev-server/selfcontained/
echo -e '#!/usr/bin/env bash\n'"$out/$pname/bin/remote-dev-server.sh"' "$@"' > $out/$pname/bin/remote-dev-server-wrapped.sh
chmod +x $out/$pname/bin/remote-dev-server-wrapped.sh
ln -s "$out/$pname/bin/remote-dev-server-wrapped.sh" $out/bin/$pname-remote-dev-server
ln -s "$item/share/applications" $out/share
runHook postInstall
'';
}
// lib.optionalAttrs (!(meta.license.free or true)) {
preferLocalBuild = true;
}
)