mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-24 18:16:21 +03:00

Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:
nix-build ci -A fmt.check
This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).
This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).
Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase
).
If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
126 lines
3.5 KiB
Nix
126 lines
3.5 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.ntfy-sh;
|
|
|
|
settingsFormat = pkgs.formats.yaml { };
|
|
in
|
|
|
|
{
|
|
options.services.ntfy-sh = {
|
|
enable = lib.mkEnableOption "[ntfy-sh](https://ntfy.sh), a push notification service";
|
|
|
|
package = lib.mkPackageOption pkgs "ntfy-sh" { };
|
|
|
|
user = lib.mkOption {
|
|
default = "ntfy-sh";
|
|
type = lib.types.str;
|
|
description = "User the ntfy-sh server runs under.";
|
|
};
|
|
|
|
group = lib.mkOption {
|
|
default = "ntfy-sh";
|
|
type = lib.types.str;
|
|
description = "Primary group of ntfy-sh user.";
|
|
};
|
|
|
|
settings = lib.mkOption {
|
|
type = lib.types.submodule {
|
|
freeformType = settingsFormat.type;
|
|
options = {
|
|
base-url = lib.mkOption {
|
|
type = lib.types.str;
|
|
example = "https://ntfy.example";
|
|
description = ''
|
|
Public facing base URL of the service
|
|
|
|
This setting is required for any of the following features:
|
|
- attachments (to return a download URL)
|
|
- e-mail sending (for the topic URL in the email footer)
|
|
- iOS push notifications for self-hosted servers
|
|
(to calculate the Firebase poll_request topic)
|
|
- Matrix Push Gateway (to validate that the pushkey is correct)
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
default = { };
|
|
|
|
example = lib.literalExpression ''
|
|
{
|
|
listen-http = ":8080";
|
|
}
|
|
'';
|
|
|
|
description = ''
|
|
Configuration for ntfy.sh, supported values are [here](https://ntfy.sh/docs/config/#config-options).
|
|
'';
|
|
};
|
|
};
|
|
|
|
config =
|
|
let
|
|
configuration = settingsFormat.generate "server.yml" cfg.settings;
|
|
in
|
|
lib.mkIf cfg.enable {
|
|
# to configure access control via the cli
|
|
environment = {
|
|
etc."ntfy/server.yml".source = configuration;
|
|
systemPackages = [ cfg.package ];
|
|
};
|
|
|
|
services.ntfy-sh.settings = {
|
|
auth-file = lib.mkDefault "/var/lib/ntfy-sh/user.db";
|
|
listen-http = lib.mkDefault "127.0.0.1:2586";
|
|
attachment-cache-dir = lib.mkDefault "/var/lib/ntfy-sh/attachments";
|
|
cache-file = lib.mkDefault "/var/lib/ntfy-sh/cache-file.db";
|
|
};
|
|
|
|
systemd.services.ntfy-sh = {
|
|
description = "Push notifications server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
|
ExecStart = "${cfg.package}/bin/ntfy serve -c ${configuration}";
|
|
User = cfg.user;
|
|
StateDirectory = "ntfy-sh";
|
|
|
|
DynamicUser = true;
|
|
AmbientCapabilities = "CAP_NET_BIND_SERVICE";
|
|
PrivateTmp = true;
|
|
NoNewPrivileges = true;
|
|
CapabilityBoundingSet = "CAP_NET_BIND_SERVICE";
|
|
ProtectSystem = "full";
|
|
ProtectKernelTunables = true;
|
|
ProtectKernelModules = true;
|
|
ProtectKernelLogs = true;
|
|
ProtectControlGroups = true;
|
|
PrivateDevices = true;
|
|
RestrictSUIDSGID = true;
|
|
RestrictNamespaces = true;
|
|
RestrictRealtime = true;
|
|
MemoryDenyWriteExecute = true;
|
|
# Upstream Recommandation
|
|
LimitNOFILE = 20500;
|
|
};
|
|
};
|
|
|
|
users.groups = lib.optionalAttrs (cfg.group == "ntfy-sh") {
|
|
ntfy-sh = { };
|
|
};
|
|
|
|
users.users = lib.optionalAttrs (cfg.user == "ntfy-sh") {
|
|
ntfy-sh = {
|
|
isSystemUser = true;
|
|
group = cfg.group;
|
|
};
|
|
};
|
|
};
|
|
}
|