fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . programs . beets ; 8 9yamlFormat = pkgs . formats . yaml { }; 10 11in { 12meta . maintainers = with maintainers ; [ rycee Scrumplex ]; 13 14options = { 15programs . beets = { 16enable = mkOption { 17type = types . bool ; 18default = if versionAtLeast config . home . stateVersion "19.03" then 19false 20else 21cfg . settings != { }; 22defaultText = "false" ; 23description = '' 24Whether to enable the beets music library manager. This 25defaults to `false` for state 26version ≥ 19.03. For earlier versions beets is enabled if 27{option}`programs.beets.settings` is non-empty. 28'' ; 29}; 30 31package = mkOption { 32type = types . package ; 33default = pkgs . beets ; 34defaultText = literalExpression "pkgs.beets" ; 35example = 36literalExpression "(pkgs.beets.override { enableCheck = true; })" ; 37description = '' 38The `beets` package to use. 39Can be used to specify extensions. 40'' ; 41}; 42 43settings = mkOption { 44type = yamlFormat . type ; 45default = { }; 46description = '' 47Configuration written to 48{file}`$XDG_CONFIG_HOME/beets/config.yaml` 49'' ; 50}; 51 52mpdIntegration = { 53enableStats = mkEnableOption "mpdstats plugin and service" ; 54 55enableUpdate = mkEnableOption "mpdupdate plugin" ; 56 57host = mkOption { 58type = types . str ; 59default = "localhost" ; 60example = "10.0.0.42" ; 61description = "The host that mpdstats will connect to." ; 62}; 63 64port = mkOption { 65type = types . port ; 66default = config . services . mpd . network . port ; 67defaultText = literalExpression "config.services.mpd.network.port" ; 68example = 6601 ; 69description = "The port that mpdstats will connect to." ; 70}; 71}; 72}; 73}; 74 75config = mkMerge [ 76( mkIf cfg . enable { 77home . packages = [ cfg . package ]; 78 79xdg . configFile . "beets/config.yaml" . source = 80yamlFormat . generate "beets-config" cfg . settings ; 81}) 82 83( mkIf ( cfg . mpdIntegration . enableStats || cfg . mpdIntegration . enableUpdate ) { 84programs . beets . settings . mpd = { 85host = cfg . mpdIntegration . host ; 86port = cfg . mpdIntegration . port ; 87}; 88}) 89 90( mkIf cfg . mpdIntegration . enableStats { 91programs . beets . settings . plugins = [ "mpdstats" ]; 92}) 93 94( mkIf cfg . mpdIntegration . enableUpdate { 95programs . beets . settings . plugins = [ "mpdupdate" ]; 96}) 97 98( mkIf ( cfg . enable && cfg . mpdIntegration . enableStats ) { 99systemd . user . services . "beets-mpdstats" = { 100Unit = { 101Description = "Beets MPDStats daemon" ; 102After = optional config . services . mpd . enable "mpd.service" ; 103Requires = optional config . services . mpd . enable "mpd.service" ; 104}; 105Service . ExecStart = " ${ cfg . package } /bin/beet mpdstats" ; 106Install . WantedBy = [ "default.target" ]; 107}; 108}) 109]; 110}