ntfy: update client config to auto subscribe
This commit is contained in:
parent
9a6e73d751
commit
ef34dbb44f
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
in
|
||||
|
@ -24,10 +24,16 @@ in
|
|||
navidrome.enable = mkEnableOption "navidrome";
|
||||
|
||||
ntfy-sh.enable = mkEnableOption "ntfy-sh";
|
||||
ntfy-sh.client.enable = mkOption {
|
||||
ntfy-sh.client = {
|
||||
settings = lib.mkOption {
|
||||
type = (pkgs.formats.yaml { }).type;
|
||||
default = { };
|
||||
};
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = config.profile.services.ntfy-sh.enable;
|
||||
};
|
||||
};
|
||||
|
||||
couchdb.enable = mkEnableOption "couchdb";
|
||||
|
||||
|
|
|
@ -59,8 +59,8 @@ let
|
|||
}
|
||||
]);
|
||||
in
|
||||
{
|
||||
config = mkIf (podman.enable && podman.${name}.enable) {
|
||||
lib.mkMerge [
|
||||
(mkIf podman.${name}.enable {
|
||||
sops = {
|
||||
secrets =
|
||||
let
|
||||
|
@ -142,6 +142,7 @@ in
|
|||
mode = "0444";
|
||||
};
|
||||
|
||||
|
||||
virtualisation.oci-containers.containers.${name} = {
|
||||
inherit image;
|
||||
hostname = name;
|
||||
|
@ -163,5 +164,13 @@ in
|
|||
"io.containers.autoupdate" = "registry";
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
{
|
||||
profile.services.ntfy-sh.client.settings.subscribe = [
|
||||
{
|
||||
topic = "ytptube";
|
||||
command = ''${pkgs.libnotify}/bin/notify-send --category=im.received --urgency=normal "$title" "$message"'';
|
||||
}
|
||||
];
|
||||
}
|
||||
]
|
||||
|
|
|
@ -5,6 +5,7 @@ let
|
|||
inherit (lib) mkIf;
|
||||
domain = "ntfy.tigor.web.id";
|
||||
listenAddress = "0.0.0.0:15150";
|
||||
configPath = "/etc/ntfy/client.yml";
|
||||
in
|
||||
lib.mkMerge [
|
||||
(mkIf cfg.enable {
|
||||
|
@ -46,7 +47,26 @@ lib.mkMerge [
|
|||
];
|
||||
|
||||
environment.sessionVariables = {
|
||||
NTFY_CONFIG = "/etc/ntfy/client.yml";
|
||||
NTFY_CONFIG = configPath;
|
||||
};
|
||||
|
||||
systemd.services.ntfy-client = {
|
||||
enable = true;
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
description = "ntfy client";
|
||||
after = [ "network-online.target" ];
|
||||
restartTriggers = [ (builtins.toJSON cfg.client.settings) ];
|
||||
environment = {
|
||||
DISPLAY = ":0";
|
||||
DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/user/${toString config.profile.user.uid}/bus";
|
||||
};
|
||||
path = [ pkgs.bash ];
|
||||
serviceConfig = {
|
||||
User = toString config.profile.user.uid;
|
||||
Group = toString config.profile.user.gid;
|
||||
ExecStart = "${pkgs.ntfy-sh}/bin/ntfy subscribe --config ${configPath} --from-config";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
|
||||
sops = {
|
||||
|
@ -55,20 +75,20 @@ lib.mkMerge [
|
|||
opts = { sopsFile = ../../secrets/ntfy.yaml; };
|
||||
in
|
||||
{
|
||||
"ntfy/default/user" = opts;
|
||||
"ntfy/default/password" = opts;
|
||||
"ntfy/tokens/tigor" = opts;
|
||||
};
|
||||
|
||||
templates =
|
||||
let filename = "ntfy-client.yaml"; in
|
||||
{
|
||||
${filename} = {
|
||||
content = builtins.readFile ((pkgs.formats.yaml { }).generate filename {
|
||||
content = builtins.readFile ((pkgs.formats.yaml { }).generate filename (
|
||||
{
|
||||
default-host = "https://${domain}";
|
||||
default-user = config.sops.placeholder."ntfy/default/user";
|
||||
default-password = config.sops.placeholder."ntfy/default/password";
|
||||
});
|
||||
path = "/etc/ntfy/client.yml";
|
||||
detault-token = config.sops.placeholder."ntfy/tokens/tigor";
|
||||
} // cfg.client.settings
|
||||
));
|
||||
path = configPath;
|
||||
owner = config.profile.user.name;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue