From c6c0062b2c9c10a9df3657f0242c2ef7346b7183 Mon Sep 17 00:00:00 2001 From: nicoo Date: Sun, 31 Dec 2023 10:57:13 +0000 Subject: [PATCH] mpvScripts.buildLua: `extraScripts` support directories, preserve mode --- pkgs/applications/video/mpv/scripts/buildLua.nix | 9 ++++++--- pkgs/applications/video/mpv/scripts/cutter.nix | 1 - pkgs/applications/video/mpv/scripts/sponsorblock.nix | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/video/mpv/scripts/buildLua.nix b/pkgs/applications/video/mpv/scripts/buildLua.nix index e0afa7d932c6..84cf6ec52ef3 100644 --- a/pkgs/applications/video/mpv/scripts/buildLua.nix +++ b/pkgs/applications/video/mpv/scripts/buildLua.nix @@ -2,7 +2,10 @@ , stdenvNoCC }: let - escapedList = with lib; concatMapStringsSep " " (s: "'${escape [ "'" ] s}'"); + # Escape strings for embedding in shell scripts + escaped = s: "'${lib.escape [ "'" ] s}'"; + escapedList = lib.concatMapStringsSep " " escaped; + fileName = pathStr: lib.last (lib.splitString "/" pathStr); scriptsDir = "$out/share/mpv/scripts"; @@ -56,8 +59,8 @@ lib.makeOverridable (args: stdenvNoCC.mkDerivation (extendedBy mkdir -p "${scriptsDir}" cp -a "${scriptPath}" "${scriptsDir}/${scriptName}" else - install -m644 -Dt "${scriptsDir}" \ - ${escapedList ([ scriptPath ] ++ extraScripts)} + install -m644 -Dt "${scriptsDir}" ${escaped scriptPath} + ${lib.optionalString (extraScripts != []) ''cp -at "${scriptsDir}/" ${escapedList extraScripts}''} fi runHook postInstall diff --git a/pkgs/applications/video/mpv/scripts/cutter.nix b/pkgs/applications/video/mpv/scripts/cutter.nix index 69eba782cc1d..36bc69bebaf8 100644 --- a/pkgs/applications/video/mpv/scripts/cutter.nix +++ b/pkgs/applications/video/mpv/scripts/cutter.nix @@ -29,7 +29,6 @@ buildLua { extraScripts = [ "c_concat.sh" ]; postInstall = '' - chmod 0755 $out/share/mpv/scripts/c_concat.sh wrapProgram $out/share/mpv/scripts/c_concat.sh \ --run "mkdir -p ~/.config/mpv/cutter/" ''; diff --git a/pkgs/applications/video/mpv/scripts/sponsorblock.nix b/pkgs/applications/video/mpv/scripts/sponsorblock.nix index 077b8f0590b2..56ac2575ecde 100644 --- a/pkgs/applications/video/mpv/scripts/sponsorblock.nix +++ b/pkgs/applications/video/mpv/scripts/sponsorblock.nix @@ -32,7 +32,7 @@ buildLua { --replace 'mp.find_config_file("scripts")' "\"$out/share/mpv/scripts\"" ''; - postInstall = "cp -a sponsorblock_shared $out/share/mpv/scripts/"; + extraScripts = [ "sponsorblock_shared" ]; passthru.updateScript = nix-update-script { extraArgs = [ "--version=branch" ];