about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2019-07-24 00:54:24 +0200
committerGitHub <noreply@github.com>2019-07-24 00:54:24 +0200
commit101a4be5a77bd6ee7af655bbc565efd43bb3a1e7 (patch)
tree05c555858f2a369ec3e78ad3148fbcac0d1ffa14
parent471ff05140c4b5fc8ff2777753671cc6b95dd49e (diff)
parent53841fcea9cbd639dfd30714e48959a9752c5818 (diff)
downloadnixlib-101a4be5a77bd6ee7af655bbc565efd43bb3a1e7.tar
nixlib-101a4be5a77bd6ee7af655bbc565efd43bb3a1e7.tar.gz
nixlib-101a4be5a77bd6ee7af655bbc565efd43bb3a1e7.tar.bz2
nixlib-101a4be5a77bd6ee7af655bbc565efd43bb3a1e7.tar.lz
nixlib-101a4be5a77bd6ee7af655bbc565efd43bb3a1e7.tar.xz
nixlib-101a4be5a77bd6ee7af655bbc565efd43bb3a1e7.tar.zst
nixlib-101a4be5a77bd6ee7af655bbc565efd43bb3a1e7.zip
Add spotifyd package and service (#65092)
Add spotifyd package and service
-rw-r--r--maintainers/maintainer-list.nix5
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/audio/spotifyd.nix42
-rw-r--r--pkgs/applications/audio/spotifyd/default.nix40
-rw-r--r--pkgs/top-level/all-packages.nix6
5 files changed, 94 insertions, 0 deletions
diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix
index fe413a6a5dfa..3b3104fc4411 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";
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 5041e49db1da..8d63a03dd057 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 000000000000..e3556b2559c2
--- /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 ];
+}
diff --git a/pkgs/applications/audio/spotifyd/default.nix b/pkgs/applications/audio/spotifyd/default.nix
new file mode 100644
index 000000000000..5f064cf4e885
--- /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 7a95cfaf45dd..79388cefe841 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -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 { };