Skip to content

Commit 0223e69

Browse files
authored
{SDL1, SDL_compat}: migrate to by-name (#339311)
2 parents 13c7cdc + 36d40df commit 0223e69

File tree

8 files changed

+85
-61
lines changed

8 files changed

+85
-61
lines changed

pkgs/development/libraries/SDL/default.nix renamed to pkgs/by-name/sd/SDL1/package.nix

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,50 @@
1-
{ lib, stdenv, config, fetchurl, fetchpatch, pkg-config, audiofile, libcap, libiconv
1+
{ lib
2+
, alsa-lib
3+
, audiofile
4+
, config
5+
, darwin
6+
, fetchpatch
7+
, fetchurl
8+
, libGL
9+
, libGLU
10+
, libICE
11+
, libXext
12+
, libXrandr
13+
, libcap
14+
, libiconv
15+
, libpulseaudio
16+
, pkg-config
17+
, stdenv
18+
# Boolean flags
19+
, alsaSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid
220
, libGLSupported ? lib.meta.availableOn stdenv.hostPlatform libGL
3-
, openglSupport ? libGLSupported, libGL, libGLU
4-
, alsaSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid, alsa-lib
21+
, openglSupport ? libGLSupported
22+
, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux && !stdenv.hostPlatform.isAndroid && lib.meta.availableOn stdenv.hostPlatform libpulseaudio
523
, x11Support ? !stdenv.isCygwin && !stdenv.hostPlatform.isAndroid
6-
, libXext, libICE, libXrandr
7-
, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux && !stdenv.hostPlatform.isAndroid && lib.meta.availableOn stdenv.hostPlatform libpulseaudio, libpulseaudio
8-
, OpenGL, GLUT, CoreAudio, CoreServices, AudioUnit, Kernel, Cocoa
924
}:
1025

1126
# NOTE: When editing this expression see if the same change applies to
1227
# SDL2 expression too
1328

1429
let
30+
inherit (darwin.apple_sdk.frameworks) OpenGL CoreAudio CoreServices AudioUnit Kernel Cocoa GLUT;
1531
extraPropagatedBuildInputs = [ ]
1632
++ lib.optionals x11Support [ libXext libICE libXrandr ]
17-
++ lib.optionals (openglSupport && stdenv.isLinux) [ libGL libGLU ]
33+
++ lib.optionals (openglSupport && stdenv.isLinux) [ libGL ]
34+
# libGLU doesn’t work with Android's SDL
35+
++ lib.optionals (openglSupport && stdenv.isLinux && (!stdenv.hostPlatform.isAndroid)) [ libGLU ]
1836
++ lib.optionals (openglSupport && stdenv.isDarwin) [ OpenGL GLUT ]
1937
++ lib.optional alsaSupport alsa-lib
2038
++ lib.optional pulseaudioSupport libpulseaudio
2139
++ lib.optional stdenv.isDarwin Cocoa;
22-
rpath = lib.makeLibraryPath extraPropagatedBuildInputs;
2340
in
24-
25-
stdenv.mkDerivation rec {
41+
stdenv.mkDerivation (finalAttrs: {
2642
pname = "SDL";
2743
version = "1.2.15";
2844

2945
src = fetchurl {
30-
url = "https://www.libsdl.org/release/${pname}-${version}.tar.gz";
31-
sha256 = "005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn";
46+
url = "https://www.libsdl.org/release/SDL-${finalAttrs.version}.tar.gz";
47+
hash = "sha256-1tMWp5Pl40gVXw3ZO5eXmJM/uYqh7evMEIgp1kdKrQA=";
3248
};
3349

3450
outputs = [ "out" "dev" ];
@@ -39,8 +55,9 @@ stdenv.mkDerivation rec {
3955

4056
propagatedBuildInputs = [ libiconv ] ++ extraPropagatedBuildInputs;
4157

42-
buildInputs = [ ]
43-
++ lib.optional (!stdenv.hostPlatform.isMinGW && alsaSupport) audiofile
58+
buildInputs =
59+
[ ]
60+
++ lib.optionals (!stdenv.hostPlatform.isMinGW && alsaSupport) [ audiofile ]
4461
++ lib.optionals stdenv.isDarwin [ AudioUnit CoreAudio CoreServices Kernel OpenGL ];
4562

4663
configureFlags = [
@@ -106,12 +123,16 @@ stdenv.mkDerivation rec {
106123
})
107124
];
108125

126+
enableParallelBuilding = true;
127+
109128
postInstall = ''
110129
moveToOutput share/aclocal "$dev"
111130
'';
112131

113132
# See the same place in the expression for SDL2
114-
postFixup = ''
133+
postFixup = let
134+
rpath = lib.makeLibraryPath extraPropagatedBuildInputs;
135+
in ''
115136
for lib in $out/lib/*.so* ; do
116137
if [[ -L "$lib" ]]; then
117138
patchelf --set-rpath "$(patchelf --print-rpath $lib):${rpath}" "$lib"
@@ -123,14 +144,12 @@ stdenv.mkDerivation rec {
123144

124145
passthru = { inherit openglSupport; };
125146

126-
enableParallelBuilding = true;
127-
128-
meta = with lib; {
147+
meta = {
148+
homepage = "http://www.libsdl.org/";
129149
description = "Cross-platform multimedia library";
150+
license = lib.licenses.lgpl21;
130151
mainProgram = "sdl-config";
131-
homepage = "http://www.libsdl.org/";
132-
maintainers = with maintainers; [ lovek323 ];
133-
platforms = platforms.unix;
134-
license = licenses.lgpl21;
152+
maintainers = lib.teams.sdl.members ++ (with lib.maintainers; [ lovek323 ]);
153+
platforms = lib.platforms.unix;
135154
};
136-
}
155+
})
File renamed without changes.
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
11
{ lib
2-
, stdenv
3-
, fetchFromGitHub
4-
, cmake
5-
, pkg-config
62
, SDL2
3+
, cmake
4+
, darwin
5+
, fetchFromGitHub
6+
, libGLU
77
, libiconv
8-
, Cocoa
9-
, autoSignDarwinBinariesHook
108
, mesa
9+
, pkg-config
10+
, stdenv
11+
# Boolean flags
1112
, libGLSupported ? lib.elem stdenv.hostPlatform.system mesa.meta.platforms
1213
, openglSupport ? libGLSupported
13-
, libGLU
1414
}:
1515

1616
let
17-
inherit (lib) optionals makeLibraryPath;
18-
17+
inherit (darwin.apple_sdk.frameworks) Cocoa;
18+
inherit (darwin) autoSignDarwinBinariesHook;
1919
in
20-
stdenv.mkDerivation rec {
20+
stdenv.mkDerivation (finalAttrs: {
2121
pname = "SDL_compat";
2222
version = "1.2.68";
2323

2424
src = fetchFromGitHub {
2525
owner = "libsdl-org";
2626
repo = "sdl12-compat";
27-
rev = "release-" + version;
27+
rev = "release-" + finalAttrs.version;
2828
hash = "sha256-f2dl3L7/qoYNl4sjik1npcW/W09zsEumiV9jHuKnUmM=";
2929
};
3030

3131
nativeBuildInputs = [ cmake pkg-config ]
32-
++ optionals (stdenv.isDarwin && stdenv.isAarch64) [ autoSignDarwinBinariesHook ];
32+
++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ autoSignDarwinBinariesHook ];
3333

3434
propagatedBuildInputs = [ SDL2 ]
35-
++ optionals stdenv.hostPlatform.isDarwin [ libiconv Cocoa ]
36-
++ optionals openglSupport [ libGLU ];
35+
++ lib.optionals stdenv.hostPlatform.isDarwin [ libiconv Cocoa ]
36+
++ lib.optionals openglSupport [ libGLU ];
3737

3838
enableParallelBuilding = true;
3939

40-
setupHook = ../SDL/setup-hook.sh;
40+
setupHook = ./setup-hook.sh;
4141

4242
postFixup = ''
4343
for lib in $out/lib/*${stdenv.hostPlatform.extensions.sharedLibrary}* ; do
4444
if [[ -L "$lib" ]]; then
4545
${if stdenv.hostPlatform.isDarwin then ''
46-
install_name_tool ${lib.strings.concatMapStrings (x: " -add_rpath ${makeLibraryPath [x]} ") propagatedBuildInputs} "$lib"
46+
install_name_tool ${lib.strings.concatMapStrings (x: " -add_rpath ${lib.makeLibraryPath [x]} ") finalAttrs.propagatedBuildInputs} "$lib"
4747
'' else ''
48-
patchelf --set-rpath "$(patchelf --print-rpath $lib):${makeLibraryPath propagatedBuildInputs}" "$lib"
48+
patchelf --set-rpath "$(patchelf --print-rpath $lib):${lib.makeLibraryPath finalAttrs.propagatedBuildInputs}" "$lib"
4949
''}
5050
fi
5151
done
5252
'';
5353

54-
meta = with lib; {
54+
meta = {
55+
homepage = "https://www.libsdl.org/";
5556
description = "Cross-platform multimedia library - build SDL 1.2 applications against 2.0";
57+
license = lib.licenses.zlib;
5658
mainProgram = "sdl-config";
57-
homepage = "https://www.libsdl.org/";
58-
license = licenses.zlib;
59-
maintainers = with maintainers; [ peterhoeg ];
60-
platforms = platforms.all;
59+
maintainers = lib.teams.sdl.members ++ (with lib.maintainers; [ peterhoeg ]);
60+
platforms = lib.platforms.all;
6161
};
62-
}
62+
})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
addSDLPath () {
2+
if [ -e "$1/include/SDL" ]; then
3+
export SDL_PATH="${SDL_PATH-}${SDL_PATH:+ }$1/include/SDL"
4+
# NB this doesn’t work with split dev packages because different packages
5+
# will contain "include/SDL/" and "lib/" directories.
6+
#
7+
# However the SDL_LIB_PATH is consumed by SDL itself and serves to locate
8+
# libraries like SDL_mixer, SDL_image, etc which are not split-package
9+
# so the check above will only trigger on them.
10+
if [ -e "$1/lib" ]; then
11+
export SDL_LIB_PATH="${SDL_LIB_PATH-}${SDL_LIB_PATH:+ }-L$1/lib"
12+
fi
13+
fi
14+
}
15+
16+
addEnvHooks "$hostOffset" addSDLPath

pkgs/games/rott/default.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ stdenv.mkDerivation rec {
4040
"SHAREWARE=${if buildShareware then "1" else "0"}"
4141
];
4242

43-
# when using SDL_compat instead of SDL_classic, SDL_mixer isn't correctly
44-
# detected, but there is no harm just specifying it
43+
# when using SDL_compat instead of SDL1, SDL_mixer isn't correctly detected,
44+
# but there is no harm just specifying it
4545
env.NIX_CFLAGS_COMPILE = toString [
4646
"-I${lib.getDev SDL_mixer}/include/SDL"
4747
];

pkgs/top-level/aliases.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ mapAliases ({
13721372

13731373
### S ###
13741374

1375+
SDL_classic = SDL1; # Added 2024-09-03
13751376
s2n = s2n-tls; # Added 2021-03-03
13761377
sandboxfs = throw "'sandboxfs' has been removed due to being unmaintained, consider using linux namespaces for sandboxing instead"; # Added 2024-06-06
13771378
sane-backends-git = sane-backends; # Added 2021-02-19

pkgs/top-level/all-packages.nix

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23442,19 +23442,7 @@ with pkgs;
2344223442

2344323443
scope-lite = callPackage ../development/libraries/scope-lite { };
2344423444

23445-
SDL_classic = callPackage ../development/libraries/SDL ({
23446-
inherit (darwin.apple_sdk.frameworks) OpenGL CoreAudio CoreServices AudioUnit Kernel Cocoa GLUT;
23447-
} // lib.optionalAttrs stdenv.hostPlatform.isAndroid {
23448-
# libGLU doesn’t work with Android’s SDL
23449-
libGLU = null;
23450-
});
23451-
23452-
SDL_compat = callPackage ../development/libraries/SDL_compat {
23453-
inherit (darwin.apple_sdk.frameworks) Cocoa;
23454-
inherit (darwin) autoSignDarwinBinariesHook;
23455-
};
23456-
23457-
SDL = SDL_classic;
23445+
SDL = SDL1;
2345823446

2345923447
SDL2 = callPackage ../development/libraries/SDL2 {
2346023448
inherit (darwin.apple_sdk.frameworks) AudioUnit Cocoa CoreAudio CoreServices ForceFeedback OpenGL;

0 commit comments

Comments
 (0)