mpv{,-unwrapped,Scripts}: move to by-name
This commit is contained in:
@@ -373,8 +373,8 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt
|
|||||||
/pkgs/development/lua-modules @NixOS/lua
|
/pkgs/development/lua-modules @NixOS/lua
|
||||||
|
|
||||||
# mpvScripts
|
# mpvScripts
|
||||||
/pkgs/applications/video/mpv/scripts @uninsane
|
/pkgs/by-name/mp/mpv/scripts @uninsane
|
||||||
/pkgs/applications/video/mpv/scripts.nix @uninsane
|
/pkgs/by-name/mp/mpv/scripts.nix @uninsane
|
||||||
|
|
||||||
# Neovim
|
# Neovim
|
||||||
/pkgs/applications/editors/neovim @NixOS/neovim
|
/pkgs/applications/editors/neovim @NixOS/neovim
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
|
|
||||||
### Deprecations {#sec-nixpkgs-release-26.05-lib-deprecations}
|
### Deprecations {#sec-nixpkgs-release-26.05-lib-deprecations}
|
||||||
|
|
||||||
- Create the first release note entry in this section!
|
- `mpv-unwrapped.scripts` and `mpv-unwrapped.wrapper` have been removed. Please use `mpvScripts` and `mpv.override` accordingly.
|
||||||
|
|
||||||
|
|
||||||
### Additions and Improvements {#sec-nixpkgs-release-26.05-lib-additions-improvements}
|
### Additions and Improvements {#sec-nixpkgs-release-26.05-lib-additions-improvements}
|
||||||
|
|||||||
@@ -1,163 +0,0 @@
|
|||||||
# Arguments that this derivation gets when it is created with `callPackage`
|
|
||||||
{
|
|
||||||
stdenv,
|
|
||||||
buildEnv,
|
|
||||||
lib,
|
|
||||||
makeBinaryWrapper,
|
|
||||||
mpvScripts,
|
|
||||||
symlinkJoin,
|
|
||||||
writeTextDir,
|
|
||||||
yt-dlp,
|
|
||||||
# the unwrapped mpv derivation
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
# arguments to the function (exposed as `mpv-unwrapped.wrapper` in top-level)
|
|
||||||
wrapper =
|
|
||||||
{
|
|
||||||
mpv,
|
|
||||||
extraMakeWrapperArgs ? [ ],
|
|
||||||
youtubeSupport ? true,
|
|
||||||
# a set of derivations (probably from `mpvScripts`) where each is expected
|
|
||||||
# to have a `scriptName` passthru attribute that points to the name of the
|
|
||||||
# script that would reside in the script's derivation's
|
|
||||||
# `$out/share/mpv/scripts/`.
|
|
||||||
#
|
|
||||||
# A script can optionally also provide `passthru.extraWrapperArgs`
|
|
||||||
# attribute.
|
|
||||||
scripts ? [ ],
|
|
||||||
extraUmpvWrapperArgs ? [ ],
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
binPath = lib.makeBinPath (
|
|
||||||
[
|
|
||||||
mpv.luaEnv
|
|
||||||
]
|
|
||||||
++ lib.optionals mpv.vapoursynthSupport [
|
|
||||||
mpv.vapoursynth.python3
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
# With some tools, we want to prioritize tools that are in PATH. For example, users may want
|
|
||||||
# to quickly expose a newer version of yt-dlp through the nix shell because it needs to be
|
|
||||||
# kept up-to-date for it to work.
|
|
||||||
fallbackBinPath = lib.makeBinPath (lib.optionals youtubeSupport [ yt-dlp ]);
|
|
||||||
|
|
||||||
# All arguments besides the input and output binaries (${mpv}/bin/mpv and
|
|
||||||
# $out/bin/mpv). These are used by the darwin specific makeWrapper call
|
|
||||||
# used to wrap $out/Applications/mpv.app/Contents/MacOS/mpv as well.
|
|
||||||
mostMakeWrapperArgs = lib.strings.escapeShellArgs (
|
|
||||||
[
|
|
||||||
"--inherit-argv0"
|
|
||||||
# These are always needed (TODO: Explain why)
|
|
||||||
"--prefix"
|
|
||||||
"LUA_CPATH"
|
|
||||||
";"
|
|
||||||
"${mpv.luaEnv}/lib/lua/${mpv.lua.luaversion}/?.so"
|
|
||||||
"--prefix"
|
|
||||||
"LUA_PATH"
|
|
||||||
";"
|
|
||||||
"${mpv.luaEnv}/share/lua/${mpv.lua.luaversion}/?.lua"
|
|
||||||
]
|
|
||||||
++ lib.optionals mpv.vapoursynthSupport [
|
|
||||||
"--prefix"
|
|
||||||
"PYTHONPATH"
|
|
||||||
":"
|
|
||||||
"${mpv.vapoursynth}/${mpv.vapoursynth.python3.sitePackages}"
|
|
||||||
]
|
|
||||||
++ lib.optionals (binPath != "") [
|
|
||||||
"--prefix"
|
|
||||||
"PATH"
|
|
||||||
":"
|
|
||||||
binPath
|
|
||||||
]
|
|
||||||
++ lib.optionals (fallbackBinPath != "") [
|
|
||||||
"--suffix"
|
|
||||||
"PATH"
|
|
||||||
":"
|
|
||||||
fallbackBinPath
|
|
||||||
]
|
|
||||||
++ (lib.lists.flatten (
|
|
||||||
map
|
|
||||||
# For every script in the `scripts` argument, add the necessary flags to the wrapper
|
|
||||||
(
|
|
||||||
script:
|
|
||||||
let
|
|
||||||
mkScriptArgs = script: scriptName: [
|
|
||||||
"--add-flags"
|
|
||||||
"--script=${script}/share/mpv/scripts/${scriptName}"
|
|
||||||
];
|
|
||||||
in
|
|
||||||
# Here we rely on the existence of the `scriptName` passthru
|
|
||||||
# attribute of the script derivation from the `scripts`
|
|
||||||
(mkScriptArgs script script.scriptName)
|
|
||||||
# scripts might need others to be explicitly loaded
|
|
||||||
++ (map (extraScriptName: mkScriptArgs script extraScriptName) (script.extraScriptsToLoad or [ ]))
|
|
||||||
# scripts can also set the `extraWrapperArgs` passthru
|
|
||||||
++ (script.extraWrapperArgs or [ ])
|
|
||||||
)
|
|
||||||
scripts
|
|
||||||
))
|
|
||||||
++ extraMakeWrapperArgs
|
|
||||||
);
|
|
||||||
umpvWrapperArgs = lib.strings.escapeShellArgs (
|
|
||||||
[
|
|
||||||
"--inherit-argv0"
|
|
||||||
"--set"
|
|
||||||
"MPV"
|
|
||||||
"${placeholder "out"}/bin/mpv"
|
|
||||||
]
|
|
||||||
++ extraUmpvWrapperArgs
|
|
||||||
);
|
|
||||||
in
|
|
||||||
symlinkJoin {
|
|
||||||
name = "mpv-with-scripts-${mpv.version}";
|
|
||||||
|
|
||||||
# TODO: don't link all mpv outputs and convert package to mpv-unwrapped?
|
|
||||||
paths = [ mpv.all ];
|
|
||||||
|
|
||||||
nativeBuildInputs = [ makeBinaryWrapper ];
|
|
||||||
|
|
||||||
passthru.unwrapped = mpv;
|
|
||||||
|
|
||||||
passthru.tests.mpv-scripts-should-not-collide = buildEnv {
|
|
||||||
name = "mpv-scripts-env";
|
|
||||||
paths = lib.pipe mpvScripts [
|
|
||||||
# filters "override" "overrideDerivation" "recurseForDerivations"
|
|
||||||
(lib.filterAttrs (key: script: lib.isDerivation script))
|
|
||||||
# replaces unfree and meta.broken scripts with decent placeholders
|
|
||||||
(lib.mapAttrsToList (
|
|
||||||
key: script:
|
|
||||||
if (builtins.tryEval script.outPath).success then
|
|
||||||
script
|
|
||||||
else
|
|
||||||
writeTextDir "share/mpv/scripts/${script.scriptName}" "placeholder of ${script.name}"
|
|
||||||
))
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
postBuild = ''
|
|
||||||
# wrapProgram can't operate on symlinks
|
|
||||||
rm "$out/bin/mpv"
|
|
||||||
makeWrapper "${mpv}/bin/mpv" "$out/bin/mpv" ${mostMakeWrapperArgs}
|
|
||||||
rm "$out/bin/umpv"
|
|
||||||
makeWrapper "${mpv}/bin/umpv" "$out/bin/umpv" ${umpvWrapperArgs}
|
|
||||||
''
|
|
||||||
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
||||||
# wrapProgram can't operate on symlinks
|
|
||||||
rm "$out/Applications/mpv.app/Contents/MacOS/mpv"
|
|
||||||
makeWrapper "${mpv}/Applications/mpv.app/Contents/MacOS/mpv" "$out/Applications/mpv.app/Contents/MacOS/mpv" ${mostMakeWrapperArgs}
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
inherit (mpv.meta)
|
|
||||||
homepage
|
|
||||||
description
|
|
||||||
longDescription
|
|
||||||
maintainers
|
|
||||||
;
|
|
||||||
mainProgram = "mpv";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
lib.makeOverridable wrapper
|
|
||||||
@@ -5,11 +5,9 @@
|
|||||||
alsa-lib,
|
alsa-lib,
|
||||||
bash,
|
bash,
|
||||||
buildPackages,
|
buildPackages,
|
||||||
callPackage,
|
|
||||||
config,
|
config,
|
||||||
docutils,
|
docutils,
|
||||||
fetchFromGitHub,
|
fetchFromGitHub,
|
||||||
fetchpatch,
|
|
||||||
ffmpeg,
|
ffmpeg,
|
||||||
freefont_ttf,
|
freefont_ttf,
|
||||||
freetype,
|
freetype,
|
||||||
@@ -301,8 +299,9 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
vapoursynth
|
vapoursynth
|
||||||
;
|
;
|
||||||
|
|
||||||
wrapper = callPackage ./wrapper.nix { };
|
# Should be removed in the future. These can't be added to `pkgs/top-level/aliases.nix`.
|
||||||
scripts = callPackage ./scripts.nix { };
|
scripts = throw "'mpv-unwrapped.scripts' has been removed. Please use 'mpvScripts' instead."; # Added 2025-12-29
|
||||||
|
wrapper = throw "'mpv-unwrapped.wrapper' has been removed. Please use 'mpv.override' instead."; # Added 2025-12-29
|
||||||
|
|
||||||
tests = {
|
tests = {
|
||||||
inherit (nixosTests) mpv;
|
inherit (nixosTests) mpv;
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
{
|
||||||
|
stdenv,
|
||||||
|
buildEnv,
|
||||||
|
lib,
|
||||||
|
makeBinaryWrapper,
|
||||||
|
mpvScripts,
|
||||||
|
mpv-unwrapped,
|
||||||
|
symlinkJoin,
|
||||||
|
writeTextDir,
|
||||||
|
yt-dlp,
|
||||||
|
extraMakeWrapperArgs ? [ ],
|
||||||
|
youtubeSupport ? true,
|
||||||
|
# a set of derivations (probably from `mpvScripts`) where each is expected
|
||||||
|
# to have a `scriptName` passthru attribute that points to the name of the
|
||||||
|
# script that would reside in the script's derivation's
|
||||||
|
# `$out/share/mpv/scripts/`.
|
||||||
|
#
|
||||||
|
# A script can optionally also provide `passthru.extraWrapperArgs`
|
||||||
|
# attribute.
|
||||||
|
scripts ? [ ],
|
||||||
|
extraUmpvWrapperArgs ? [ ],
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
binPath = lib.makeBinPath (
|
||||||
|
[
|
||||||
|
mpv-unwrapped.luaEnv
|
||||||
|
]
|
||||||
|
++ lib.optionals mpv-unwrapped.vapoursynthSupport [
|
||||||
|
mpv-unwrapped.vapoursynth.python3
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
# With some tools, we want to prioritize tools that are in PATH. For example, users may want
|
||||||
|
# to quickly expose a newer version of yt-dlp through the nix shell because it needs to be
|
||||||
|
# kept up-to-date for it to work.
|
||||||
|
fallbackBinPath = lib.makeBinPath (lib.optionals youtubeSupport [ yt-dlp ]);
|
||||||
|
|
||||||
|
# All arguments besides the input and output binaries (${mpv-unwrapped}/bin/mpv and
|
||||||
|
# $out/bin/mpv). These are used by the darwin specific makeWrapper call
|
||||||
|
# used to wrap $out/Applications/mpv.app/Contents/MacOS/mpv as well.
|
||||||
|
mostMakeWrapperArgs = lib.strings.escapeShellArgs (
|
||||||
|
[
|
||||||
|
"--inherit-argv0"
|
||||||
|
# These are always needed (TODO: Explain why)
|
||||||
|
"--prefix"
|
||||||
|
"LUA_CPATH"
|
||||||
|
";"
|
||||||
|
"${mpv-unwrapped.luaEnv}/lib/lua/${mpv-unwrapped.lua.luaversion}/?.so"
|
||||||
|
"--prefix"
|
||||||
|
"LUA_PATH"
|
||||||
|
";"
|
||||||
|
"${mpv-unwrapped.luaEnv}/share/lua/${mpv-unwrapped.lua.luaversion}/?.lua"
|
||||||
|
]
|
||||||
|
++ lib.optionals mpv-unwrapped.vapoursynthSupport [
|
||||||
|
"--prefix"
|
||||||
|
"PYTHONPATH"
|
||||||
|
":"
|
||||||
|
"${mpv-unwrapped.vapoursynth}/${mpv-unwrapped.vapoursynth.python3.sitePackages}"
|
||||||
|
]
|
||||||
|
++ lib.optionals (binPath != "") [
|
||||||
|
"--prefix"
|
||||||
|
"PATH"
|
||||||
|
":"
|
||||||
|
binPath
|
||||||
|
]
|
||||||
|
++ lib.optionals (fallbackBinPath != "") [
|
||||||
|
"--suffix"
|
||||||
|
"PATH"
|
||||||
|
":"
|
||||||
|
fallbackBinPath
|
||||||
|
]
|
||||||
|
++ (lib.lists.flatten (
|
||||||
|
map
|
||||||
|
# For every script in the `scripts` argument, add the necessary flags to the wrapper
|
||||||
|
(
|
||||||
|
script:
|
||||||
|
let
|
||||||
|
mkScriptArgs = script: scriptName: [
|
||||||
|
"--add-flags"
|
||||||
|
"--script=${script}/share/mpv/scripts/${scriptName}"
|
||||||
|
];
|
||||||
|
in
|
||||||
|
# Here we rely on the existence of the `scriptName` passthru
|
||||||
|
# attribute of the script derivation from the `scripts`
|
||||||
|
(mkScriptArgs script script.scriptName)
|
||||||
|
# scripts might need others to be explicitly loaded
|
||||||
|
++ (map (extraScriptName: mkScriptArgs script extraScriptName) (script.extraScriptsToLoad or [ ]))
|
||||||
|
# scripts can also set the `extraWrapperArgs` passthru
|
||||||
|
++ (script.extraWrapperArgs or [ ])
|
||||||
|
)
|
||||||
|
scripts
|
||||||
|
))
|
||||||
|
++ extraMakeWrapperArgs
|
||||||
|
);
|
||||||
|
umpvWrapperArgs = lib.strings.escapeShellArgs (
|
||||||
|
[
|
||||||
|
"--inherit-argv0"
|
||||||
|
"--set"
|
||||||
|
"MPV"
|
||||||
|
"${placeholder "out"}/bin/mpv"
|
||||||
|
]
|
||||||
|
++ extraUmpvWrapperArgs
|
||||||
|
);
|
||||||
|
in
|
||||||
|
symlinkJoin {
|
||||||
|
name = "mpv-with-scripts-${mpv-unwrapped.version}";
|
||||||
|
|
||||||
|
# TODO: don't link all mpv outputs
|
||||||
|
paths = [ mpv-unwrapped.all ];
|
||||||
|
|
||||||
|
nativeBuildInputs = [ makeBinaryWrapper ];
|
||||||
|
|
||||||
|
passthru.unwrapped = mpv-unwrapped;
|
||||||
|
|
||||||
|
passthru.tests.mpv-scripts-should-not-collide = buildEnv {
|
||||||
|
name = "mpv-scripts-env";
|
||||||
|
paths = lib.pipe mpvScripts [
|
||||||
|
# filters "override" "overrideDerivation" "recurseForDerivations"
|
||||||
|
(lib.filterAttrs (key: script: lib.isDerivation script))
|
||||||
|
# replaces unfree and meta.broken scripts with decent placeholders
|
||||||
|
(lib.mapAttrsToList (
|
||||||
|
key: script:
|
||||||
|
if (builtins.tryEval script.outPath).success then
|
||||||
|
script
|
||||||
|
else
|
||||||
|
writeTextDir "share/mpv/scripts/${script.scriptName}" "placeholder of ${script.name}"
|
||||||
|
))
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
postBuild = ''
|
||||||
|
# wrapProgram can't operate on symlinks
|
||||||
|
rm "$out/bin/mpv"
|
||||||
|
makeWrapper "${mpv-unwrapped}/bin/mpv" "$out/bin/mpv" ${mostMakeWrapperArgs}
|
||||||
|
rm "$out/bin/umpv"
|
||||||
|
makeWrapper "${mpv-unwrapped}/bin/umpv" "$out/bin/umpv" ${umpvWrapperArgs}
|
||||||
|
''
|
||||||
|
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||||
|
# wrapProgram can't operate on symlinks
|
||||||
|
rm "$out/Applications/mpv.app/Contents/MacOS/mpv"
|
||||||
|
makeWrapper "${mpv-unwrapped}/Applications/mpv.app/Contents/MacOS/mpv" "$out/Applications/mpv.app/Contents/MacOS/mpv" ${mostMakeWrapperArgs}
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
inherit (mpv-unwrapped.meta)
|
||||||
|
homepage
|
||||||
|
description
|
||||||
|
longDescription
|
||||||
|
maintainers
|
||||||
|
;
|
||||||
|
mainProgram = "mpv";
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -11426,14 +11426,7 @@ with pkgs;
|
|||||||
// (config.mplayer or { })
|
// (config.mplayer or { })
|
||||||
);
|
);
|
||||||
|
|
||||||
mpv-unwrapped = callPackage ../applications/video/mpv {
|
mpvScripts = callPackage ../by-name/mp/mpv/scripts.nix { };
|
||||||
stdenv = if stdenv.hostPlatform.isDarwin then swiftPackages.stdenv else stdenv;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Wrap avoiding rebuild
|
|
||||||
mpv = mpv-unwrapped.wrapper { mpv = mpv-unwrapped; };
|
|
||||||
|
|
||||||
mpvScripts = mpv-unwrapped.scripts;
|
|
||||||
|
|
||||||
mu-repo = python3Packages.callPackage ../applications/misc/mu-repo { };
|
mu-repo = python3Packages.callPackage ../applications/misc/mu-repo { };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user