<commit_before>{ stdenv, fetchurl, boost, cmake, gettext, gstreamer, gst-plugins-base
, liblastfm, qt4, taglib, fftw, glew, qjson, sqlite, libgpod, libplist
, usbmuxd, libmtp, gvfs, libcdio, libspotify, protobuf, qca2, pkgconfig
, sparsehash, config, makeWrapper, runCommand, gst_plugins }:

let
  withSpotify = config.clementine.spotify or false;

  version = "1.2.3";

  exeName = "clementine";

  src = fetchurl {
    url = https://github.com/clementine-player/Clementine/archive/1.2.3.tar.gz;
    sha256 = "1gx1109i4pylz6x7gvp4rdzc6dvh0w6in6hfbygw01d08l26bxbx";
  };

  patches = [
    ./clementine-1.2.1-include-paths.patch
    ./clementine-dbus-namespace.patch
    ./clementine-spotify-blob.patch
  ];

  buildInputs = [
    boost
    cmake
    fftw
    gettext
    glew
    gst-plugins-base
    gstreamer
    gvfs
    libcdio
    libgpod
    liblastfm
    libmtp
    libplist
    pkgconfig
    protobuf
    qca2
    qjson
    qt4
    sparsehash
    sqlite
    taglib
    usbmuxd
  ];

  free = stdenv.mkDerivation {
    name = "clementine-free-${version}";
    inherit patches src buildInputs;
    enableParallelBuilding = true;
    postPatch = ''
      sed -i src/CMakeLists.txt \
        -e 's,-Werror,,g' \
        -e 's,-Wno-unknown-warning-option,,g' \
        -e 's,-Wno-unused-private-field,,g'
    '';
    meta = with stdenv.lib; {
      homepage = "http://www.clementine-player.org";
      description = "A multiplatform music player";
      license = licenses.gpl3Plus;
      platforms = platforms.linux;
      maintainers = [ maintainers.ttuegel ];
    };
  };

  # Spotify blob for Clementine
  blob = stdenv.mkDerivation {
    name = "clementine-blob-${version}";
    # Use the same patches and sources as Clementine
    inherit patches src;
    buildInputs = buildInputs ++ [ libspotify ];
    # Only build and install the Spotify blob
    preBuild = ''
      cd ext/clementine-spotifyblob
    '';
    postInstall = ''
      mkdir -p $out/libexec/clementine
      mv $out/bin/clementine-spotifyblob $out/libexec/clementine
      rmdir $out/bin
    '';
    enableParallelBuilding = true;
    meta = with stdenv.lib; {
      homepage = "http://www.clementine-player.org";
      description = "Spotify integration for Clementine";
      # The blob itself is Apache-licensed, although libspotify is unfree.
      license = licenses.asl20;
      platforms = platforms.linux;
      maintainers = [ maintainers.ttuegel ];
    };
  };

in

with stdenv.lib;

runCommand "clementine-${version}"
{
  inherit blob free;
  buildInputs = [ makeWrapper ] ++ gst_plugins; # for the setup-hooks
  dontPatchELF = true;
  dontStrip = true;
  meta = {
    homepage = "http://www.clementine-player.org";
    description = "A multiplatform music player"
      + " (" + (optionalString withSpotify "with Spotify, ")
      + "with gstreamer plugins: "
      + concatStrings (intersperse ", " (map (x: x.name) gst_plugins))
      + ")";
    license = licenses.gpl3Plus;
    platforms = platforms.linux;
    maintainers = [ maintainers.ttuegel ];
  };
}
''
  mkdir -p $out/bin
  makeWrapper "$free/bin/${exeName}" "$out/bin/${exeName}" \
      ${optionalString withSpotify "--set CLEMENTINE_SPOTIFYBLOB \"$blob/libexec/clementine\""} \
      --prefix GST_PLUGIN_SYSTEM_PATH : "$GST_PLUGIN_SYSTEM_PATH"

  mkdir -p $out/share
  for dir in applications icons kde4; do
      ln -s "$free/share/$dir" "$out/share/$dir"
  done
''
<commit_msg>clementine: added switches for optional dependences (#23730)<commit_after>{ stdenv, fetchurl, boost, cmake, gettext, gstreamer, gst-plugins-base
, liblastfm, qt4, taglib, fftw, glew, qjson, sqlite, libgpod, libplist
, usbmuxd, libmtp, gvfs, libcdio, libspotify, protobuf, qca2, pkgconfig
, sparsehash, config, makeWrapper, runCommand, gst_plugins }:

let
  withSpotify = config.clementine.spotify or false;
  withIpod = config.clementine.ipod or false;
  withMTP = config.clementine.mtp or true;
  withCD = config.clementine.cd or true;
  withCloud = config.clementine.cloud or true;

  version = "1.2.3";

  exeName = "clementine";

  src = fetchurl {
    url = https://github.com/clementine-player/Clementine/archive/1.2.3.tar.gz;
    sha256 = "1gx1109i4pylz6x7gvp4rdzc6dvh0w6in6hfbygw01d08l26bxbx";
  };

  patches = [
    ./clementine-1.2.1-include-paths.patch
    ./clementine-dbus-namespace.patch
    ./clementine-spotify-blob.patch
  ];

  buildInputs = [
    boost
    cmake
    fftw
    gettext
    glew
    gst-plugins-base
    gstreamer
    gvfs
    liblastfm
    pkgconfig
    protobuf
    qca2
    qjson
    qt4
    sqlite
    taglib
  ]
  ++ stdenv.lib.optionals (withIpod) [libgpod libplist usbmuxd]
  ++ stdenv.lib.optionals (withMTP) [libmtp]
  ++ stdenv.lib.optionals (withCD) [libcdio]
  ++ stdenv.lib.optionals (withCloud) [sparsehash];

  free = stdenv.mkDerivation {
    name = "clementine-free-${version}";
    inherit patches src buildInputs;
    enableParallelBuilding = true;
    postPatch = ''
      sed -i src/CMakeLists.txt \
        -e 's,-Werror,,g' \
        -e 's,-Wno-unknown-warning-option,,g' \
        -e 's,-Wno-unused-private-field,,g'
    '';
    meta = with stdenv.lib; {
      homepage = "http://www.clementine-player.org";
      description = "A multiplatform music player";
      license = licenses.gpl3Plus;
      platforms = platforms.linux;
      maintainers = [ maintainers.ttuegel ];
    };
  };

  # Spotify blob for Clementine
  blob = stdenv.mkDerivation {
    name = "clementine-blob-${version}";
    # Use the same patches and sources as Clementine
    inherit patches src;
    buildInputs = buildInputs ++ [ libspotify ];
    # Only build and install the Spotify blob
    preBuild = ''
      cd ext/clementine-spotifyblob
    '';
    postInstall = ''
      mkdir -p $out/libexec/clementine
      mv $out/bin/clementine-spotifyblob $out/libexec/clementine
      rmdir $out/bin
    '';
    enableParallelBuilding = true;
    meta = with stdenv.lib; {
      homepage = "http://www.clementine-player.org";
      description = "Spotify integration for Clementine";
      # The blob itself is Apache-licensed, although libspotify is unfree.
      license = licenses.asl20;
      platforms = platforms.linux;
      maintainers = [ maintainers.ttuegel ];
    };
  };

in

with stdenv.lib;

runCommand "clementine-${version}"
{
  inherit blob free;
  buildInputs = [ makeWrapper ] ++ gst_plugins; # for the setup-hooks
  dontPatchELF = true;
  dontStrip = true;
  meta = {
    homepage = "http://www.clementine-player.org";
    description = "A multiplatform music player"
      + " (" + (optionalString withSpotify "with Spotify, ")
      + "with gstreamer plugins: "
      + concatStrings (intersperse ", " (map (x: x.name) gst_plugins))
      + ")";
    license = licenses.gpl3Plus;
    platforms = platforms.linux;
    maintainers = [ maintainers.ttuegel ];
  };
}
''
  mkdir -p $out/bin
  makeWrapper "$free/bin/${exeName}" "$out/bin/${exeName}" \
      ${optionalString withSpotify "--set CLEMENTINE_SPOTIFYBLOB \"$blob/libexec/clementine\""} \
      --prefix GST_PLUGIN_SYSTEM_PATH : "$GST_PLUGIN_SYSTEM_PATH"

  mkdir -p $out/share
  for dir in applications icons kde4; do
      ln -s "$free/share/$dir" "$out/share/$dir"
  done
''

{'fraction_non_alphanumeric': 0.12357993904128567, 'fraction_numerical': 0.011776115267387088, 'mean_word_length': 2.866630958757365, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5705687', 'n_tokens_mistral': 2631, 'n_tokens_neox': 2556, 'n_words': 530}