mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 00:12:56 +00:00
Merge pull request #126247 from kmein/feature/spotifyd
spotifyd: generate TOML config via formats
This commit is contained in:
commit
2e04b29a17
@ -4,7 +4,15 @@ with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.spotifyd;
|
||||
spotifydConf = pkgs.writeText "spotifyd.conf" cfg.config;
|
||||
toml = pkgs.formats.toml {};
|
||||
warnConfig =
|
||||
if cfg.config != ""
|
||||
then lib.trace "Using the stringly typed .config attribute is discouraged. Use the TOML typed .settings attribute instead."
|
||||
else id;
|
||||
spotifydConf =
|
||||
if cfg.settings != {}
|
||||
then toml.generate "spotify.conf" cfg.settings
|
||||
else warnConfig (pkgs.writeText "spotifyd.conf" cfg.config);
|
||||
in
|
||||
{
|
||||
options = {
|
||||
@ -14,6 +22,16 @@ in
|
||||
config = mkOption {
|
||||
default = "";
|
||||
type = types.lines;
|
||||
description = ''
|
||||
(Deprecated) Configuration for Spotifyd. For syntax and directives, see
|
||||
<link xlink:href="https://github.com/Spotifyd/spotifyd#Configuration"/>.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
default = {};
|
||||
type = toml.type;
|
||||
example = { global.bitrate = 320; };
|
||||
description = ''
|
||||
Configuration for Spotifyd. For syntax and directives, see
|
||||
<link xlink:href="https://github.com/Spotifyd/spotifyd#Configuration"/>.
|
||||
@ -23,6 +41,13 @@ in
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.config == "" || cfg.settings == {};
|
||||
message = "At most one of the .config attribute and the .settings attribute may be set";
|
||||
}
|
||||
];
|
||||
|
||||
systemd.services.spotifyd = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" "sound.target" ];
|
||||
|
Loading…
Reference in New Issue
Block a user