about summary refs log tree commit diff stats
path: root/modules/home.legacy/conf/beets/default.nix
blob: 8d6277b763735e09b1d17b508232b336403d04a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{
  pkgs,
  lib,
  config,
  ...
}: let
  plugins = import ./plugins.nix {};
in {
  imports = [
    ./plugins
  ];

  programs.beets = {
    enable = true;
    package = pkgs.beets.override {
      pluginOverrides = {
        xtractor = {
          enable = true;
          propagatedBuildInputs = [pkgs.beetsExtraPlugins.xtractor];
        };
      };
    };

    settings = {
      library = "${config.xdg.dataHome}/beets/library.db";
      art_filename = "cover";
      directory = "${config.xdg.userDirs.music}/beets";
      ui = {
        color = true;
      };

      include = [
        "./replace_override.yaml"
      ];

      import = {
        # move, instead of copying or linking the files
        copy = false;
        move = true;
        link = false;

        # Show more detail, when beet needs to ask for something
        detail = true;

        incremental = false;

        # Write the metadata to the files
        write = true;
        log = "${config.xdg.dataHome}/beets/beetslog.txt";
      };

      paths = let
        j = lib.strings.concatStringsSep "/";
      in {
        default = j ["[Default]" "$genre" "$first_artist" "$album ($albumtype)" "$track $title"];
        "albumtype:live" = j ["[Live]" "$genre" "$first_artist" "$album ($albumtype)" "$track $title"];

        "albumtype:album" = j ["Music" "$genre" "$first_artist" "$album ($albumtype)" "$track $title"];
        "albumtype::(Single|EP)" = j ["Music" "$genre" "$first_artist_singleton" "$album ($albumtype)" "$track $title"];
        "albumtype:compilation" = j ["Complilations" "$genre" "Various Artists" "$album ($albumtype)" "$track $title"];
        "albumtype:soundtrack" = j ["Soundtracks" "$genre" "$first_artist" "$album" "$track $title"];
      };

      inherit plugins;

      # Plugin config
      # scrub = {
      #   auto = true;
      # };

      musicbrainz = {
        # Search for deezer id's and use them in the autotagger
        # external_ids = {
        #   deezer = true;
        # };
      };

      # Log-on config
      # 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;
    };
  };

  xdg.configFile."beets/replace_override.yaml".source = ./replace_override.yaml;

  # Use the json formatter instead of the YAML one, as the YAML formatter mangles the
  # longer python inline strings.
  # YAML is a superset of JSON.
  xdg.configFile."beets/config.yaml".source =
    lib.mkForce
    ((pkgs.formats.json {}).generate
      "beets-config"
      config.programs.beets.settings);
}