about summary refs log tree commit diff stats
path: root/modules/home/conf/beets/default.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-07 22:15:00 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-07 22:22:02 +0200
commitf57522f3e2c3a28c5c1cf9f3e8087e12120035cc (patch)
tree199fd2877f05d54bbe1455172a0ced3eaa4cc8bb /modules/home/conf/beets/default.nix
parentfix(flake): Update flake templates (diff)
downloadnixos-config-f57522f3e2c3a28c5c1cf9f3e8087e12120035cc.tar.gz
nixos-config-f57522f3e2c3a28c5c1cf9f3e8087e12120035cc.zip
feat(home/beets): Init
Diffstat (limited to 'modules/home/conf/beets/default.nix')
-rw-r--r--modules/home/conf/beets/default.nix117
1 files changed, 117 insertions, 0 deletions
diff --git a/modules/home/conf/beets/default.nix b/modules/home/conf/beets/default.nix
new file mode 100644
index 00000000..fe3281ac
--- /dev/null
+++ b/modules/home/conf/beets/default.nix
@@ -0,0 +1,117 @@
+{
+  pkgs,
+  config,
+  ...
+}: {
+  programs.beets = {
+    enable = true;
+    package = pkgs.beets.override {
+      pluginOverrides = {
+        beatport.enable = true;
+      };
+    };
+    settings = {
+      library = "${config.xdg.dataHome}/beets/library.db";
+      art_filename = "cover";
+      directory = config.xdg.userDirs.music;
+      ui = {
+        color = true;
+      };
+      import = {
+        # link, instead of copying or moving the files
+        copy = false;
+        move = false;
+        link = true;
+
+        # Write the metadata to the files
+        write = true;
+        log = "beetslog.txt";
+      };
+
+      paths = {
+        default = "$genre/$albumartist/$album/$track $title";
+        comp = "$genre/$album/$track $title";
+        singleton = "$genre/$artist/$title";
+        "albumtype:soundtrack" = "Soundtracks/$album/$track $title";
+      };
+
+      # Plugin config
+      fetchart = {};
+      lastgenre = {};
+      lyrics = {
+        # Always fetch lyrics (and update them, if some were found)
+        force = true;
+      };
+      hook = {
+        hooks = [
+          {
+            # Called, when `beet import` finishes
+            event = "import";
+            command = "echo 'Import finished. Starting to calculate replay gain..' && beet replaygain";
+          }
+        ];
+      };
+      replaygain = {
+        # Can't run in parallel in the import because of writing issues, thus we run it
+        # after the import finishes (see the `hooks` config)
+        auto = false;
+        backend = "ffmpeg";
+
+        # Re-calculate the replay gain value even for files, that already have one set.
+        overwrite = true;
+      };
+      scrub = {
+        # Could be set to false, to only scrub metadata with the `beet scrub` command.
+        auto = true;
+      };
+
+      plugins = [
+        # Remove all previous tags before import (this is useful to ensure, that
+        # the metadata in the libary.db is synced with the tags on disk)
+        # # FIXME: I think, that this also removes the baked-in images, which is not ideal
+        # <2024-08-07>
+        # "scrub"
+
+        # Calculate replay gain
+        "replaygain"
+
+        # Generate fingerprints
+        "chroma"
+
+        # Download album art
+        "fetchart"
+
+        # Fetches tags from `last.fm` and adds them as genres to imported music
+        "lastgenre"
+
+        # Run commands on events
+        "hooks"
+
+        # Fetch lyrics
+        "lyrics"
+
+        # Allow beets to understand deezer id's
+        "deezer"
+
+        "mpdstats" # Transfer MPD stats to beets
+        "mpdupdate" # Update MPD database on import
+      ];
+
+      # Log-on config
+      # musicbrainz:
+      #     external_ids:
+      #         deezer: true
+      # TODO: Add this, to upload the generated fingerprints (to help improve their
+      # database) <2024-08-07>
+      # acoustid = {
+      #   apikey = "TODO";
+      # };
+    };
+
+    mpdIntegration = {
+      enableStats = true;
+      enableUpdate = true;
+      host = config.home.sessionVariables.MPD_HOST;
+    };
+  };
+}