mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-31 12:44:44 +00:00
this creates some eval errors that will be fixed in the next commit
done with the following script:
```fish
\#!/usr/bin/env fish
set packagesjson (nix eval --impure --json --expr '
let
lib = import ./lib;
in
import pkgs/servers/x11/xorg/default.nix (lib.mapAttrs (
name: _:
if name == "lib" then
lib
else if name == "config" then
{ allowAliases = false; }
else
name
) (__functionArgs (import pkgs/servers/x11/xorg/default.nix))) { }
' | jq)
set one (grep '^ [A-Za-z0-9_-]*$' pkgs/servers/x11/xorg/default.nix | string trim | string replace -r '$' Z | sort | string sub -e -1)
set two (grep '^ [A-Za-z0-9_-]* = [A-Za-z0-9_-]*;$' pkgs/servers/x11/xorg/default.nix | cut -d= -f1 | string trim | string replace -r '$' Z | sort | string sub -e -1)
for arg in $one $two
set oname $arg
set nname (echo $packagesjson | jq -r .$oname)
if test $nname = null
echo (set_color red)warn:(set_color normal) unknown package xorg.$oname >&2
continue
end
echo $oname "->" $nname
# replace basic xorg.$name references
for file in (rg -F "xorg.$oname" --files-with-matches pkgs)
# special cases
sd -F "$oname = xorg.$oname;" "$nname = $nname;" $file
# replace
sd -F "xorg.$oname" "$nname" $file
# fixup function arguments
# prevent duplicate function args
if grep -E " ($oname|$nname),\$" $file >/dev/null
continue
end
if grep 'xorg\..' $file >/dev/null # case1: there is more so we can't just remove the function arg
if grep ' xorg,$' $file >/dev/null
sd ' xorg,$' " xorg,
$nname," $file
else if grep ' xorg ? .*,$' $file >/dev/null
sd 'xorg( ? .*),$' "xorg\$1,
$nname," $file
else
sd -F 'xorg,' "$nname,
xorg," $file
end
else # case there is no more xorg..* so we can just replace the function arg
sd 'xorg(| ? .*),.*$' "$nname," $file
end
end
end
nix fmt
```
155 lines
3.9 KiB
Nix
155 lines
3.9 KiB
Nix
{
|
|
name-prefix ? "temurin",
|
|
brand-name ? "Eclipse Temurin",
|
|
sourcePerArch,
|
|
knownVulnerabilities ? [ ],
|
|
}:
|
|
|
|
{
|
|
stdenv,
|
|
lib,
|
|
fetchurl,
|
|
autoPatchelfHook,
|
|
makeWrapper,
|
|
setJavaClassPath,
|
|
# minimum dependencies
|
|
alsa-lib,
|
|
fontconfig,
|
|
freetype,
|
|
libffi,
|
|
libxtst,
|
|
libxrender,
|
|
libxi,
|
|
libxext,
|
|
libx11,
|
|
zlib,
|
|
# runtime dependencies
|
|
cups,
|
|
# runtime dependencies for GTK+ Look and Feel
|
|
# TODO(@sternenseemann): gtk3 fails to evaluate in pkgsCross.ghcjs.buildPackages
|
|
# which should be fixable, this is a no-rebuild workaround for GHC.
|
|
gtkSupport ? !stdenv.targetPlatform.isGhcjs,
|
|
cairo,
|
|
glib,
|
|
gtk3,
|
|
}:
|
|
|
|
let
|
|
cpuName = stdenv.hostPlatform.parsed.cpu.name;
|
|
runtimeDependencies = [
|
|
cups
|
|
]
|
|
++ lib.optionals gtkSupport [
|
|
cairo
|
|
glib
|
|
gtk3
|
|
];
|
|
runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies;
|
|
validCpuTypes = builtins.attrNames lib.systems.parse.cpuTypes;
|
|
providedCpuTypes = builtins.filter (arch: builtins.elem arch validCpuTypes) (
|
|
builtins.attrNames sourcePerArch
|
|
);
|
|
result = stdenv.mkDerivation {
|
|
pname =
|
|
if sourcePerArch.packageType == "jdk" then
|
|
"${name-prefix}-bin"
|
|
else
|
|
"${name-prefix}-${sourcePerArch.packageType}-bin";
|
|
|
|
version = sourcePerArch.${cpuName}.version or (throw "unsupported CPU ${cpuName}");
|
|
|
|
src = fetchurl {
|
|
inherit (sourcePerArch.${cpuName}) url sha256;
|
|
};
|
|
|
|
buildInputs = [
|
|
alsa-lib # libasound.so wanted by lib/libjsound.so
|
|
fontconfig
|
|
freetype
|
|
(lib.getLib stdenv.cc.cc) # libstdc++.so.6
|
|
libx11
|
|
libxext
|
|
libxi
|
|
libxrender
|
|
libxtst
|
|
zlib
|
|
]
|
|
++ lib.optional stdenv.hostPlatform.isAarch32 libffi;
|
|
|
|
nativeBuildInputs = [
|
|
autoPatchelfHook
|
|
makeWrapper
|
|
];
|
|
|
|
# See: https://github.com/NixOS/patchelf/issues/10
|
|
dontStrip = 1;
|
|
|
|
installPhase = ''
|
|
cd ..
|
|
|
|
mv $sourceRoot $out
|
|
|
|
# jni.h expects jni_md.h to be in the header search path.
|
|
ln -s $out/include/linux/*_md.h $out/include/
|
|
|
|
# Remove some broken manpages.
|
|
# Only for 11 and earlier.
|
|
[ -e "$out/man/ja" ] && rm -r $out/man/ja*
|
|
|
|
# Remove embedded freetype to avoid problems like
|
|
# https://github.com/NixOS/nixpkgs/issues/57733
|
|
find "$out" -name 'libfreetype.so*' -delete
|
|
|
|
# Propagate the setJavaClassPath setup hook from the JDK so that
|
|
# any package that depends on the JDK has $CLASSPATH set up
|
|
# properly.
|
|
mkdir -p $out/nix-support
|
|
printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs
|
|
|
|
# Set JAVA_HOME automatically.
|
|
cat <<EOF >> "$out/nix-support/setup-hook"
|
|
if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
|
|
EOF
|
|
|
|
# We cannot use -exec since wrapProgram is a function but not a command.
|
|
#
|
|
# jspawnhelper is executed from JVM, so it doesn't need to wrap it, and it
|
|
# breaks building OpenJDK (#114495).
|
|
for bin in $( find "$out" -executable -type f -not -name jspawnhelper ); do
|
|
if patchelf --print-interpreter "$bin" &> /dev/null; then
|
|
wrapProgram "$bin" --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}"
|
|
fi
|
|
done
|
|
'';
|
|
|
|
preFixup = ''
|
|
find "$out" -name libfontmanager.so -exec \
|
|
patchelf --add-needed libfontconfig.so {} \;
|
|
'';
|
|
|
|
# FIXME: use multiple outputs or return actual JRE package
|
|
passthru = {
|
|
jre = result;
|
|
home = result;
|
|
};
|
|
|
|
meta = {
|
|
license = with lib.licenses; [
|
|
gpl2
|
|
classpathException20
|
|
];
|
|
sourceProvenance = with lib.sourceTypes; [
|
|
binaryNativeCode
|
|
binaryBytecode
|
|
];
|
|
description = "${brand-name}, prebuilt OpenJDK binary";
|
|
platforms = map (arch: arch + "-linux") providedCpuTypes; # some inherit jre.meta.platforms
|
|
maintainers = with lib.maintainers; [ taku0 ];
|
|
teams = [ lib.teams.java ];
|
|
inherit knownVulnerabilities;
|
|
mainProgram = "java";
|
|
};
|
|
};
|
|
in
|
|
result
|