1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-31 04:04:32 +00:00
This commit is contained in:
Matthias Beyer 2025-03-30 20:04:08 +02:00 committed by GitHub
commit 54b7bff160
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,59 @@
{ pkgs, lib, config, ... }:
let
cfg = config.programs.ntfy-sh;
yamlFormat = pkgs.formats.yaml { };
in with lib; {
options.programs.ntfy-sh = {
enable = mkEnableOption "ntfy-sh";
enableUserService = mkEnableOption "ntfy-sh user service";
package = mkPackageOption pkgs "ntfy-sh" { };
configFilePath = mkOption {
type = types.path;
default = "${config.xdg.configHome}/ntfy/client.yml";
defaultText = literalExpression
"''${config.xdg.configHome}/ntfy/client.yml";
description = "Path where the configuration file is placed.";
};
settings = mkOption {
type = yamlFormat.type;
default = { };
description = "Configuration for the ntfy binary";
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
home.file.ntfy-sh = {
enable = true;
target = cfg.configFilePath;
onChange = ''
systemctl --user restart ntfy-sh-client
'';
source = mkIf (cfg.settings != { })
(yamlFormat.generate "ntfy-sh-config" cfg.settings);
};
systemd.user.services.ntfy-sh-client = mkIf cfg.enableUserService {
Unit.Description = "ntfy-sh client service";
Install.WantedBy = [ "multi-user.target" ];
Service = {
Type = "simple";
Restart = "on-failure";
ExecStart = ''
${cfg.package}/bin/ntfy subscribe --config ${cfg.configFilePath} --from-config
'';
};
};
};
meta.maintainers = [ maintainers.matthiasbeyer ];
}