Merge pull request #272088 from nbraud/mpvScripts/validate

mpvScripts: Add generic tests to all drvs
This commit is contained in:
Peder Bergebakken Sundt 2023-12-24 15:59:39 +01:00 committed by GitHub
commit d914dcf6d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 5 deletions

View file

@ -1,11 +1,63 @@
{ lib
, callPackage
, config
, runCommand
}:
let buildLua = callPackage ./buildLua.nix { };
in lib.recurseIntoAttrs
({
let
buildLua = callPackage ./buildLua.nix { };
unionOfDisjoints = lib.fold lib.attrsets.unionOfDisjoint {};
addTests = name: drv: let
inherit (drv) scriptName;
scriptPath = "share/mpv/scripts/${scriptName}";
fullScriptPath = "${drv}/${scriptPath}";
in drv.overrideAttrs (old: { passthru = (old.passthru or {}) // { tests = unionOfDisjoints [
(old.passthru.tests or {})
{
scriptName-is-valid = runCommand "mpvScripts.${name}.passthru.tests.scriptName-is-valid" {
meta.maintainers = with lib.maintainers; [ nicoo ];
preferLocalBuild = true;
} ''
if [ -e "${fullScriptPath}" ]; then
touch $out
else
echo "mpvScripts.\"${name}\" does not contain a script named \"${scriptName}\"" >&2
exit 1
fi
'';
}
# can't check whether `fullScriptPath` is a directory, in pure-evaluation mode
(with lib; optionalAttrs (! any (s: hasSuffix s drv.passthru.scriptName) [ ".js" ".lua" ".so" ]) {
single-main-in-script-dir = runCommand "mpvScripts.${name}.passthru.tests.single-main-in-script-dir" {
meta.maintainers = with lib.maintainers; [ nicoo ];
preferLocalBuild = true;
} ''
die() {
echo "$@" >&2
exit 1
}
cd "${drv}/${scriptPath}" # so the glob expands to filenames only
mains=( main.* )
if [ "''${#mains[*]}" -eq 1 ]; then
touch $out
elif [ "''${#mains[*]}" -eq 0 ]; then
die "'${scriptPath}' contains no 'main.*' file"
else
die "'${scriptPath}' contains multiple 'main.*' files:" "''${mains[*]}"
fi
'';
})
]; }; });
in
lib.recurseIntoAttrs
(lib.mapAttrs addTests ({
acompressor = callPackage ./acompressor.nix { inherit buildLua; };
autocrop = callPackage ./autocrop.nix { };
autodeint = callPackage ./autodeint.nix { };
@ -29,7 +81,7 @@ in lib.recurseIntoAttrs
vr-reversal = callPackage ./vr-reversal.nix { };
webtorrent-mpv-hook = callPackage ./webtorrent-mpv-hook.nix { };
}
// (callPackage ./occivink.nix { inherit buildLua; }))
// (callPackage ./occivink.nix { inherit buildLua; })))
// lib.optionalAttrs config.allowAliases {
youtube-quality = throw "'youtube-quality' is no longer maintained, use 'quality-menu' instead"; # added 2023-07-14
}

View file

@ -32,6 +32,8 @@ buildLua rec {
runHook postInstall
'';
passthru.scriptName = "mpvacious";
meta = with lib; {
description = "Adds mpv keybindings to create Anki cards from movies and TV shows";
homepage = "https://github.com/Ajatt-Tools/mpvacious";

View file

@ -13,7 +13,7 @@ buildLua rec {
};
scriptPath = ".";
passthru.scriptName = "webui.lua";
passthru.scriptName = "webui";
meta = with lib; {
description = "A web based user interface with controls for the mpv mediaplayer";