home-manager/programs/pipewire: init

This commit is contained in:
Gabriel Arazas 2024-02-04 22:25:20 +08:00
parent 4d44190cc4
commit 6d1cb78564
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
2 changed files with 47 additions and 0 deletions

View File

@ -1,6 +1,7 @@
{ {
imports = [ imports = [
./files/mutable-files.nix ./files/mutable-files.nix
./programs/pipewire.nix
./programs/pop-launcher.nix ./programs/pop-launcher.nix
./services/archivebox.nix ./services/archivebox.nix
./services/activitywatch.nix ./services/activitywatch.nix

View File

@ -0,0 +1,46 @@
{ config, lib, pkgs, ... }:
let
cfg = config.programs.pipewire;
settingsFormat = pkgs.formats.json { };
generatePipewireConfig = name: settings: {
"pipewire/pipewire.conf.d/${name}.conf" = settingsFormat.generate "hm-pipewire-override-settings-${name}" settings;
};
in
{
options.programs.pipewire = {
enable = lib.mkEnableOption "Pipewire configuration";
settings = {
type = settingsFormat.type;
default = { };
description = ''
The configuration file to be generated at
{file}`$XDG_CONFIG_HOME/pipewire/pipewire.conf`. For more details,
please see {manpage}`pipewire.conf(5)`.
'';
};
overrides = {
type = with lib.types; attrsOf settingsFormat.type;
default = { };
description = ''
A set of user overrides to be generated in
{file}`$XDG_CONFIG_HOME/pipewire/pipewire.conf.d/$OVERRIDE.conf`.
::: {.note}
Both the `settings` and `overrides` can be used at the same time but
they will be merged in some order. You can see more details about it in
{manpage}`pipewire.conf(5)`.
:::
'';
};
};
config = lib.mkIf cfg.enable {
xdg.configFile =
lib.optionalAttrs (cfg.settings != { }) {
"pipewire/pipewire.conf" = settingsFormat.generate "hm-pipewire-settings" cfg.settings;
}
// lib.mapAttrs generatePipewireConfig cfg.overrides;
};
}