Add spotifyd package and service (#65092)

Add spotifyd package and service
This commit is contained in:
Florian Klink 2019-07-24 00:54:24 +02:00 committed by GitHub
commit 101a4be5a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 0 deletions

View file

@ -333,6 +333,11 @@
github = "andersk";
name = "Anders Kaseorg";
};
anderslundstedt = {
email = "git@anderslundstedt.se";
github = "anderslundstedt";
name = "Anders Lundstedt";
};
AndersonTorres = {
email = "torres.anderson.85@protonmail.com";
github = "AndersonTorres";

View file

@ -198,6 +198,7 @@
./services/audio/slimserver.nix
./services/audio/snapserver.nix
./services/audio/squeezelite.nix
./services/audio/spotifyd.nix
./services/audio/ympd.nix
./services/backup/automysqlbackup.nix
./services/backup/bacula.nix

View file

@ -0,0 +1,42 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.spotifyd;
spotifydConf = pkgs.writeText "spotifyd.conf" cfg.config;
in
{
options = {
services.spotifyd = {
enable = mkEnableOption "spotifyd, a Spotify playing daemon";
config = mkOption {
default = "";
type = types.lines;
description = ''
Configuration for Spotifyd. For syntax and directives, see
https://github.com/Spotifyd/spotifyd#Configuration.
'';
};
};
};
config = mkIf cfg.enable {
systemd.services.spotifyd = {
wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" "sound.target" ];
description = "spotifyd, a Spotify playing daemon";
serviceConfig = {
ExecStart = "${pkgs.spotifyd}/bin/spotifyd --no-daemon --cache_path /var/cache/spotifyd --config ${spotifydConf}";
Restart = "always";
RestartSec = 12;
DynamicUser = true;
CacheDirectory = "spotifyd";
SupplementaryGroups = ["audio"];
};
};
};
meta.maintainers = [ maintainers.anderslundstedt ];
}

View file

@ -0,0 +1,40 @@
{ stdenv, fetchFromGitHub, rustPlatform, pkgconfig, openssl
, withALSA ? true, alsaLib ? null
, withPulseAudio ? false, libpulseaudio ? null
, withPortAudio ? false, portaudio ? null
}:
rustPlatform.buildRustPackage rec {
pname = "spotifyd";
version = "0.2.11";
src = fetchFromGitHub {
owner = "Spotifyd";
repo = "spotifyd";
rev = "${version}";
sha256 = "1iybk9xrrvhrcl2xl5r2xhyn1ydhrgwnnb8ldhsw5c16b32z03q1";
};
cargoSha256 = "0879p1h32259schmy8j3xnwpw3sw80f8mrj8s6b5aihi3yyzz521";
cargoBuildFlags = [
"--no-default-features"
"--features"
"${stdenv.lib.optionalString withALSA "alsa_backend,"}${stdenv.lib.optionalString withPulseAudio "pulseaudio_backend,"}${stdenv.lib.optionalString withPortAudio "portaudio_backend,"}"
];
nativeBuildInputs = [ pkgconfig ];
buildInputs = [ openssl ]
++ stdenv.lib.optional withALSA alsaLib
++ stdenv.lib.optional withPulseAudio libpulseaudio
++ stdenv.lib.optional withPortAudio portaudio;
meta = with stdenv.lib; {
description = "An open source Spotify client running as a UNIX daemon";
homepage = "https://github.com/Spotifyd/spotifyd";
license = with licenses; [ gpl3 ];
maintainers = [ maintainers.anderslundstedt ];
platforms = platforms.unix;
};
}

View file

@ -18538,6 +18538,12 @@ in
spectral = qt5.callPackage ../applications/networking/instant-messengers/spectral { };
spotifyd = callPackage ../applications/audio/spotifyd {
withALSA = stdenv.isLinux;
withPulseAudio = config.pulseaudio or true;
withPortAudio = stdenv.isDarwin;
};
super-productivity = callPackage ../applications/networking/super-productivity { };
wlc = callPackage ../development/libraries/wlc { };