mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
pianobar: add module to create config file (#7734)
Configuration entry similar to;
```nix
programs.pianobar = {
enable = true;
user = "groovy-tunes@example.com";
password_command = "cat /run/secrets/pianobar/groovy-tunes";
};
```
... will produce a `~/.config/pianobar/config` file with content of;
```conf
user = groovy-tunes@example.com
password_command = cat /run/secrets/pianobar/groovy-tunes
```
... and add `pianobar` to `home.packages` list.
All configurations that `man pianobar` documents _should_ available via
`extraOptions` attribute.
License, according to `NixOS/nixpkgs` is MIT, and that seems to match
what's shown on `PromyLOPh/pianobar` repo too;
- d92bfd5feb/pkgs/by-name/pi/pianobar/package.nix (L42o)
- https://github.com/PromyLOPh/pianobar/?tab=License-1-ov-file#readme
This commit is contained in:
parent
ede1f891c0
commit
a60021a8c9
7 changed files with 204 additions and 0 deletions
11
modules/misc/news/2025/09/2025-09-06_10-04-11.nix
Normal file
11
modules/misc/news/2025/09/2025-09-06_10-04-11.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
time = "2025-09-06T17:04:11+00:00";
|
||||
condition = true;
|
||||
message = ''
|
||||
A new module is available: 'programs.pianobar'.
|
||||
|
||||
`pianobar` is a console front-end for Pandora.com and provides options to
|
||||
extend with third-party applications or scripts. This module enables
|
||||
declarative configuration of all documented options.
|
||||
'';
|
||||
}
|
||||
101
modules/programs/pianobar.nix
Normal file
101
modules/programs/pianobar.nix
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
mkEnableOption
|
||||
mkIf
|
||||
mkOption
|
||||
mkPackageOption
|
||||
literalExpression
|
||||
;
|
||||
|
||||
inherit (lib.types)
|
||||
nonEmptyStr
|
||||
submodule
|
||||
;
|
||||
|
||||
inherit (pkgs.formats)
|
||||
keyValue
|
||||
;
|
||||
|
||||
keyValueFormat = keyValue { };
|
||||
|
||||
cfg = config.programs.pianobar;
|
||||
in
|
||||
{
|
||||
meta.maintainers = [
|
||||
# lib.maintainers.S0AndS0
|
||||
## TODO: Trade above for below when `node.nixpkgs.locked.rev` is at or beyond
|
||||
## 4d48a4e93b9ffbd291b2d9ca3315848e27eed800
|
||||
{
|
||||
name = "S0AndS0";
|
||||
email = "S0AndS0@digital-mercenaries.com";
|
||||
github = "S0AndS0";
|
||||
githubId = 4116150;
|
||||
matrix = "@s0ands0:matrix.org";
|
||||
}
|
||||
];
|
||||
|
||||
options.programs.pianobar = {
|
||||
enable = mkEnableOption "Enable pianobar";
|
||||
|
||||
package = mkPackageOption pkgs "pianobar" {
|
||||
nullable = true;
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
type = submodule {
|
||||
freeformType = keyValueFormat.type;
|
||||
options = {
|
||||
user = mkOption {
|
||||
description = "Username or emaill address for Pandora music service authentication";
|
||||
example = ''"groovy-tunes@example.com"'';
|
||||
type = nonEmptyStr;
|
||||
};
|
||||
|
||||
password_command = mkOption {
|
||||
description = "Command pianobar will use to access password for Pandora music service authentication";
|
||||
example = ''"cat /run/secrets/pianobar/groovy-tunes"'';
|
||||
type = nonEmptyStr;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
default = { };
|
||||
|
||||
description = ''
|
||||
Apply configurations for `pianobar` via key/value attributes.
|
||||
|
||||
Note; it is recommended to use `sops-nix`, or similar, secrets
|
||||
management solution for providing
|
||||
`programs.pianobar.settings.password_command` value.
|
||||
'';
|
||||
|
||||
example = literalExpression ''
|
||||
{
|
||||
programs.pianobar = {
|
||||
enable = true;
|
||||
settings = {
|
||||
user = "groovy-tunes@example.com";
|
||||
password_command = "cat /run/secrets/pianobar/groovy-tunes";
|
||||
};
|
||||
};
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
xdg.configFile."pianobar/config" = lib.mkIf (cfg.settings != { }) {
|
||||
source = keyValueFormat.generate "pianobar-config" cfg.settings;
|
||||
};
|
||||
|
||||
home.packages = mkIf (cfg.package != null) [
|
||||
cfg.package
|
||||
];
|
||||
};
|
||||
}
|
||||
4
tests/modules/programs/pianobar/default.nix
Normal file
4
tests/modules/programs/pianobar/default.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
pianobar-minimally-required-configs = ./minimally-required-configs.nix;
|
||||
pianobar-extra-settings = ./extra-settings.nix;
|
||||
}
|
||||
29
tests/modules/programs/pianobar/extra-settings.conf
Normal file
29
tests/modules/programs/pianobar/extra-settings.conf
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
act_help=h
|
||||
act_history=?
|
||||
at_icon=@
|
||||
audio_pipe=/path/to/fifo
|
||||
audio_quality=low
|
||||
autoselect={1,0}
|
||||
autostart_station=123456
|
||||
bind_to={if!tunX,host!127.0.0.1}
|
||||
buffer_seconds=5
|
||||
ca_bundle=/etc/ssl/certs/ca-certificates.crt
|
||||
control_proxy=http://user:password@host:port/
|
||||
event_command=/home/user/.config/pianobar/eventcmd
|
||||
fifo=/home/user/.config/pianobar/cmd
|
||||
format_list_song=%i) %a - %t%r
|
||||
format_msg_none=%s
|
||||
gain_mul=1.0
|
||||
history=5
|
||||
host=tuner.pandora.com
|
||||
love_icon=<3
|
||||
max_retry=3
|
||||
password_command=cat /run/secrets/pianobar/groovy-tunes
|
||||
proxy=http://user:password@host:port/
|
||||
sample_rate=0
|
||||
sort={name_az, name_za, quickmix_01_name_az, quickmix_01_name_za, quickmix_10_name_az, quickmix_10_name_za}
|
||||
timeout=30
|
||||
tired_icon=zZ
|
||||
tls_port=443
|
||||
user=groovy-tunes@example.com
|
||||
volume=30
|
||||
42
tests/modules/programs/pianobar/extra-settings.nix
Normal file
42
tests/modules/programs/pianobar/extra-settings.nix
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
programs.pianobar = {
|
||||
enable = true;
|
||||
settings = {
|
||||
act_help = "h";
|
||||
act_history = "?";
|
||||
at_icon = "@";
|
||||
audio_pipe = "/path/to/fifo";
|
||||
audio_quality = "low";
|
||||
autoselect = "{1,0}";
|
||||
autostart_station = "123456";
|
||||
bind_to = "{if!tunX,host!127.0.0.1}";
|
||||
buffer_seconds = "5";
|
||||
ca_bundle = "/etc/ssl/certs/ca-certificates.crt";
|
||||
control_proxy = "http://user:password@host:port/";
|
||||
event_command = "/home/user/.config/pianobar/eventcmd";
|
||||
fifo = "/home/user/.config/pianobar/cmd";
|
||||
format_list_song = "%i) %a - %t%r";
|
||||
format_msg_none = "%s";
|
||||
gain_mul = "1.0";
|
||||
history = "5";
|
||||
host = "tuner.pandora.com";
|
||||
love_icon = "<3";
|
||||
max_retry = "3";
|
||||
password_command = "cat /run/secrets/pianobar/groovy-tunes";
|
||||
proxy = "http://user:password@host:port/";
|
||||
sample_rate = "0";
|
||||
sort = "{name_az, name_za, quickmix_01_name_az, quickmix_01_name_za, quickmix_10_name_az, quickmix_10_name_za}";
|
||||
timeout = "30";
|
||||
tired_icon = "zZ";
|
||||
tls_port = "443";
|
||||
user = "groovy-tunes@example.com";
|
||||
volume = "30";
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/pianobar/config
|
||||
assertFileContent home-files/.config/pianobar/config \
|
||||
${./extra-settings.conf}
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
password_command=cat /run/secrets/pianobar/groovy-tunes
|
||||
user=groovy-tunes@example.com
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
programs.pianobar = {
|
||||
enable = true;
|
||||
settings = {
|
||||
password_command = "cat /run/secrets/pianobar/groovy-tunes";
|
||||
user = "groovy-tunes@example.com";
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/pianobar/config
|
||||
assertFileContent home-files/.config/pianobar/config \
|
||||
${./minimally-required-configs.conf}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue