mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-08-16 16:10:39 +03:00
spotifyd: add spotifyd service
This commit is contained in:
parent
5c3146b75d
commit
f3aa13d141
@ -54,6 +54,7 @@
|
|||||||
./services/redis
|
./services/redis
|
||||||
./services/skhd
|
./services/skhd
|
||||||
./services/spacebar
|
./services/spacebar
|
||||||
|
./services/spotifyd.nix
|
||||||
./services/synapse-bt.nix
|
./services/synapse-bt.nix
|
||||||
./services/synergy
|
./services/synergy
|
||||||
./services/yabai
|
./services/yabai
|
||||||
|
63
modules/services/spotifyd.nix
Normal file
63
modules/services/spotifyd.nix
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.spotifyd;
|
||||||
|
|
||||||
|
format = pkgs.formats.toml { };
|
||||||
|
configFile = format.generate "spotifyd.conf" {
|
||||||
|
global = {
|
||||||
|
backend = "portaudio";
|
||||||
|
};
|
||||||
|
spotifyd = cfg.settings;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
services.spotifyd = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Whether to enable the spotifyd service.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = types.path;
|
||||||
|
default = pkgs.spotifyd;
|
||||||
|
defaultText = "pkgs.spotifyd";
|
||||||
|
description = ''
|
||||||
|
The spotifyd package to use.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
settings = mkOption {
|
||||||
|
type = types.nullOr format.type;
|
||||||
|
default = null;
|
||||||
|
example = {
|
||||||
|
bitrate = 160;
|
||||||
|
volume_normalisation = true;
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Configuration for spotifyd, see <link xlink:href="https://spotifyd.github.io/spotifyd/config/File.html" />
|
||||||
|
for supported values.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
environment.systemPackages = [ cfg.package ];
|
||||||
|
launchd.user.agents.spotifyd = {
|
||||||
|
serviceConfig.ProgramArguments = [ "${cfg.package}/bin/spotifyd" "--no-daemon" ]
|
||||||
|
++ optionals (cfg.settings != null) [ "--config-path=${configFile}" ];
|
||||||
|
serviceConfig = {
|
||||||
|
KeepAlive = true;
|
||||||
|
RunAtLoad = true;
|
||||||
|
ThrottleInterval = 30;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@ -125,6 +125,7 @@ let
|
|||||||
tests.services-redis = makeTest ./tests/services-redis.nix;
|
tests.services-redis = makeTest ./tests/services-redis.nix;
|
||||||
tests.services-skhd = makeTest ./tests/services-skhd.nix;
|
tests.services-skhd = makeTest ./tests/services-skhd.nix;
|
||||||
tests.services-spacebar = makeTest ./tests/services-spacebar.nix;
|
tests.services-spacebar = makeTest ./tests/services-spacebar.nix;
|
||||||
|
tests.services-spotifyd = makeTest ./tests/services-spotifyd.nix;
|
||||||
tests.services-synapse-bt = makeTest ./tests/services-synapse-bt.nix;
|
tests.services-synapse-bt = makeTest ./tests/services-synapse-bt.nix;
|
||||||
tests.services-synergy = makeTest ./tests/services-synergy.nix;
|
tests.services-synergy = makeTest ./tests/services-synergy.nix;
|
||||||
tests.services-yabai = makeTest ./tests/services-yabai.nix;
|
tests.services-yabai = makeTest ./tests/services-yabai.nix;
|
||||||
|
18
tests/services-spotifyd.nix
Normal file
18
tests/services-spotifyd.nix
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
spotifyd = pkgs.runCommand "spotifyd-0.0.0" {} "mkdir $out";
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
services.spotifyd.enable = true;
|
||||||
|
services.spotifyd.package = spotifyd;
|
||||||
|
|
||||||
|
test = ''
|
||||||
|
echo >&2 "checking spotifyd service in ~/Library/LaunchAgents"
|
||||||
|
grep "org.nixos.spotifyd" ${config.out}/user/Library/LaunchAgents/org.nixos.spotifyd.plist
|
||||||
|
grep "${spotifyd}/bin/spotifyd" ${config.out}/user/Library/LaunchAgents/org.nixos.spotifyd.plist
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user