aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/development/libraries/pipewire/default.nix
blob: d07c77f4e2eb42794eab4e5abc3121c49e046ccd (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
{ stdenv
, lib
, fetchFromGitLab
, fetchpatch
, removeReferencesTo
, meson
, ninja
, systemd
, pkgconfig
, doxygen
, graphviz
, valgrind
, glib
, dbus
, alsaLib
, libjack2
, udev
, libva
, libsndfile
, vulkan-headers
, vulkan-loader
, makeFontsConf
, callPackage
, nixosTests
, gstreamerSupport ? true, gst_all_1 ? null
, ffmpegSupport ? true, ffmpeg ? null
, bluezSupport ? true, bluez ? null, sbc ? null
, nativeHspSupport ? true
, ofonoSupport ? true
, hsphfpdSupport ? true
}:

let
  fontsConf = makeFontsConf {
    fontDirectories = [];
  };

  mesonBool = b: if b then "true" else "false";
in
stdenv.mkDerivation rec {
  pname = "pipewire";
  version = "0.3.17";

  outputs = [
    "out"
    "lib"
    "pulse"
    "jack"
    "dev"
    "doc"
    "installedTests"
  ];

  src = fetchFromGitLab {
    domain = "gitlab.freedesktop.org";
    owner = "pipewire";
    repo = "pipewire";
    rev = version;
    sha256 = "1gzdahji23fsgjycc08h7zzv8filmzdrkyvpkljc881l4cb5l58n";
  };

  patches = [
    # Break up a dependency cycle between outputs.
    ./alsa-profiles-use-libdir.patch
    # Move installed tests into their own output.
    ./installed-tests-path.patch
    # Change the path of the pipewire-pulse binary in the service definition.
    ./pipewire-pulse-path.patch
    # Add flag to specify configuration directory (different from the installation directory).
    ./pipewire-config-dir.patch
  ];

  nativeBuildInputs = [
    doxygen
    graphviz
    meson
    ninja
    pkgconfig
  ];

  buildInputs = [
    alsaLib
    dbus
    glib
    libjack2
    libsndfile
    udev
    vulkan-headers
    vulkan-loader
    valgrind
    systemd
  ] ++ lib.optionals gstreamerSupport [ gst_all_1.gst-plugins-base gst_all_1.gstreamer ]
  ++ lib.optional ffmpegSupport ffmpeg
  ++ lib.optionals bluezSupport [ bluez sbc ];

  mesonFlags = [
    "-Ddocs=true"
    "-Dman=false" # we don't have xmltoman
    "-Dexamples=true" # only needed for `pipewire-media-session`
    "-Dudevrulesdir=lib/udev/rules.d"
    "-Dinstalled_tests=true"
    "-Dinstalled_test_prefix=${placeholder "installedTests"}"
    "-Dpipewire_pulse_prefix=${placeholder "pulse"}"
    "-Dlibjack-path=${placeholder "jack"}/lib"
    "-Dgstreamer=${mesonBool gstreamerSupport}"
    "-Dffmpeg=${mesonBool ffmpegSupport}"
    "-Dbluez5=${mesonBool bluezSupport}"
    "-Dbluez5-backend-native=${mesonBool nativeHspSupport}"
    "-Dbluez5-backend-ofono=${mesonBool ofonoSupport}"
    "-Dbluez5-backend-hsphfpd=${mesonBool hsphfpdSupport}"
    "-Dpipewire_config_dir=/etc/pipewire"
  ];

  FONTCONFIG_FILE = fontsConf; # Fontconfig error: Cannot load default config file

  doCheck = true;

  postInstall = ''
    moveToOutput "share/systemd/user/pipewire-pulse.*" "$pulse"
    moveToOutput "lib/systemd/user/pipewire-pulse.*" "$pulse"
    moveToOutput "bin/pipewire-pulse" "$pulse"
  '';

  passthru.tests = {
    installedTests = nixosTests.installed-tests.pipewire;

    # This ensures that all the paths used by the NixOS module are found.
    test-paths = callPackage ./test-paths.nix {
      paths-out = [
        "share/alsa/alsa.conf.d/50-pipewire.conf"
      ];
      paths-lib = [
        "lib/alsa-lib/libasound_module_pcm_pipewire.so"
        "share/alsa-card-profile/mixer"
      ];
    };
  };

  meta = with stdenv.lib; {
    description = "Server and user space API to deal with multimedia pipelines";
    homepage = "https://pipewire.org/";
    license = licenses.mit;
    platforms = platforms.linux;
    maintainers = with maintainers; [ jtojnar ];
  };
}