<commit_before># pipewire example session manager.
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.pipewire.media-session;
  enable32BitAlsaPlugins = cfg.alsa.support32Bit
                           && pkgs.stdenv.isx86_64
                           && pkgs.pkgsi686Linux.pipewire != null;

  # Helpers for generating the pipewire JSON config file
  mkSPAValueString = v:
  if builtins.isList v then "[${lib.concatMapStringsSep " " mkSPAValueString v}]"
  else if lib.types.attrs.check v then
    "{${lib.concatStringsSep " " (mkSPAKeyValue v)}}"
  else lib.generators.mkValueStringDefault { } v;

  mkSPAKeyValue = attrs: map (def: def.content) (
  lib.sortProperties
    (
      lib.mapAttrsToList
        (k: v: lib.mkOrder (v._priority or 1000) "${lib.escape [ "=" ] k} = ${mkSPAValueString (v._content or v)}")
        attrs
    )
  );

  toSPAJSON = attrs: lib.concatStringsSep "\n" (mkSPAKeyValue attrs);
in {

  meta = {
    maintainers = teams.freedesktop.members;
  };

  ###### interface
  options = {
    services.pipewire.media-session = {
      enable = mkOption {
        type = types.bool;
        default = true;
        description = "Example pipewire session manager";
      };

      package = mkOption {
        type = types.package;
        default = pkgs.pipewire.mediaSession;
        example = literalExample "pkgs.pipewire.mediaSession";
        description = ''
          The pipewire-media-session derivation to use.
        '';
      };

      config = mkOption {
        type = types.attrs;
        description = ''
          Configuration for the media session core.
        '';
        default = {
          # media-session config file
          properties = {
            # Properties to configure the session and some
            # modules
            #mem.mlock-all = false;
            #context.profile.modules = "default,rtkit";
          };
<commit_msg>nixos/pipewire: only enable media-session if pipewire is enabled<commit_after># pipewire example session manager.
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.pipewire.media-session;
  enable32BitAlsaPlugins = cfg.alsa.support32Bit
                           && pkgs.stdenv.isx86_64
                           && pkgs.pkgsi686Linux.pipewire != null;

  # Helpers for generating the pipewire JSON config file
  mkSPAValueString = v:
  if builtins.isList v then "[${lib.concatMapStringsSep " " mkSPAValueString v}]"
  else if lib.types.attrs.check v then
    "{${lib.concatStringsSep " " (mkSPAKeyValue v)}}"
  else lib.generators.mkValueStringDefault { } v;

  mkSPAKeyValue = attrs: map (def: def.content) (
  lib.sortProperties
    (
      lib.mapAttrsToList
        (k: v: lib.mkOrder (v._priority or 1000) "${lib.escape [ "=" ] k} = ${mkSPAValueString (v._content or v)}")
        attrs
    )
  );

  toSPAJSON = attrs: lib.concatStringsSep "\n" (mkSPAKeyValue attrs);
in {

  meta = {
    maintainers = teams.freedesktop.members;
  };

  ###### interface
  options = {
    services.pipewire.media-session = {
      enable = mkOption {
        type = types.bool;
        default = config.services.pipewire.enable;
        defaultText = "config.services.pipewire.enable";
        description = "Example pipewire session manager";
      };

      package = mkOption {
        type = types.package;
        default = pkgs.pipewire.mediaSession;
        example = literalExample "pkgs.pipewire.mediaSession";
        description = ''
          The pipewire-media-session derivation to use.
        '';
      };

      config = mkOption {
        type = types.attrs;
        description = ''
          Configuration for the media session core.
        '';
        default = {
          # media-session config file
          properties = {
            # Properties to configure the session and some
            # modules
            #mem.mlock-all = false;
            #context.profile.modules = "default,rtkit";
          };

{'fraction_non_alphanumeric': 0.11094263330806166, 'fraction_numerical': 0.0075815011372251705, 'mean_word_length': 2.1689351481184946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3228406', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1163, 'n_words': 275}