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
mpv: add flag for swift on darwin #79344
Conversation
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; }; }
Some more background on the cocoa-cb backend: mpv-player/mpv@c5e4538 |
Hmm, I was trying this out but I'm running into a weird issue. It seems like my shell is aborting nix. I haven't encountered this before and I'm not sure how to solve it.
|
@toonn That's an evaluation issue. I think something in your NIX_PATH or overlays is causing a a lot of memory usage, this error usually occurs when trying to evaluate all of nixpkgs. |
Referencing darwin.* directly makes overriding dependencies very awkward.
I can confirm that |
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.
Motivation for this change
The latest release still builds but isn't functional without swift.
Things done
Tested using sandboxing (nix.useSandbox on NixOS, or optionsandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)