From b317fc17f00ea74fe2267950b3119dddddd78b09 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 16 Nov 2024 21:13:24 +0100 Subject: refactor(pkgs/mpc): Rename to `mpp` Nixpkgs has renamed their `mpc-cli` package to just `mpc`, turning this `mpc` package into an override for the official nixpkgs one. I think being explicit about the fact, that `mpc` is wrapped is the best solution here. --- pkgs/by-name/mp/mpc-beetrm/package.nix | 4 +- pkgs/by-name/mp/mpc-lyrics/package.nix | 4 +- pkgs/by-name/mp/mpc-searchadd/package.nix | 4 +- pkgs/by-name/mp/mpc/mpc.sh | 24 ------------ pkgs/by-name/mp/mpc/package.nix | 15 -------- pkgs/by-name/mp/mpp/mpp.sh | 24 ++++++++++++ pkgs/by-name/mp/mpp/package.nix | 63 +++++++++++++++++++++++++++++++ 7 files changed, 93 insertions(+), 45 deletions(-) delete mode 100755 pkgs/by-name/mp/mpc/mpc.sh delete mode 100644 pkgs/by-name/mp/mpc/package.nix create mode 100755 pkgs/by-name/mp/mpp/mpp.sh create mode 100644 pkgs/by-name/mp/mpp/package.nix (limited to 'pkgs') diff --git a/pkgs/by-name/mp/mpc-beetrm/package.nix b/pkgs/by-name/mp/mpc-beetrm/package.nix index 837c93e2..99ca8bbd 100644 --- a/pkgs/by-name/mp/mpc-beetrm/package.nix +++ b/pkgs/by-name/mp/mpc-beetrm/package.nix @@ -1,6 +1,6 @@ { sysLib, - mpc-cli, + mpc, beets, }: sysLib.writeShellScript { @@ -10,7 +10,7 @@ sysLib.writeShellScript { keepPath = false; dependencies = [ - mpc-cli + mpc beets ]; } diff --git a/pkgs/by-name/mp/mpc-lyrics/package.nix b/pkgs/by-name/mp/mpc-lyrics/package.nix index fdb8c53a..08cc8e48 100644 --- a/pkgs/by-name/mp/mpc-lyrics/package.nix +++ b/pkgs/by-name/mp/mpc-lyrics/package.nix @@ -1,7 +1,7 @@ { sysLib, exiftool, - mpc-cli, + mpc, jq, less, locale, # dependency of less @@ -19,7 +19,7 @@ sysLib.writeShellScript { dependencies = [ exiftool - mpc-cli + mpc jq less locale # dependency of less diff --git a/pkgs/by-name/mp/mpc-searchadd/package.nix b/pkgs/by-name/mp/mpc-searchadd/package.nix index 54ceca91..fd9f94e6 100644 --- a/pkgs/by-name/mp/mpc-searchadd/package.nix +++ b/pkgs/by-name/mp/mpc-searchadd/package.nix @@ -1,6 +1,6 @@ { sysLib, - mpc-cli, + mpc, beets, }: sysLib.writeShellScript { @@ -10,7 +10,7 @@ sysLib.writeShellScript { keepPath = false; dependencies = [ - mpc-cli + mpc beets ]; } diff --git a/pkgs/by-name/mp/mpc/mpc.sh b/pkgs/by-name/mp/mpc/mpc.sh deleted file mode 100755 index 0d636ac5..00000000 --- a/pkgs/by-name/mp/mpc/mpc.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -case "$1" in -"searchadd") - shift 1 - mpc-searchadd "$@" - ;; -"lyrics") - shift 1 - mpc-lyrics "$@" - ;; -"beetrm") - shift 1 - mpc-beetrm "$@" - ;; -*) - mpc "$@" - ;; -esac - -# vim: ft=sh diff --git a/pkgs/by-name/mp/mpc/package.nix b/pkgs/by-name/mp/mpc/package.nix deleted file mode 100644 index d73c0523..00000000 --- a/pkgs/by-name/mp/mpc/package.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ - sysLib, - mpc-cli, -}: -sysLib.writeShellScript { - name = "mpc"; - src = ./mpc.sh; - generateCompletions = false; - # We source the wrappers from the environment, to ensure that they have the same - # configurations (e.g. MPD_MUSIC_DIR in `mpc-lyrics`) - keepPath = true; - dependencies = [ - mpc-cli - ]; -} diff --git a/pkgs/by-name/mp/mpp/mpp.sh b/pkgs/by-name/mp/mpp/mpp.sh new file mode 100755 index 00000000..0d636ac5 --- /dev/null +++ b/pkgs/by-name/mp/mpp/mpp.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env dash + +# shellcheck source=/dev/null +SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH + +case "$1" in +"searchadd") + shift 1 + mpc-searchadd "$@" + ;; +"lyrics") + shift 1 + mpc-lyrics "$@" + ;; +"beetrm") + shift 1 + mpc-beetrm "$@" + ;; +*) + mpc "$@" + ;; +esac + +# vim: ft=sh diff --git a/pkgs/by-name/mp/mpp/package.nix b/pkgs/by-name/mp/mpp/package.nix new file mode 100644 index 00000000..29ec1c80 --- /dev/null +++ b/pkgs/by-name/mp/mpp/package.nix @@ -0,0 +1,63 @@ +{ + sysLib, + mpc, + fd, + symlinkJoin, + stdenv, +}: let + script = sysLib.writeShellScript { + name = "mpp"; + src = ./mpp.sh; + generateCompletions = false; + # We source the wrappers from the environment, to ensure that they have the same + # configurations (e.g. MPD_MUSIC_DIR in `mpc-lyrics`) + keepPath = true; + dependencies = [ + mpc + ]; + }; + + mpcShare = stdenv.mkDerivation { + name = "${mpc.name}-only-share"; + nativeBuildInputs = [fd]; + strictDeps = true; + + src = mpc; + + buildPhase = '' + fixMpc() { + file_path="$1" + + new_file_path="$(echo "$file_path" | sed "s|mpc|mpp|g")" + + echo "Fixing '$file_path' -> '$new_file_path'.." + + [ -f "$file_path"] && mkdir --parents "$(dirname "$new_file_path")" + + mv "$file_path" "$new_file_path" + } + + # Replace all reverences to `mpc`. First all files + fd "mpc" "." --hidden --type file | while read -r file_path; do + fixMpc "$file_path" + done + # Then their possible parent directories. + fd "mpc" "." --hidden --type directory | while read -r file_path; do + fixMpc "$file_path" + done + # Now patch all reverences to `mpc` away + fd "." --hidden --type file | while read -r file_path; do + sed --in-place 's/mpc/mpp/g' "$file_path" + done + ''; + + installPhase = '' + mkdir "$out"; + cp --recursive ./share "$out/share"; + ''; + }; +in + symlinkJoin { + name = "mpp-merged"; + paths = [script mpcShare]; + } -- cgit 1.4.1