1
0
Fork 0
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:
Aguirre Matteo 2025-07-17 19:21:31 +00:00 committed by GitHub
parent 50adf43449
commit 2d55a52963
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 85 additions and 0 deletions

View 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;
};
};
}

View 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
}

View file

@ -0,0 +1 @@
{ radio-cli-example = ./example-config.nix; }

View 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}
'';
}