mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-31 04:04:32 +00:00
Merge 467266d6c6
into 09280e17bb
This commit is contained in:
commit
54b7bff160
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
Reference in a new issue