summary refs log tree commit diff
path: root/pkgs/misc/scream-receivers/default.nix
blob: 2ca00ccc9cea652f79c28a968b7f54125fcd1f65 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{ stdenv, lib, fetchFromGitHub, alsaLib
, pulseSupport ? false, libpulseaudio ? null
}:

stdenv.mkDerivation rec {
  pname = "scream-receivers";
  version = "3.3";

  src = fetchFromGitHub {
    owner = "duncanthrax";
    repo = "scream";
    rev = version;
    sha256 = "1iqhs7m0fv3vfld7h288j5j0jc5xdihaghd0jd9qrk68mj2g6g9w";
  };

  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 = [ maintainers.ivan ];
  };
}