From b930e1cf20f5d120822476aaa95d8da67d7ccfee Mon Sep 17 00:00:00 2001 From: Anders Lundstedt Date: Sat, 20 Jul 2019 19:38:08 +0200 Subject: [PATCH 1/3] maintainers: add anderslundstedt --- maintainers/maintainer-list.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 426113b7918..000376a9a4c 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -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"; From e6dd87c438ede050a78b7eeb1539be1af03f4479 Mon Sep 17 00:00:00 2001 From: Anders Lundstedt Date: Sat, 20 Jul 2019 19:38:53 +0200 Subject: [PATCH 2/3] spotifyd: init at 0.2.11 --- pkgs/applications/audio/spotifyd/default.nix | 40 ++++++++++++++++++++ pkgs/top-level/all-packages.nix | 6 +++ 2 files changed, 46 insertions(+) create mode 100644 pkgs/applications/audio/spotifyd/default.nix diff --git a/pkgs/applications/audio/spotifyd/default.nix b/pkgs/applications/audio/spotifyd/default.nix new file mode 100644 index 00000000000..5f064cf4e88 --- /dev/null +++ b/pkgs/applications/audio/spotifyd/default.nix @@ -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; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 03ae106c481..55ae0f3fa67 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -18496,6 +18496,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 { }; From 53841fcea9cbd639dfd30714e48959a9752c5818 Mon Sep 17 00:00:00 2001 From: Anders Lundstedt Date: Fri, 19 Jul 2019 22:13:06 +0200 Subject: [PATCH 3/3] nixos/spotifyd: init --- nixos/modules/module-list.nix | 1 + nixos/modules/services/audio/spotifyd.nix | 42 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 nixos/modules/services/audio/spotifyd.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index e07fabb348c..add9483f4a5 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -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 diff --git a/nixos/modules/services/audio/spotifyd.nix b/nixos/modules/services/audio/spotifyd.nix new file mode 100644 index 00000000000..e3556b2559c --- /dev/null +++ b/nixos/modules/services/audio/spotifyd.nix @@ -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 ]; +}