mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-19 15:31:10 +01:00
ntfy-sh: Add client module
Co-authored-by: Sumner Evans <me@sumnerevans.com> Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
97118a310e
commit
dedf16a43c
1 changed files with 59 additions and 0 deletions
59
modules/programs/ntfy-sh.nix
Normal file
59
modules/programs/ntfy-sh.nix
Normal 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 ];
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue