diff options
author | Kierán Meinhardt <kmein@posteo.de> | 2021-06-08 20:05:57 +0200 |
---|---|---|
committer | Kierán Meinhardt <kmein@posteo.de> | 2021-07-24 07:56:44 +0200 |
commit | 3f0fb761044413e4d4f2c1d3d34e89726860d701 (patch) | |
tree | a90a3d3f5b48106aac1f0e42643091ab039c2d1f | |
parent | 9be8db34cf5c05aad77128c87c746bcc909f570d (diff) | |
download | nixpkgs-3f0fb761044413e4d4f2c1d3d34e89726860d701.tar nixpkgs-3f0fb761044413e4d4f2c1d3d34e89726860d701.tar.gz nixpkgs-3f0fb761044413e4d4f2c1d3d34e89726860d701.tar.bz2 nixpkgs-3f0fb761044413e4d4f2c1d3d34e89726860d701.tar.lz nixpkgs-3f0fb761044413e4d4f2c1d3d34e89726860d701.tar.xz nixpkgs-3f0fb761044413e4d4f2c1d3d34e89726860d701.tar.zst nixpkgs-3f0fb761044413e4d4f2c1d3d34e89726860d701.zip |
spotifyd: generate TOML config via formats
-rw-r--r-- | nixos/modules/services/audio/spotifyd.nix | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/nixos/modules/services/audio/spotifyd.nix b/nixos/modules/services/audio/spotifyd.nix index 9279a03aed4..22848ed9800 100644 --- a/nixos/modules/services/audio/spotifyd.nix +++ b/nixos/modules/services/audio/spotifyd.nix @@ -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 = { @@ -15,6 +23,16 @@ in 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" ]; |