about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--modules/home.legacy/conf/beets/plugins/play/default.nix2
-rw-r--r--modules/home.legacy/conf/yambar/default.nix2
-rw-r--r--modules/home.legacy/pkgs/default.nix16
-rw-r--r--pkgs/by-name/mp/mpc-beetrm/package.nix4
-rw-r--r--pkgs/by-name/mp/mpc-lyrics/package.nix4
-rw-r--r--pkgs/by-name/mp/mpc-searchadd/package.nix4
-rw-r--r--pkgs/by-name/mp/mpc/package.nix15
-rwxr-xr-xpkgs/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.nix63
9 files changed, 76 insertions, 34 deletions
diff --git a/modules/home.legacy/conf/beets/plugins/play/default.nix b/modules/home.legacy/conf/beets/plugins/play/default.nix
index f5bc3c9b..635848c0 100644
--- a/modules/home.legacy/conf/beets/plugins/play/default.nix
+++ b/modules/home.legacy/conf/beets/plugins/play/default.nix
@@ -5,7 +5,7 @@
   ...
 }: {
   programs.beets.settings.play = {
-    command = "${lib.getExe pkgs.mpc-cli} $args add";
+    command = "${lib.getExe pkgs.mpc} $args add";
     relative_to = config.services.mpd.musicDirectory;
 
     # Run the command with the returned paths as arguments
diff --git a/modules/home.legacy/conf/yambar/default.nix b/modules/home.legacy/conf/yambar/default.nix
index 007e7f25..72dcaa8e 100644
--- a/modules/home.legacy/conf/yambar/default.nix
+++ b/modules/home.legacy/conf/yambar/default.nix
@@ -29,7 +29,7 @@ in {
       else "";
 
     mpd_song_name_script = makeScript {
-      dependencies = builtins.attrValues {inherit (pkgs) mpc-cli;};
+      dependencies = builtins.attrValues {inherit (pkgs) mpc;};
       name = "mpd_song_name";
     };
 
diff --git a/modules/home.legacy/pkgs/default.nix b/modules/home.legacy/pkgs/default.nix
index ad77c5fb..2018805f 100644
--- a/modules/home.legacy/pkgs/default.nix
+++ b/modules/home.legacy/pkgs/default.nix
@@ -5,14 +5,8 @@
   nixosConfig,
   ...
 }:
+# TODO: Remove this whole file, and move each pkgs to a separate module. <2024-11-16>
 with pkgs; let
-  onlyShare = drv:
-    runCommand "${drv.name}-only-share" {} ''
-      mkdir -p $out
-      ln -s ${drv}/share $out/share
-    '';
-  mpc-cli-man = onlyShare mpc-cli;
-
   Gui = {
     Terminals = [
       # foot # wayland native terminal
@@ -126,9 +120,10 @@ with pkgs; let
 
       Listen = [
         spodi # Wrapper around `spotdl`.
-        ncmpc # mpd player client
-        mpc-cli-man # a cli mpd client (added via a wrapper script)
-        mpc # Wrapper around `mpc` that allows the usage of `mpc-{rm,lyrics,searchadd}` without the `-`
+        sort_song # Sorts songs in the current directory.
+
+        mpp # Wrapper around `mpc` that allows the usage of `mpc-{beetsrm,lyrics,searchadd}` (below) without the `-`
+
         # Removes the currently playing song from the disk and storage
         (mpc-beetrm.override {
           beets = config.programs.beets.package;
@@ -141,7 +136,6 @@ with pkgs; let
         (mpc-lyrics.override {
           mpd_music_dir = config.services.mpd.musicDirectory;
         })
-        sort_song # Sorts songs in the current directory.
       ];
     };
 
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/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/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];
+  }