Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libcapsule: init at 0.20240806.0; libglcapsule: init; libGL: point to libglcapsule and make supporting changes #337995

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nixos/modules/hardware/graphics.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ let

driversEnv = pkgs.buildEnv {
name = "graphics-drivers";
paths = [ cfg.package ] ++ cfg.extraPackages;
paths = [ cfg.package pkgs.libGL ] ++ cfg.extraPackages;
};

driversEnv32 = pkgs.buildEnv {
name = "graphics-drivers-32bit";
paths = [ cfg.package32 ] ++ cfg.extraPackages32;
paths = [ cfg.package32 pkgs.libGL ] ++ cfg.extraPackages32;
};
in
{
Expand Down
65 changes: 65 additions & 0 deletions pkgs/by-name/li/libcapsule/mkCapsule.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
lib,
stdenv,
runCommand,
autoreconfHook,
autoconf,
automake,
getopt,
pkg-config,
libcapsule,
libtool,
}:

{
pname,
dependencies,
objects,
meta ? {},
}@args:

stdenv.mkDerivation (finalAttrs: {
inherit pname;
inherit (libcapsule) version;

outputs = [ "out" "dev" ];

src = runCommand "${pname}-src" {
nativeBuildInputs = [
autoconf
automake
libtool
pkg-config
];
buildInputs = [
libcapsule
];
LD_LIBRARY_PATH = lib.makeLibraryPath dependencies;
} ''
capsule-init-project --destination=$out --package-name=${pname} --runtime-tree="/" ${lib.concatStringsSep " " objects}
'';

nativeBuildInputs = [
autoreconfHook
pkg-config
getopt
];
buildInputs = [
libcapsule
];

# Do hacky stuff to pull dev outputs from dependencies that have them
postInstall = ''
mkdir -p $dev/include $dev/lib/pkgconfig
'' + (lib.concatStringsSep "\n" (builtins.map (dep: ''
cp -r ${dep.dev}/include/. $dev/include/
for pc in $(find ${dep.dev}/lib/pkgconfig -printf "%P\n"); do
cat "${dep.dev}/lib/pkgconfig/$pc" | sed "s|${dep}|$out|g" | sed "s|${dep.dev}|$dev|g" > $dev/lib/pkgconfig/$pc
done
'') (builtins.filter (dep: builtins.hasAttr "dev" dep) dependencies)));

meta = {
description = "libcapsule-wrapped ${lib.concatStringsSep ", " objects}";
license = lib.licenses.gpl3Plus;
} // meta;
})
72 changes: 72 additions & 0 deletions pkgs/by-name/li/libcapsule/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
lib,
stdenv,
fetchFromGitLab,
autoreconfHook,
autoconf-archive,
elfutils,
getopt,
gtk-doc,
intltool,
libtool,
makeWrapper,
patchelf,
pkg-config,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libcapsule";
version = "0.20240806.0";

src = fetchFromGitLab {
domain = "gitlab.collabora.com";
owner = "vivek";
repo = "libcapsule";
rev = "refs/tags/v${finalAttrs.version}";
hash = "sha256-aJV1u047hCVZhuLvAKe8JvoLe/vGkuuCs/LvD+bLTGU=";
};

postPatch = ''
patchShebangs data
'';

configureFlags = [ "--enable-host-prefix=no" ];

nativeBuildInputs = [
autoreconfHook
autoconf-archive
getopt
gtk-doc
intltool
libtool
makeWrapper
patchelf
pkg-config
];

buildInputs = [
elfutils
];

postInstall = ''
# Manually remove /build/source/tests/.libs from the rpath of this specific test binary
patchelf --shrink-rpath --allowed-rpath-prefixes /nix/store $out/libexec/installed-tests/libcapsule/tests/libcapsule-test-dependent-runpath.so.1

# Tell programs where to find files
wrapProgram $out/bin/capsule-init-project \
--prefix PATH : ${lib.makeBinPath [ getopt pkg-config ]} \
--set CAPSULE_MKINC $out/share/libcapsule/ \
--set CAPSULE_SYMBOLS_TOOL $out/bin/capsule-symbols \
--set CAPSULE_VERSION_TOOL $out/bin/capsule-version
wrapProgram $out/bin/capsule-mkstublib \
--prefix PATH : ${lib.makeBinPath [ pkg-config ]} \
--set CAPSULE_SYMBOLS_TOOL $out/bin/capsule-symbols
'';

meta = {
description = "Segregated dynamic linking library";
homepage = "https://gitlab.collabora.com/vivek/libcapsule";
mainProgram = "capsule-init-project";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [ pandapip1 ];
};
})
14 changes: 14 additions & 0 deletions pkgs/by-name/li/libglcapsule/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
lib,
mkCapsule,
libglvnd,
}:

mkCapsule {
pname = "libglcapsule";
dependencies = [ libglvnd ];
objects = [ "libGL.so" "libEGL.so" "libGLESv1_CM.so" "libGLESv2.so" "libGLX.so" "libOpenGL.so" ];
meta = {
maintainers = with lib.maintainers; [ pandapip1 ];
};
}
10 changes: 4 additions & 6 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22589,7 +22589,7 @@ with pkgs;
else if stdenv.hostPlatform.isDarwin then
darwin.apple_sdk.frameworks.OpenGL
else
libglvnd;
libglcapsule;

# On macOS, we use the OpenGL framework. Packages that use libGLX on
# macOS may need to depend on mesa_glu directly if this doesn’t work.
Expand All @@ -22600,11 +22600,7 @@ with pkgs;
mesa_glu;

# libglvnd does not work (yet?) on macOS.
libGLX =
if stdenv.hostPlatform.isDarwin then
mesa
else
libglvnd;
libGLX = libglcapsule;

# On macOS, we use the GLUT framework. Packages that use libGLX on
# macOS may need to depend on freeglut directly if this doesn’t work.
Expand Down Expand Up @@ -24571,6 +24567,8 @@ with pkgs;
faslExt = "fas";
};

mkCapsule = callPackage ../../pkgs/by-name/li/libcapsule/mkCapsule.nix { };

# Steel Bank Common Lisp
sbcl_2_4_6 = wrapLisp {
pkg = callPackage ../development/compilers/sbcl { version = "2.4.6"; };
Expand Down
Loading