{ sysLib, mpc, fd, symlinkJoin, stdenv, zsh, }: 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 = "mpp-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" } # Copy the zsh bundled `mpc` completions to `mpp` # TODO: Also add completions for the new subcommands <2024-11-17> mkdir --parents share/zsh/site-functions; cp "${zsh}/share/zsh/${zsh.version}/functions/_mpc" "share/zsh/site-functions" # 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]; }