mirror of
https://github.com/kmein/niveum
synced 2026-03-19 03:21:10 +01:00
fix(spotifyd): hand-craft spotifyd module
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
{
|
{
|
||||||
|
imports = [ <niveum/modules/spotifyd.nix> ];
|
||||||
|
disabledModules = [ "services/audio/spotifyd.nix" ];
|
||||||
|
|
||||||
services.spotifyd = {
|
services.spotifyd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
config = builtins.readFile ((pkgs.formats.toml {}).generate "spotifyd.toml" {
|
settings = {
|
||||||
global = {
|
global = {
|
||||||
username = lib.strings.fileContents <secrets/spotify/username>;
|
username = lib.strings.fileContents <secrets/spotify/username>;
|
||||||
password = lib.strings.fileContents <secrets/spotify/password>;
|
password = lib.strings.fileContents <secrets/spotify/password>;
|
||||||
@@ -11,7 +14,7 @@
|
|||||||
device_type = "s_t_b"; # set-top box
|
device_type = "s_t_b"; # set-top box
|
||||||
device_name = config.networking.hostName;
|
device_name = config.networking.hostName;
|
||||||
};
|
};
|
||||||
});
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# ref https://github.com/NixOS/nixpkgs/issues/71362#issuecomment-753461502
|
# ref https://github.com/NixOS/nixpkgs/issues/71362#issuecomment-753461502
|
||||||
|
|||||||
60
modules/spotifyd.nix
Normal file
60
modules/spotifyd.nix
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.spotifyd;
|
||||||
|
toml = pkgs.formats.toml {};
|
||||||
|
spotifydConf = if cfg.settings != {} then toml.generate "spotify.conf" cfg.settings else pkgs.writeText "spotifyd.conf" cfg.config;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
services.spotifyd = {
|
||||||
|
enable = mkEnableOption "spotifyd, a Spotify playing daemon";
|
||||||
|
|
||||||
|
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;
|
||||||
|
description = ''
|
||||||
|
Configuration for Spotifyd. For syntax and directives, see
|
||||||
|
<link xlink:href="https://github.com/Spotifyd/spotifyd#Configuration"/>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = (cfg.config == "" && cfg.settings != {}) || (cfg.config != "" && cfg.settings == {});
|
||||||
|
message = "Using the stringly typed .config attribute is discouraged. Use the TOML typed .settings attribute instead.";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
systemd.services.spotifyd = {
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "network-online.target" "sound.target" ];
|
||||||
|
description = "spotifyd, a Spotify playing daemon";
|
||||||
|
environment.SHELL = "/bin/sh";
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = "${pkgs.spotifyd}/bin/spotifyd --no-daemon --cache-path /var/cache/spotifyd --config-path ${spotifydConf}";
|
||||||
|
Restart = "always";
|
||||||
|
RestartSec = 12;
|
||||||
|
DynamicUser = true;
|
||||||
|
CacheDirectory = "spotifyd";
|
||||||
|
SupplementaryGroups = ["audio"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
meta.maintainers = [ maintainers.anderslundstedt ];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user