mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
radio-cli: add module (#7488)
This commit is contained in:
parent
50adf43449
commit
2d55a52963
4 changed files with 85 additions and 0 deletions
51
modules/programs/radio-cli.nix
Normal file
51
modules/programs/radio-cli.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkIf
|
||||||
|
mkEnableOption
|
||||||
|
mkPackageOption
|
||||||
|
mkOption
|
||||||
|
;
|
||||||
|
|
||||||
|
cfg = config.programs.radio-cli;
|
||||||
|
jsonFormat = pkgs.formats.json { };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
||||||
|
|
||||||
|
options.programs.radio-cli = {
|
||||||
|
enable = mkEnableOption "radio-cli";
|
||||||
|
package = mkPackageOption pkgs "radio-cli" { nullable = true; };
|
||||||
|
settings = mkOption {
|
||||||
|
type = jsonFormat.type;
|
||||||
|
default = { };
|
||||||
|
example = {
|
||||||
|
config_version = "2.3.0";
|
||||||
|
max_lines = 7;
|
||||||
|
country = "ES";
|
||||||
|
data = [
|
||||||
|
{
|
||||||
|
station = "lofi";
|
||||||
|
url = "https://www.youtube.com/live/jfKfPfyJRdk?si=WDl-XdfuhxBfe6XN";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Configuration settings for radio-cli. For an example config,
|
||||||
|
refer to: <https://github.com/margual56/radio-cli/blob/main/config.json>
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||||
|
xdg.configFile."radio-cli/config.json" = mkIf (cfg.settings != { }) {
|
||||||
|
source = jsonFormat.generate "radio-cli-config" cfg.settings;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
11
tests/modules/programs/radio-cli/config.json
Normal file
11
tests/modules/programs/radio-cli/config.json
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"config_version": "2.3.0",
|
||||||
|
"country": "ES",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"station": "lofi",
|
||||||
|
"url": "https://www.youtube.com/live/jfKfPfyJRdk?si=WDl-XdfuhxBfe6XN"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"max_lines": 7
|
||||||
|
}
|
||||||
1
tests/modules/programs/radio-cli/default.nix
Normal file
1
tests/modules/programs/radio-cli/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ radio-cli-example = ./example-config.nix; }
|
||||||
22
tests/modules/programs/radio-cli/example-config.nix
Normal file
22
tests/modules/programs/radio-cli/example-config.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
programs.radio-cli = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
config_version = "2.3.0";
|
||||||
|
max_lines = 7;
|
||||||
|
country = "ES";
|
||||||
|
data = [
|
||||||
|
{
|
||||||
|
station = "lofi";
|
||||||
|
url = "https://www.youtube.com/live/jfKfPfyJRdk?si=WDl-XdfuhxBfe6XN";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/radio-cli/config.json
|
||||||
|
assertFileContent home-files/.config/radio-cli/config.json \
|
||||||
|
${./config.json}
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue