From c219dfc43458ec104086c254e78b703b3476865d Mon Sep 17 00:00:00 2001
From: arcnmx <arcnmx@users.noreply.github.com>
Date: Fri, 2 Oct 2020 12:39:15 -0700
Subject: [PATCH] scream: 3.4 -> 3.6

Renamed from scream-receivers
---
 pkgs/applications/audio/scream/default.nix | 43 +++++++++++++++++
 pkgs/misc/scream-receivers/default.nix     | 56 ----------------------
 pkgs/top-level/all-packages.nix            |  4 +-
 3 files changed, 44 insertions(+), 59 deletions(-)
 create mode 100644 pkgs/applications/audio/scream/default.nix
 delete mode 100644 pkgs/misc/scream-receivers/default.nix

diff --git a/pkgs/applications/audio/scream/default.nix b/pkgs/applications/audio/scream/default.nix
new file mode 100644
index 00000000000..976ede5803d
--- /dev/null
+++ b/pkgs/applications/audio/scream/default.nix
@@ -0,0 +1,43 @@
+{ stdenv, lib, config, fetchFromGitHub, cmake, pkg-config
+, alsaSupport ? stdenv.isLinux, alsaLib
+, pulseSupport ? config.pulseaudio or stdenv.isLinux, libpulseaudio
+}:
+
+stdenv.mkDerivation rec {
+  pname = "scream";
+  version = "3.6";
+
+  src = fetchFromGitHub {
+    owner = "duncanthrax";
+    repo = pname;
+    rev = version;
+    sha256 = "01k2zhfb781gfj3apmcjqbm5m05m6pvnh7fb5k81zwvqibai000v";
+  };
+
+  buildInputs = lib.optional pulseSupport libpulseaudio
+    ++ lib.optional alsaSupport alsaLib;
+  nativeBuildInputs = [ cmake pkg-config ];
+
+  cmakeFlags = [
+    "-DPULSEAUDIO_ENABLE=${if pulseSupport then "ON" else "OFF"}"
+    "-DALSA_ENABLE=${if alsaSupport then "ON" else "OFF"}"
+  ];
+
+  cmakeDir = "../Receivers/unix";
+
+  doInstallCheck = true;
+  installCheckPhase = ''
+    set +o pipefail
+
+    # Programs exit with code 1 when testing help, so grep for a string
+    $out/bin/scream -h 2>&1 | grep -q Usage:
+  '';
+
+  meta = with lib; {
+    description = "Audio receiver for the Scream virtual network sound card";
+    homepage = "https://github.com/duncanthrax/scream";
+    license = licenses.mspl;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ arcnmx ];
+  };
+}
diff --git a/pkgs/misc/scream-receivers/default.nix b/pkgs/misc/scream-receivers/default.nix
deleted file mode 100644
index 6c0f73f1b25..00000000000
--- a/pkgs/misc/scream-receivers/default.nix
+++ /dev/null
@@ -1,56 +0,0 @@
-{ stdenv, lib, fetchFromGitHub, alsaLib
-, pulseSupport ? false, libpulseaudio ? null
-}:
-
-stdenv.mkDerivation rec {
-  pname = "scream-receivers";
-  version = "3.4";
-
-  src = fetchFromGitHub {
-    owner = "duncanthrax";
-    repo = "scream";
-    rev = version;
-    sha256 = "1ig89bmzfrm57nd8lamzsdz5z81ks5vjvq3f0xhgm2dk2mrgjsj3";
-  };
-
-  buildInputs = [ alsaLib ] ++ lib.optional pulseSupport libpulseaudio;
-
-  buildPhase = ''
-    (cd Receivers/alsa && make)
-    (cd Receivers/alsa-ivshmem && make)
-  '' + lib.optionalString pulseSupport ''
-    (cd Receivers/pulseaudio && make)
-    (cd Receivers/pulseaudio-ivshmem && make)
-  '';
-
-  installPhase = ''
-    mkdir -p $out/bin
-    mv ./Receivers/alsa/scream-alsa $out/bin/
-    mv ./Receivers/alsa-ivshmem/scream-ivshmem-alsa $out/bin/
-  '' + lib.optionalString pulseSupport ''
-    mv ./Receivers/pulseaudio/scream-pulse $out/bin/
-    mv ./Receivers/pulseaudio-ivshmem/scream-ivshmem-pulse $out/bin/
-  '';
-
-  doInstallCheck = true;
-  installCheckPhase = ''
-    export PATH=$PATH:$out/bin
-    set -o verbose
-    set +o pipefail
-
-    # Programs exit with code 1 when testing help, so grep for a string
-    scream-alsa -h 2>&1 | grep -q Usage:
-    scream-ivshmem-alsa 2>&1 | grep -q Usage:
-  '' + lib.optionalString pulseSupport ''
-    scream-pulse -h 2>&1 | grep -q Usage:
-    scream-ivshmem-pulse 2>&1 | grep -q Usage:
-  '';
-
-  meta = with lib; {
-    description = "Audio receivers for the Scream virtual network sound card";
-    homepage = "https://github.com/duncanthrax/scream";
-    license = licenses.mspl;
-    platforms = platforms.linux;
-    maintainers = with maintainers; [ ];
-  };
-}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 32c6eb4ee80..eb1372d278b 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -8060,9 +8060,7 @@ in
 
   scmpuff = callPackage ../applications/version-management/git-and-tools/scmpuff { };
 
-  scream-receivers = callPackage ../misc/scream-receivers {
-    pulseSupport = config.pulseaudio or false;
-  };
+  scream = callPackage ../applications/audio/scream { };
 
   scimark = callPackage ../misc/scimark { };