Loading pkgs/applications/video/mpv/scripts/buildLua.nix +81 −66 Original line number Diff line number Diff line { lib , stdenvNoCC }: { lib, stdenvNoCC }: let # Escape strings for embedding in shell scripts Loading @@ -10,37 +9,45 @@ let scriptsDir = "$out/share/mpv/scripts"; # similar to `lib.extends`, but with inverted precedence and recursive update extendedBy = args: orig: self: let super = args self; in lib.recursiveUpdate (orig super) super ; extendedBy = args: orig: self: let super = args self; in lib.recursiveUpdate (orig super) super; in lib.makeOverridable (args: stdenvNoCC.mkDerivation (extendedBy (if lib.isFunction args then args else (_: args)) ( { pname , extraScripts ? [] , ... }@args: lib.makeOverridable ( args: stdenvNoCC.mkDerivation ( extendedBy (if lib.isFunction args then args else (_: args)) ( { pname, extraScripts ? [ ], ... }@args: let strippedName = with builtins; let strippedName = with builtins; let groups = match "mpv[-_](.*)" pname; in if groups != null then head groups else pname ; groups = match "mpv[-_](.*)" pname; in if groups != null then head groups else pname; # either passthru.scriptName, inferred from scriptPath, or from pname scriptName = (args.passthru or {}).scriptName or ( if args ? scriptPath then fileName args.scriptPath else "${strippedName}.lua" ); scriptName = (args.passthru or { }).scriptName or (if args ? scriptPath then fileName args.scriptPath else "${strippedName}.lua"); scriptPath = args.scriptPath or "./${scriptName}"; in { in { dontBuild = true; preferLocalBuild = true; # Prevent `patch` from emitting `.orig` files (that end up in the output) patchFlags = [ "--no-backup-if-mismatch" "-p1" ]; patchFlags = [ "--no-backup-if-mismatch" "-p1" ]; outputHashMode = "recursive"; installPhase = '' Loading @@ -60,24 +67,32 @@ lib.makeOverridable (args: stdenvNoCC.mkDerivation (extendedBy cp -a "${scriptPath}" "${scriptsDir}/${scriptName}" else install -m644 -Dt "${scriptsDir}" ${escaped scriptPath} ${lib.optionalString (extraScripts != []) ''cp -at "${scriptsDir}/" ${escapedList extraScripts}''} ${ lib.optionalString (extraScripts != [ ]) ''cp -at "${scriptsDir}/" ${escapedList extraScripts}'' } fi runHook postInstall ''; passthru = { inherit scriptName; }; meta = { passthru = { inherit scriptName; }; meta = { platforms = lib.platforms.all; } // ( let pos = } // ( let pos = if (args.meta or { }) ? description then builtins.unsafeGetAttrPos "description" args.meta else builtins.unsafeGetAttrPos "pname" args; in lib.optionalAttrs (pos != null) { position = "${pos.file}:${toString pos.line}"; } in lib.optionalAttrs (pos != null) { position = "${pos.file}:${toString pos.line}"; } ); }) )) } ) ) ) pkgs/applications/video/mpv/scripts/chapterskip.nix +13 −11 Original line number Diff line number Diff line { lib , fetchFromGitHub , unstableGitUpdater , buildLua }: { lib, fetchFromGitHub, unstableGitUpdater, buildLua, }: buildLua { pname = "chapterskip"; Loading pkgs/applications/video/mpv/scripts/convert.nix +9 −8 Original line number Diff line number Diff line { lib , fetchgit , unstableGitUpdater { lib, fetchgit, unstableGitUpdater, , buildLua , libnotify , mkvtoolnix-cli , yad buildLua, libnotify, mkvtoolnix-cli, yad, }: buildLua { Loading pkgs/applications/video/mpv/scripts/cutter.nix +8 −2 Original line number Diff line number Diff line { lib, buildLua, fetchFromGitHub, makeWrapper, unstableGitUpdater }: { lib, buildLua, fetchFromGitHub, makeWrapper, unstableGitUpdater, }: buildLua { pname = "video-cutter"; Loading pkgs/applications/video/mpv/scripts/default.nix +126 −92 Original line number Diff line number Diff line { lib , config , newScope , runCommand { lib, config, newScope, runCommand, }: let unionOfDisjoints = lib.fold lib.attrsets.unionOfDisjoint { }; addTests = name: drv: addTests = name: drv: if !lib.isDerivation drv then drv else let else let inherit (drv) scriptName; scriptPath = "share/mpv/scripts/${scriptName}"; fullScriptPath = "${drv}/${scriptPath}"; in drv.overrideAttrs (old: { passthru = (old.passthru or {}) // { tests = unionOfDisjoints [ 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" { 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 Loading @@ -32,11 +41,24 @@ let } # 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" { ( 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 Loading @@ -52,16 +74,25 @@ let die "'${scriptPath}' contains multiple 'main.*' files:" "''${mains[*]}" fi ''; }) ]; }; }); } ) ]; }; }); scope = self: let scope = self: let inherit (self) callPackage; in lib.mapAttrs addTests { in lib.mapAttrs addTests { inherit (callPackage ./mpv.nix { }) acompressor autocrop autodeint autoload; inherit (callPackage ./occivink.nix { }) blacklistExtensions seekTo; acompressor autocrop autodeint autoload ; inherit (callPackage ./occivink.nix { }) blacklistExtensions seekTo; buildLua = callPackage ./buildLua.nix { }; chapterskip = callPackage ./chapterskip.nix { }; Loading Loading @@ -102,10 +133,13 @@ let }; in with lib; pipe scope [ with lib; pipe scope [ (makeScope newScope) (self: ( self: assert builtins.intersectAttrs self aliases == { }; self // optionalAttrs config.allowAliases aliases) self // optionalAttrs config.allowAliases aliases ) recurseIntoAttrs ] Loading
pkgs/applications/video/mpv/scripts/buildLua.nix +81 −66 Original line number Diff line number Diff line { lib , stdenvNoCC }: { lib, stdenvNoCC }: let # Escape strings for embedding in shell scripts Loading @@ -10,37 +9,45 @@ let scriptsDir = "$out/share/mpv/scripts"; # similar to `lib.extends`, but with inverted precedence and recursive update extendedBy = args: orig: self: let super = args self; in lib.recursiveUpdate (orig super) super ; extendedBy = args: orig: self: let super = args self; in lib.recursiveUpdate (orig super) super; in lib.makeOverridable (args: stdenvNoCC.mkDerivation (extendedBy (if lib.isFunction args then args else (_: args)) ( { pname , extraScripts ? [] , ... }@args: lib.makeOverridable ( args: stdenvNoCC.mkDerivation ( extendedBy (if lib.isFunction args then args else (_: args)) ( { pname, extraScripts ? [ ], ... }@args: let strippedName = with builtins; let strippedName = with builtins; let groups = match "mpv[-_](.*)" pname; in if groups != null then head groups else pname ; groups = match "mpv[-_](.*)" pname; in if groups != null then head groups else pname; # either passthru.scriptName, inferred from scriptPath, or from pname scriptName = (args.passthru or {}).scriptName or ( if args ? scriptPath then fileName args.scriptPath else "${strippedName}.lua" ); scriptName = (args.passthru or { }).scriptName or (if args ? scriptPath then fileName args.scriptPath else "${strippedName}.lua"); scriptPath = args.scriptPath or "./${scriptName}"; in { in { dontBuild = true; preferLocalBuild = true; # Prevent `patch` from emitting `.orig` files (that end up in the output) patchFlags = [ "--no-backup-if-mismatch" "-p1" ]; patchFlags = [ "--no-backup-if-mismatch" "-p1" ]; outputHashMode = "recursive"; installPhase = '' Loading @@ -60,24 +67,32 @@ lib.makeOverridable (args: stdenvNoCC.mkDerivation (extendedBy cp -a "${scriptPath}" "${scriptsDir}/${scriptName}" else install -m644 -Dt "${scriptsDir}" ${escaped scriptPath} ${lib.optionalString (extraScripts != []) ''cp -at "${scriptsDir}/" ${escapedList extraScripts}''} ${ lib.optionalString (extraScripts != [ ]) ''cp -at "${scriptsDir}/" ${escapedList extraScripts}'' } fi runHook postInstall ''; passthru = { inherit scriptName; }; meta = { passthru = { inherit scriptName; }; meta = { platforms = lib.platforms.all; } // ( let pos = } // ( let pos = if (args.meta or { }) ? description then builtins.unsafeGetAttrPos "description" args.meta else builtins.unsafeGetAttrPos "pname" args; in lib.optionalAttrs (pos != null) { position = "${pos.file}:${toString pos.line}"; } in lib.optionalAttrs (pos != null) { position = "${pos.file}:${toString pos.line}"; } ); }) )) } ) ) )
pkgs/applications/video/mpv/scripts/chapterskip.nix +13 −11 Original line number Diff line number Diff line { lib , fetchFromGitHub , unstableGitUpdater , buildLua }: { lib, fetchFromGitHub, unstableGitUpdater, buildLua, }: buildLua { pname = "chapterskip"; Loading
pkgs/applications/video/mpv/scripts/convert.nix +9 −8 Original line number Diff line number Diff line { lib , fetchgit , unstableGitUpdater { lib, fetchgit, unstableGitUpdater, , buildLua , libnotify , mkvtoolnix-cli , yad buildLua, libnotify, mkvtoolnix-cli, yad, }: buildLua { Loading
pkgs/applications/video/mpv/scripts/cutter.nix +8 −2 Original line number Diff line number Diff line { lib, buildLua, fetchFromGitHub, makeWrapper, unstableGitUpdater }: { lib, buildLua, fetchFromGitHub, makeWrapper, unstableGitUpdater, }: buildLua { pname = "video-cutter"; Loading
pkgs/applications/video/mpv/scripts/default.nix +126 −92 Original line number Diff line number Diff line { lib , config , newScope , runCommand { lib, config, newScope, runCommand, }: let unionOfDisjoints = lib.fold lib.attrsets.unionOfDisjoint { }; addTests = name: drv: addTests = name: drv: if !lib.isDerivation drv then drv else let else let inherit (drv) scriptName; scriptPath = "share/mpv/scripts/${scriptName}"; fullScriptPath = "${drv}/${scriptPath}"; in drv.overrideAttrs (old: { passthru = (old.passthru or {}) // { tests = unionOfDisjoints [ 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" { 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 Loading @@ -32,11 +41,24 @@ let } # 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" { ( 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 Loading @@ -52,16 +74,25 @@ let die "'${scriptPath}' contains multiple 'main.*' files:" "''${mains[*]}" fi ''; }) ]; }; }); } ) ]; }; }); scope = self: let scope = self: let inherit (self) callPackage; in lib.mapAttrs addTests { in lib.mapAttrs addTests { inherit (callPackage ./mpv.nix { }) acompressor autocrop autodeint autoload; inherit (callPackage ./occivink.nix { }) blacklistExtensions seekTo; acompressor autocrop autodeint autoload ; inherit (callPackage ./occivink.nix { }) blacklistExtensions seekTo; buildLua = callPackage ./buildLua.nix { }; chapterskip = callPackage ./chapterskip.nix { }; Loading Loading @@ -102,10 +133,13 @@ let }; in with lib; pipe scope [ with lib; pipe scope [ (makeScope newScope) (self: ( self: assert builtins.intersectAttrs self aliases == { }; self // optionalAttrs config.allowAliases aliases) self // optionalAttrs config.allowAliases aliases ) recurseIntoAttrs ]