Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 322 lines 8.4 kB view raw
1{ 2 lib, 3 SDL2, 4 addDriverRunpath, 5 alsa-lib, 6 bash, 7 buildPackages, 8 callPackage, 9 config, 10 docutils, 11 fetchFromGitHub, 12 ffmpeg, 13 freefont_ttf, 14 freetype, 15 lcms2, 16 libGL, 17 libX11, 18 libXScrnSaver, 19 libXext, 20 libXpresent, 21 libXrandr, 22 libarchive, 23 libass, 24 libbluray, 25 libbs2b, 26 libcaca, 27 libcdio, 28 libcdio-paranoia, 29 libdrm, 30 libdisplay-info, 31 libdvdnav, 32 libjack2, 33 libplacebo, 34 libpthreadstubs, 35 libpulseaudio, 36 libsixel, 37 libuchardet, 38 libva, 39 libvdpau, 40 libxkbcommon, 41 lua, 42 makeWrapper, 43 libgbm, 44 meson, 45 mujs, 46 ninja, 47 nixosTests, 48 nv-codec-headers-11, 49 openalSoft, 50 pipewire, 51 pkg-config, 52 python3, 53 rubberband, 54 shaderc, # instead of spirv-cross 55 stdenv, 56 swift, 57 testers, 58 vapoursynth, 59 vulkan-headers, 60 vulkan-loader, 61 wayland, 62 wayland-protocols, 63 wayland-scanner, 64 zimg, 65 66 # Boolean 67 alsaSupport ? stdenv.hostPlatform.isLinux, 68 archiveSupport ? true, 69 bluraySupport ? true, 70 bs2bSupport ? true, 71 cacaSupport ? true, 72 cddaSupport ? false, 73 cmsSupport ? true, 74 drmSupport ? stdenv.hostPlatform.isLinux, 75 dvbinSupport ? stdenv.hostPlatform.isLinux, 76 dvdnavSupport ? true, 77 jackaudioSupport ? false, 78 javascriptSupport ? true, 79 openalSupport ? true, 80 pipewireSupport ? !stdenv.hostPlatform.isDarwin, 81 pulseSupport ? config.pulseaudio or (!stdenv.hostPlatform.isDarwin), 82 rubberbandSupport ? true, 83 sdl2Support ? false, 84 sixelSupport ? false, 85 vaapiSupport ? !stdenv.hostPlatform.isDarwin && (x11Support || waylandSupport), 86 vapoursynthSupport ? false, 87 vdpauSupport ? true, 88 vulkanSupport ? true, 89 waylandSupport ? !stdenv.hostPlatform.isDarwin, 90 x11Support ? !stdenv.hostPlatform.isDarwin, 91 zimgSupport ? true, 92}: 93 94let 95 luaEnv = lua.withPackages (ps: with ps; [ luasocket ]); 96in 97stdenv.mkDerivation (finalAttrs: { 98 pname = "mpv"; 99 version = "0.40.0"; 100 101 outputs = [ 102 "out" 103 "dev" 104 "doc" 105 "man" 106 ]; 107 108 src = fetchFromGitHub { 109 owner = "mpv-player"; 110 repo = "mpv"; 111 tag = "v${finalAttrs.version}"; 112 hash = "sha256-x8cDczKIX4+KrvRxZ+72TGlEQHd4Kx7naq0CSoOZGHA="; 113 }; 114 115 postPatch = lib.concatStringsSep "\n" [ 116 # Don't reference compile time dependencies or create a build outputs cycle 117 # between out and dev 118 '' 119 substituteInPlace meson.build \ 120 --replace-fail "conf_data.set_quoted('CONFIGURATION', meson.build_options())" \ 121 "conf_data.set_quoted('CONFIGURATION', '<omitted>')" 122 '' 123 # A trick to patchShebang everything except mpv_identify.sh 124 '' 125 pushd TOOLS 126 mv mpv_identify.sh mpv_identify 127 patchShebangs *.py *.sh 128 mv mpv_identify mpv_identify.sh 129 popd 130 '' 131 ]; 132 133 # Ensure we reference 'lib' (not 'out') of Swift. 134 # TODO: Remove this once the Swift wrapper doesn’t include these. 135 preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin '' 136 export SWIFT_LIB_DYNAMIC="${lib.getLib swift.swift}/lib/swift/macosx" 137 ''; 138 139 mesonFlags = [ 140 (lib.mesonOption "default_library" "shared") 141 (lib.mesonBool "libmpv" true) 142 (lib.mesonEnable "manpage-build" true) 143 (lib.mesonEnable "cdda" cddaSupport) 144 (lib.mesonEnable "dvbin" dvbinSupport) 145 (lib.mesonEnable "dvdnav" dvdnavSupport) 146 (lib.mesonEnable "openal" openalSupport) 147 (lib.mesonEnable "sdl2" sdl2Support) 148 ]; 149 150 mesonAutoFeatures = "auto"; 151 152 nativeBuildInputs = [ 153 addDriverRunpath 154 docutils # for rst2man 155 meson 156 ninja 157 pkg-config 158 ] 159 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 160 buildPackages.darwin.sigtool 161 swift 162 makeWrapper 163 ] 164 ++ lib.optionals waylandSupport [ wayland-scanner ]; 165 166 buildInputs = [ 167 bash 168 ffmpeg 169 freetype 170 libass 171 libplacebo 172 libpthreadstubs 173 libuchardet 174 luaEnv 175 python3 176 ] 177 ++ lib.optionals alsaSupport [ alsa-lib ] 178 ++ lib.optionals archiveSupport [ libarchive ] 179 ++ lib.optionals bluraySupport [ libbluray ] 180 ++ lib.optionals bs2bSupport [ libbs2b ] 181 ++ lib.optionals cacaSupport [ libcaca ] 182 ++ lib.optionals cddaSupport [ 183 libcdio 184 libcdio-paranoia 185 ] 186 ++ lib.optionals cmsSupport [ lcms2 ] 187 ++ lib.optionals drmSupport [ 188 libdrm 189 libdisplay-info 190 libgbm 191 ] 192 ++ lib.optionals dvdnavSupport [ 193 libdvdnav 194 libdvdnav.libdvdread 195 ] 196 ++ lib.optionals jackaudioSupport [ libjack2 ] 197 ++ lib.optionals javascriptSupport [ mujs ] 198 ++ lib.optionals openalSupport [ openalSoft ] 199 ++ lib.optionals pipewireSupport [ pipewire ] 200 ++ lib.optionals pulseSupport [ libpulseaudio ] 201 ++ lib.optionals rubberbandSupport [ rubberband ] 202 ++ lib.optionals sdl2Support [ SDL2 ] 203 ++ lib.optionals sixelSupport [ libsixel ] 204 ++ lib.optionals vaapiSupport [ libva ] 205 ++ lib.optionals vapoursynthSupport [ vapoursynth ] 206 ++ lib.optionals vdpauSupport [ libvdpau ] 207 ++ lib.optionals vulkanSupport [ 208 shaderc 209 vulkan-headers 210 vulkan-loader 211 ] 212 ++ lib.optionals waylandSupport [ 213 wayland 214 wayland-protocols 215 libxkbcommon 216 ] 217 ++ lib.optionals x11Support [ 218 libX11 219 libXext 220 libGL 221 libXrandr 222 libXpresent 223 libXScrnSaver 224 ] 225 ++ lib.optionals zimgSupport [ zimg ] 226 ++ lib.optionals stdenv.hostPlatform.isLinux [ nv-codec-headers-11 ]; 227 228 # https://github.com/mpv-player/mpv/issues/15591#issuecomment-2764797522 229 # In file included from ../player/clipboard/clipboard-mac.m:19: 230 # ./osdep/mac/swift.h:270:9: fatal error: '.../app_bridge_objc-1.pch' file not found 231 env = lib.optionalAttrs (stdenv.hostPlatform.isDarwin) { 232 NIX_SWIFTFLAGS_COMPILE = "-disable-bridging-pch"; 233 }; 234 235 postBuild = lib.optionalString stdenv.hostPlatform.isDarwin '' 236 pushd .. # Must be run from the source dir because it uses relative paths 237 python3 TOOLS/osxbundle.py -s build/mpv 238 popd 239 ''; 240 241 postInstall = '' 242 # Use a standard font 243 mkdir -p $out/share/mpv 244 ln -s ${freefont_ttf}/share/fonts/truetype/FreeSans.ttf $out/share/mpv/subfont.ttf 245 246 pushd ../TOOLS 247 cp mpv_identify.sh umpv $out/bin/ 248 popd 249 '' 250 + lib.optionalString stdenv.hostPlatform.isLinux '' 251 pushd $out/share/applications 252 253 sed -e '/Icon=/ ! s|mpv|umpv|g; s|^Exec=.*|Exec=umpv %U|' \ 254 mpv.desktop > umpv.desktop 255 printf "NoDisplay=true\n" >> umpv.desktop 256 popd 257 '' 258 + lib.optionalString stdenv.hostPlatform.isDarwin '' 259 mkdir -p $out/Applications 260 cp -r mpv.app $out/Applications 261 262 # On macOS, many things wont work properly unless `mpv(1)` is 263 # executed from the app bundle, such as spatial audio with 264 # `--ao=avfoundation`. This wrapper ensures that those features 265 # work reliably and also avoids shipping two copies of the entire 266 # `mpv` executable. 267 makeWrapper $out/Applications/mpv.app/Contents/MacOS/mpv $out/bin/mpv 268 ''; 269 270 # Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found. 271 # See the explanation in addDriverRunpath. 272 postFixup = lib.optionalString stdenv.hostPlatform.isLinux '' 273 addDriverRunpath $out/bin/mpv 274 patchShebangs --update --host $out/bin/umpv $out/bin/mpv_identify.sh 275 ''; 276 277 passthru = { 278 inherit 279 # The wrapper consults luaEnv and lua.version 280 luaEnv 281 lua 282 # In the wrapper, we want to reference vapoursynth which has the `python3` 283 # passthru attribute (which has the `sitePrefix` attribute). This way we'll 284 # be sure that in the wrapper we'll use the same python3.sitePrefix used to 285 # build vapoursynth. 286 vapoursynthSupport 287 vapoursynth 288 ; 289 290 wrapper = callPackage ./wrapper.nix { }; 291 scripts = callPackage ./scripts.nix { }; 292 293 tests = { 294 inherit (nixosTests) mpv; 295 296 version = testers.testVersion { package = finalAttrs.finalPackage; }; 297 pkg-config = testers.hasPkgConfigModules { 298 package = finalAttrs.finalPackage; 299 moduleNames = [ "mpv" ]; 300 }; 301 }; 302 }; 303 304 meta = { 305 homepage = "https://mpv.io"; 306 description = "General-purpose media player, fork of MPlayer and mplayer2"; 307 longDescription = '' 308 mpv is a free and open-source general-purpose video player, based on the 309 MPlayer and mplayer2 projects, with great improvements above both. 310 ''; 311 changelog = "https://github.com/mpv-player/mpv/releases/tag/v${finalAttrs.version}"; 312 license = lib.licenses.gpl2Plus; 313 mainProgram = "mpv"; 314 maintainers = with lib.maintainers; [ 315 fpletz 316 globin 317 ma27 318 SchweGELBin 319 ]; 320 platforms = lib.platforms.unix; 321 }; 322})