diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-11-16 21:13:24 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-11-16 21:13:24 +0100 |
commit | b317fc17f00ea74fe2267950b3119dddddd78b09 (patch) | |
tree | bdcf6882c5ba53129001597a9d057a0c4f9d4ca2 /pkgs/by-name/mp/mpp | |
parent | build(treewide): Update (diff) | |
download | nixos-config-b317fc17f00ea74fe2267950b3119dddddd78b09.tar.gz nixos-config-b317fc17f00ea74fe2267950b3119dddddd78b09.zip |
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.
Diffstat (limited to '')
-rwxr-xr-x | pkgs/by-name/mp/mpp/mpp.sh (renamed from pkgs/by-name/mp/mpc/mpc.sh) | 0 | ||||
-rw-r--r-- | pkgs/by-name/mp/mpp/package.nix | 63 |
2 files changed, 63 insertions, 0 deletions
diff --git a/pkgs/by-name/mp/mpc/mpc.sh b/pkgs/by-name/mp/mpp/mpp.sh index 0d636ac5..0d636ac5 100755 --- a/pkgs/by-name/mp/mpc/mpc.sh +++ b/pkgs/by-name/mp/mpp/mpp.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]; + } |