about summary refs log tree commit diff
path: root/home/profiles/nas.nix
blob: d23f60bfa21996e585e36ce94ae7ce7fd97b8dd0 (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
{ config, lib, pkgs, ... }:
let
  bc-to-beet = pkgs.writeShellApplication {
    name = "bc-to-beet";
    runtimeInputs = [ pkgs.beets ];
    text = ''
      rm -rf ~/import/music/tmp-bc
      unzip -d ~/import/music/tmp-bc ~/import/music/album.zip
      beet import ~/import/music/tmp-bc
      rm -rf ~/import/music/tmp-bc
      rm -rf ~/import/music/album.zip
    '';
  };
in
{
  imports = [
    ./ytdlp.nix
  ];

  home.packages = with pkgs; [
    bc-to-beet
    flac
    abcde
    (pkgs.writers.writeDashBin "rip-flac" ''
      ${pkgs.abcde}/bin/abcde -c ~/.config/abcde/config
    '')
  ];

  # configuration file for abcde (see man 1 abcde)
  xdg.configFile."abcde/config".source = pkgs.writeText "config" ''
    ACTIONS=default,getalbumart

    ALBUMARTFILE="cover.jpg"
    ALBUMARTTYPE="JPG"

    CDDBMETHOD=musicbrainz

    # cd ripping program
    CDROMREADERSYNTAX=cdparanoia
    CDPARANOIA=cdparanoia
    CDPARANOIAOPTS="--never-skip=10"

    # move here
    OUTPUTDIR="$HOME/import/music"

    # output type
    FLACENCODERSYNTAX=flac
    OUTPUTTYPE=flac
    FLAC=flac
    #  --best is the same as -8 (highest compression) (also see -e)
    FLACOPTS='--verify --best'

    EXTRAVERBOSE=2
    EJECTCD=y
    MAXPROCS=4

    post_encode ()
    {
      # beets fixes some things (e.g. moving multi-disc albums together) and
      # adds some extra info (e.g. genres with lastgenre)
      echo "-------------- beets:"
      beet import "$HOME/import/music"
    }
  '';

  programs.beets = {
    enable = true;
    settings = {
      directory = "/data/fast/music";
      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 = false;
        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";
      };
    };
  };
}