mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
alistral: add module
This commit is contained in:
parent
004753ae6b
commit
6bbfe2d697
4 changed files with 84 additions and 0 deletions
52
modules/programs/alistral.nix
Normal file
52
modules/programs/alistral.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
mkIf
|
||||
mkEnableOption
|
||||
mkPackageOption
|
||||
mkOption
|
||||
;
|
||||
|
||||
cfg = config.programs.alistral;
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
||||
options.programs.alistral = {
|
||||
enable = mkEnableOption "alistral";
|
||||
package = mkPackageOption pkgs "alistral" { nullable = true; };
|
||||
settings = mkOption {
|
||||
inherit (jsonFormat) type;
|
||||
default = { };
|
||||
example = {
|
||||
default_user = "spanish_inquisition";
|
||||
listenbrainz_url = "https://api.listenbrainz.org/1/";
|
||||
musicbrainz_url = "http://musicbrainz.org/ws/2";
|
||||
};
|
||||
description = ''
|
||||
Configuration settings for alistral. You can see the details here:
|
||||
<https://rustynova016.github.io/Alistral/config/config.html>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
configDir =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"Library/Application Support/alistral"
|
||||
else
|
||||
".config/alistral";
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||
home.file."${configDir}/config.json" = mkIf (cfg.settings != { }) {
|
||||
source = jsonFormat.generate "alistral-config.json" cfg.settings;
|
||||
};
|
||||
};
|
||||
}
|
||||
5
tests/modules/programs/alistral/config.json
Normal file
5
tests/modules/programs/alistral/config.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"default_user": "spanish_inquisition",
|
||||
"listenbrainz_url": "https://api.listenbrainz.org/1/",
|
||||
"musicbrainz_url": "http://musicbrainz.org/ws/2"
|
||||
}
|
||||
1
tests/modules/programs/alistral/default.nix
Normal file
1
tests/modules/programs/alistral/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ alistral-settings = ./settings.nix; }
|
||||
26
tests/modules/programs/alistral/settings.nix
Normal file
26
tests/modules/programs/alistral/settings.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.alistral = {
|
||||
enable = true;
|
||||
settings = {
|
||||
default_user = "spanish_inquisition";
|
||||
listenbrainz_url = "https://api.listenbrainz.org/1/";
|
||||
musicbrainz_url = "http://musicbrainz.org/ws/2";
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script =
|
||||
let
|
||||
configDir =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"Library/Application Support/alistral"
|
||||
else
|
||||
".config/alistral";
|
||||
in
|
||||
''
|
||||
assertFileExists "home-files/${configDir}/config.json"
|
||||
assertFileContent "home-files/${configDir}/config.json" \
|
||||
${./config.json}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue