Unverified Commit 63a83204 authored by nicoo's avatar nicoo Committed by GitHub
Browse files

Merge #308068: mpvScripts: comply with RFC166 formatting

parents 492b7b25 a6f88138
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ jobs:
        # Each environment variable beginning with NIX_FMT_PATHS_ is a list of
        # paths to check with nixfmt.
        env:
          NIX_FMT_PATHS_MPVSCRIPTS: pkgs/applications/video/mpv/scripts
          # Format paths related to the Nixpkgs CUDA ecosystem.
          NIX_FMT_PATHS_CUDA: |
            pkgs/development/cuda-modules
+81 −66
Original line number Diff line number Diff line
{ lib
, stdenvNoCC }:
{ lib, stdenvNoCC }:

let
  # Escape strings for embedding in shell scripts
@@ -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 = ''
@@ -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}"; }
          );
  })
))
      }
    )
  )
)
+13 −11
Original line number Diff line number Diff line
{ lib
, fetchFromGitHub
, unstableGitUpdater
, buildLua }:
{
  lib,
  fetchFromGitHub,
  unstableGitUpdater,
  buildLua,
}:

buildLua {
  pname = "chapterskip";
+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 {
+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