about summary refs log tree commit diff
path: root/home/modules/programs/spotify-tui/default.nix
blob: 433ba64778e4643e6a46430faef98195e5cab78f (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
{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.programs.spotify-tui;
  yamlFormat = pkgs.formats.yaml { };

in {
  meta.maintainers = with lib.maintainers; [ boppyt ];

  options.programs.spotify-tui = {
    enable = mkEnableOption "A Spotify client for the terminal written in Rust.";

    package = mkOption {
      type = types.package;
      default = pkgs.spotify-tui;
      defaultText = literalExpression "pkgs.spotify-tui";
      description = "The spotify-tui package to install";
    };

    settings = mkOption {
      type = yamlFormat.type;
      default = { };
      description = ''
        Configuration written to
        <filename>$XDG_CONFIG_HOME/spotify-tui/config.yml</filename>. See <link
        xlink:href="https://github.com/Rigellute/spotify-tui#configuration"/>
        for a list of available options.
      '';
      example = literalExpression ''
        {
          theme = {
            active = "Cyan";
            banner = "LightCyan";
          };

          behavior = {
            seek_milliseconds = 5000;
            volume_increment = 10;
          };
        }
      '';
    };
  };

  config = mkIf cfg.enable {

    home.packages = [ cfg.package ];

    xdg.configFile."spotify-tui/config.yml" = mkIf (cfg.settings != { }) {
      source = yamlFormat.generate "config.yml" cfg.settings;
    };
  };
}