summaryrefslogtreecommitdiff
path: root/modules/nixos/beets.nix
blob: ccceaeb257934fcfdbbd964faa90c4aeaa448da8 (plain)
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
{
  config,
  lib,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.beets;
in {
  options.nixfiles.modules.beets.enable =
    mkEnableOption "beets";

  config = mkIf cfg.enable {
    hm = let
      beetsdir = "${config.dirs.data}/beets";
    in {
      home = {
        activation.initialiseBeets = ''
          if [[ ! -d "${beetsdir}" ]]; then
            mkdir -p ${beetsdir}
          fi
        '';

        sessionVariables.BEETSDIR = beetsdir;
      };

      programs = {
        beets = {
          enable = true;

          settings = {
            library = "${beetsdir}/library.db";
            directory = config.userDirs.music;
            plugins = concatStringsSep " " [
              "badfiles"
              "edit"
              "fetchart"
              "info"
              "mbsync"
              "mpdupdate"
              "scrub"
              "zero"
            ];
            original_date = true;
            import = {
              write = true;
              copy = true;
              move = false;
              bell = true;
              from_scratch = true;
            };
            match = {
              preferred = {
                countries = [
                  "JP"
                  "KR"
                  "TW"
                  "HK"
                  "CN"
                  "RU"
                  "NL"
                  "DE"
                  "AT"
                  "GB|UK"
                  "CA"
                  "AU"
                  "NZ"
                  "US"
                ];
                original_year = true;
              };
            };
            edit = {
              albumfields = "album artist albumartist";
              itemfields = "track title album artist albumartist day month year genre";
            };
            fetchart = {
              auto = true;
              cautious = true;
              cover_names = "cover Cover folder Folder art Art album Album front Front";
              sources = "filesystem coverart itunes amazon albumart wikipedia";
              high_resolution = true;
            };
            scrub.auto = true;
            zero = {
              fields = "comments genre";
              update_database = true;
            };
            mpd = {
              host = "127.0.0.1";
              port = 6600;
            };
          };
        };

        bash.shellAliases.beet = "beet --config ${config.dirs.config}/beets/config.yaml";
      };
    };
  };
}