From c5b0b6d29cdac3faa0d594ac9876916ec5e84d92 Mon Sep 17 00:00:00 2001 From: Winter Date: Mon, 30 Sep 2024 17:48:38 -0400 Subject: [PATCH 1/3] mpv: fix build on darwin --- .../video/mpv/0001-fix-darwin-build.patch | 19 +++++++++++++++++++ pkgs/applications/video/mpv/default.nix | 7 +++++++ 2 files changed, 26 insertions(+) create mode 100644 pkgs/applications/video/mpv/0001-fix-darwin-build.patch diff --git a/pkgs/applications/video/mpv/0001-fix-darwin-build.patch b/pkgs/applications/video/mpv/0001-fix-darwin-build.patch new file mode 100644 index 000000000000..2b6085ed3c9f --- /dev/null +++ b/pkgs/applications/video/mpv/0001-fix-darwin-build.patch @@ -0,0 +1,19 @@ +diff --git a/osdep/mac/input_helper.swift b/osdep/mac/input_helper.swift +index 0acec6bd40..0ec5837864 100644 +--- a/osdep/mac/input_helper.swift ++++ b/osdep/mac/input_helper.swift +@@ -18,6 +18,14 @@ + import Cocoa + import Carbon.HIToolbox + ++extension NSCondition { ++ fileprivate func withLock(_ body: () throws -> T) rethrows -> T { ++ self.lock() ++ defer { self.unlock() } ++ return try body() ++ } ++} ++ + class InputHelper: NSObject { + var option: OptionHelper? + var lock = NSCondition() diff --git a/pkgs/applications/video/mpv/default.nix b/pkgs/applications/video/mpv/default.nix index 20601537d373..d1f44b09b16d 100644 --- a/pkgs/applications/video/mpv/default.nix +++ b/pkgs/applications/video/mpv/default.nix @@ -151,6 +151,11 @@ stdenv'.mkDerivation (finalAttrs: { hash = "sha256-BOGh+QBTO7hrHohh+RqjSF8eHQH8jVBPjG/k4eyFaaM="; }; + patches = [ + # Fix build with Darwin SDK 11 + ./0001-fix-darwin-build.patch + ]; + postPatch = lib.concatStringsSep "\n" [ # Don't reference compile time dependencies or create a build outputs cycle # between out and dev @@ -308,6 +313,8 @@ stdenv'.mkDerivation (finalAttrs: { pushd ../TOOLS cp mpv_identify.sh umpv $out/bin/ popd + '' + + lib.optionalString stdenv.hostPlatform.isLinux '' pushd $out/share/applications sed -e '/Icon=/ ! s|mpv|umpv|g; s|^Exec=.*|Exec=umpv %U|' \ From ecf486145ff0dd2ae9c8915ffcb2d2a94a55185d Mon Sep 17 00:00:00 2001 From: Winter Date: Mon, 30 Sep 2024 21:55:51 -0400 Subject: [PATCH 2/3] gonic: fix tests in darwin sandbox --- pkgs/servers/gonic/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/servers/gonic/default.nix b/pkgs/servers/gonic/default.nix index d23e130375de..a0ec78a5b36a 100644 --- a/pkgs/servers/gonic/default.nix +++ b/pkgs/servers/gonic/default.nix @@ -50,6 +50,9 @@ buildGoModule rec { tests.gonic = nixosTests.gonic; }; + # tests require it + __darwinAllowLocalNetworking = true; + meta = { homepage = "https://github.com/sentriz/gonic"; description = "Music streaming server / subsonic server API implementation"; From 8d6134b231ec3507aba9c0e50101b15a77bbeacd Mon Sep 17 00:00:00 2001 From: Winter Date: Mon, 30 Sep 2024 22:04:09 -0400 Subject: [PATCH 3/3] gonic: don't use substituteStream --replace --- pkgs/servers/gonic/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/gonic/default.nix b/pkgs/servers/gonic/default.nix index a0ec78a5b36a..c09c58f0b269 100644 --- a/pkgs/servers/gonic/default.nix +++ b/pkgs/servers/gonic/default.nix @@ -30,18 +30,18 @@ buildGoModule rec { postPatch = lib.optionalString transcodingSupport '' substituteInPlace \ transcode/transcode.go \ - --replace \ + --replace-fail \ '`ffmpeg' \ '`${lib.getBin ffmpeg}/bin/ffmpeg' '' + '' substituteInPlace \ jukebox/jukebox.go \ - --replace \ + --replace-fail \ '"mpv"' \ '"${lib.getBin mpv}/bin/mpv"' '' + '' substituteInPlace server/ctrlsubsonic/testdata/test* \ - --replace \ + --replace-quiet \ '"audio/flac"' \ '"audio/x-flac"' '';