about summary refs log tree commit diff
path: root/home/profiles/nas.nix
blob: c1e5ca9684df28196d19343cef59f88b0a1d0622 (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
{ config, lib, pkgs, ... }:
let
  bc-to-beet = pkgs.writeShellApplication {
    name = "bc-to-beet";
    runtimeInputs = [ pkgs.beets ];
    text = ''
      ALBUM_PATH="$1"
      ALBUM_NAME=$(basename "$ALBUM_PATH")

      mkdir -p ~/import
      rm -rf ~/import/tmp-bc
      unzip -d ~/import/tmp-bc ~/import/album.zip
      beet import ~/import/tmp-bc
      rm -rf ~/import/tmp-bc
      rm -rf ~/import/album.zip
    '';
  };
in
{
  imports = [
    ./ytdlp.nix
  ];

  home.packages = with pkgs; [
    bc-to-beet
    flac
    abcde
    (pkgs.writers.writeDashBin "rip-flac" ''
      cd ~/import
      ${pkgs.abcde}/bin/abcde -Vx -G -a "cddb,read,encode,tag,move,clean" -o flac
    '')
  ];

  programs.beets = {
    enable = true;
    settings = {
      directory = cfg.musicDirectory;
      plugins =
        "fromfilename discogs duplicates fetchart embedart badfiles lastgenre scrub";
      paths = {
        default = "$albumartist/$album%aunique{}/$track $title";
        singleton = "Singles/$artist/$title";
        comp = "Compilations/$album%aunique{}/$track - $title";
        "albumtype:soundtrack" = "Soundtracks/$album ($year)/$track $title";
      };
      import = {
        copy = true;
        move = true;
      };
      va_name = "Various Artists";
      embedart = { ifempty = true; };

      lastgenre = {
        auto = false;
        canonical = true;
        fallback = "unknown";
        force = true;
        prefer_specific = true;
      };

      fetchart = {
        cautious = true;
        sources = "filesystem coverart itunes amazon lastfm wikipedia";
      };
    };
  };
}