mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
algia: add module
This commit is contained in:
parent
9e0453a9b0
commit
a65df80783
4 changed files with 96 additions and 0 deletions
57
modules/programs/algia.nix
Normal file
57
modules/programs/algia.nix
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkIf
|
||||||
|
mkEnableOption
|
||||||
|
mkPackageOption
|
||||||
|
mkOption
|
||||||
|
;
|
||||||
|
|
||||||
|
cfg = config.programs.algia;
|
||||||
|
jsonFormat = pkgs.formats.json { };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
||||||
|
options.programs.algia = {
|
||||||
|
enable = mkEnableOption "algia";
|
||||||
|
package = mkPackageOption pkgs "algia" { nullable = true; };
|
||||||
|
settings = mkOption {
|
||||||
|
inherit (jsonFormat) type;
|
||||||
|
default = { };
|
||||||
|
example = {
|
||||||
|
relays = {
|
||||||
|
"wss =//relay-jp.nostr.wirednet.jp" = {
|
||||||
|
read = true;
|
||||||
|
write = true;
|
||||||
|
search = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
privatekey = "nsecXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Configuration settings for algia. All the available options can be found here:
|
||||||
|
<https://github.com/mattn/algia?tab=readme-ov-file#configuration>
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
configDir =
|
||||||
|
if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
|
".config/algia"
|
||||||
|
else
|
||||||
|
"${lib.removePrefix config.home.homeDirectory config.xdg.configHome}/algia";
|
||||||
|
in
|
||||||
|
mkIf cfg.enable {
|
||||||
|
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||||
|
home.file."${configDir}/config.json" = mkIf (cfg.settings != { }) {
|
||||||
|
source = jsonFormat.generate "algia-config.json" cfg.settings;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
10
tests/modules/programs/algia/config.json
Normal file
10
tests/modules/programs/algia/config.json
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"privatekey": "nsecXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
||||||
|
"relays": {
|
||||||
|
"wss =//relay-jp.nostr.wirednet.jp": {
|
||||||
|
"read": true,
|
||||||
|
"search": false,
|
||||||
|
"write": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
tests/modules/programs/algia/default.nix
Normal file
1
tests/modules/programs/algia/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ algia-settings = ./settings.nix; }
|
||||||
28
tests/modules/programs/algia/settings.nix
Normal file
28
tests/modules/programs/algia/settings.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.algia = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
relays = {
|
||||||
|
"wss =//relay-jp.nostr.wirednet.jp" = {
|
||||||
|
read = true;
|
||||||
|
write = true;
|
||||||
|
search = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
privatekey = "nsecXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/algia/config.json
|
||||||
|
assertFileContent home-files/.config/algia/config.json \
|
||||||
|
${./config.json}
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue