git.iko.soy/typeable/nixpkgs
on master help sign in
mpv: add flag for swift on darwin

While we currently don't have a pure swift build on macOS it's possible to build mpv using the swift compiler from CLT. eg. self: super: let CommandLineTools = "/Library/Developer/CommandLineTools"; in { swift = super.stdenv.mkDerivation { name = "swift-CommandLineTools-0.0.0"; phases = [ "installPhase" "fixupPhase" ]; propagatedBuildInputs = [ self.darwin.DarwinTools ]; installPhase = '' mkdir -p $out/bin $out/lib ln -s ${CommandLineTools}/usr/bin/swift $out/bin ln -s ${CommandLineTools}/usr/lib/swift $out/lib ln -s ${CommandLineTools}/SDKs $out ''; setupHook = builtins.toFile "hook" '' addCommandLineTools() { echo >&2 echo "WARNING: this is impure and unreliable, make sure the CommandLineTools are installed!" >&2 echo " $ xcode-select --install" >&2 echo >&2 [ -d ${CommandLineTools} ] export NIX_LDFLAGS+=" -L@out@/lib/swift/macosx" export SWIFT=swift export SWIFT_LIB_DYNAMIC=@out@/lib/swift/macosx export MACOS_SDK_VERSION=$(sw_vers -productVersion | awk -F. '{print $1 "." $2}') export MACOS_SDK=@out@/SDKs/MacOSX$MACOS_SDK_VERSION.sdk } prePhases+=" addCommandLineTools" ''; __impureHostDeps = [ CommandLineTools ]; }; mpv = super.mpv.override { swiftSupport = true; }; }

commit3987ea9a9d4464869ac6b8e8519a386190b6b68d authorDaiderd Jordan <daiderd@gmail.com> dateThu 6 Feb 2020, 14:15 (7 years ago) parentf8a38f6
2 files changed+8−5
pkgs/applications/video/mpv/default.nix+7−5 pkgs/os-specific/darwin/apple-sdk/frameworks.nix+1
pkgs/applications/video/mpv/default.nix+7−5
@@ -38,11 +38,12 @@
3838, libpngSupport ? true, libpng ? null
3939, pulseSupport ? config.pulseaudio or stdenv.isLinux, libpulseaudio ? null
4040, rubberbandSupport ? stdenv.isLinux, rubberband ? null
41−, screenSaverSupport ? true, libXScrnSaver ? null
4241, sambaSupport ? stdenv.isLinux, samba ? null
42+, screenSaverSupport ? true, libXScrnSaver ? null
4343, sdl2Support ? true, SDL2 ? null
4444, sndioSupport ? true, sndio ? null
4545, speexSupport ? true, speex ? null
46+, swiftSupport ? false, swift ? null
4647, theoraSupport ? true, libtheora ? null
4748, vaapiSupport ? stdenv.isLinux, libva ? null
4849, vdpauSupport ? true, libvdpau ? null
@@ -119,7 +120,6 @@ in stdenv.mkDerivation rec {
119120 "--disable-libmpv-static"
120121 "--disable-static-build"
121122 "--disable-build-date" # Purity
122− "--disable-macos-cocoa-cb" # Disable whilst Swift isn't supported
123123 (enableFeature archiveSupport "libarchive")
124124 (enableFeature cddaSupport "cdda")
125125 (enableFeature dvdnavSupport "dvdnav")
@@ -130,11 +130,13 @@ in stdenv.mkDerivation rec {
130130 (enableFeature vaapiSupport "vaapi")
131131 (enableFeature waylandSupport "wayland")
132132 (enableFeature stdenv.isLinux "dvbin")
133− ];
133+ ] # Disable whilst Swift isn't supported
134+ ++ stdenv.lib.optional (!swiftSupport) "--disable-macos-cocoa-cb";
134135
135136 nativeBuildInputs = [
136137 addOpenGLRunpath docutils makeWrapper perl pkgconfig python3 wafHook which
137− ];
138+ ]
139+ ++ optional swiftSupport swift;
138140
139141 buildInputs = [
140142 ffmpeg_4 freetype libass libpthreadstubs
@@ -172,7 +174,7 @@ in stdenv.mkDerivation rec {
172174 ++ optionals x11Support [ libX11 libXext libGLU libGL libXxf86vm libXrandr ]
173175 ++ optionals vulkanSupport [ libplacebo shaderc vulkan-headers vulkan-loader ]
174176 ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
175− CoreFoundation Cocoa CoreAudio
177+ CoreFoundation Cocoa CoreAudio MediaPlayer
176178 ]);
177179
178180 enableParallelBuilding = true;
pkgs/os-specific/darwin/apple-sdk/frameworks.nix+1
@@ -75,6 +75,7 @@ with frameworks; with libs; {
7575 LocalAuthentication = [];
7676 MapKit = [];
7777 MediaAccessibility = [ CoreGraphics CoreText QuartzCore ];
78+ MediaPlayer = [];
7879 MediaToolbox = [ AudioToolbox AudioUnit CoreMedia ];
7980 Metal = [];
8081 MetalKit = [ ModelIO Metal ];