mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
nixos/services.ntfy-sh: remove with lib;
This commit is contained in:
parent
eeed115e37
commit
457b7563d4
@ -1,7 +1,4 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.ntfy-sh;
|
cfg = config.services.ntfy-sh;
|
||||||
|
|
||||||
@ -10,28 +7,28 @@ in
|
|||||||
|
|
||||||
{
|
{
|
||||||
options.services.ntfy-sh = {
|
options.services.ntfy-sh = {
|
||||||
enable = mkEnableOption "[ntfy-sh](https://ntfy.sh), a push notification service";
|
enable = lib.mkEnableOption "[ntfy-sh](https://ntfy.sh), a push notification service";
|
||||||
|
|
||||||
package = mkPackageOption pkgs "ntfy-sh" { };
|
package = lib.mkPackageOption pkgs "ntfy-sh" { };
|
||||||
|
|
||||||
user = mkOption {
|
user = lib.mkOption {
|
||||||
default = "ntfy-sh";
|
default = "ntfy-sh";
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
description = "User the ntfy-sh server runs under.";
|
description = "User the ntfy-sh server runs under.";
|
||||||
};
|
};
|
||||||
|
|
||||||
group = mkOption {
|
group = lib.mkOption {
|
||||||
default = "ntfy-sh";
|
default = "ntfy-sh";
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
description = "Primary group of ntfy-sh user.";
|
description = "Primary group of ntfy-sh user.";
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = mkOption {
|
settings = lib.mkOption {
|
||||||
type = types.submodule {
|
type = lib.types.submodule {
|
||||||
freeformType = settingsFormat.type;
|
freeformType = settingsFormat.type;
|
||||||
options = {
|
options = {
|
||||||
base-url = mkOption {
|
base-url = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
example = "https://ntfy.example";
|
example = "https://ntfy.example";
|
||||||
description = ''
|
description = ''
|
||||||
Public facing base URL of the service
|
Public facing base URL of the service
|
||||||
@ -49,7 +46,7 @@ in
|
|||||||
|
|
||||||
default = { };
|
default = { };
|
||||||
|
|
||||||
example = literalExpression ''
|
example = lib.literalExpression ''
|
||||||
{
|
{
|
||||||
listen-http = ":8080";
|
listen-http = ":8080";
|
||||||
}
|
}
|
||||||
@ -65,7 +62,7 @@ in
|
|||||||
let
|
let
|
||||||
configuration = settingsFormat.generate "server.yml" cfg.settings;
|
configuration = settingsFormat.generate "server.yml" cfg.settings;
|
||||||
in
|
in
|
||||||
mkIf cfg.enable {
|
lib.mkIf cfg.enable {
|
||||||
# to configure access control via the cli
|
# to configure access control via the cli
|
||||||
environment = {
|
environment = {
|
||||||
etc."ntfy/server.yml".source = configuration;
|
etc."ntfy/server.yml".source = configuration;
|
||||||
@ -73,10 +70,10 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
services.ntfy-sh.settings = {
|
services.ntfy-sh.settings = {
|
||||||
auth-file = mkDefault "/var/lib/ntfy-sh/user.db";
|
auth-file = lib.mkDefault "/var/lib/ntfy-sh/user.db";
|
||||||
listen-http = mkDefault "127.0.0.1:2586";
|
listen-http = lib.mkDefault "127.0.0.1:2586";
|
||||||
attachment-cache-dir = mkDefault "/var/lib/ntfy-sh/attachments";
|
attachment-cache-dir = lib.mkDefault "/var/lib/ntfy-sh/attachments";
|
||||||
cache-file = mkDefault "/var/lib/ntfy-sh/cache-file.db";
|
cache-file = lib.mkDefault "/var/lib/ntfy-sh/cache-file.db";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.ntfy-sh = {
|
systemd.services.ntfy-sh = {
|
||||||
@ -110,11 +107,11 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
users.groups = optionalAttrs (cfg.group == "ntfy-sh") {
|
users.groups = lib.optionalAttrs (cfg.group == "ntfy-sh") {
|
||||||
ntfy-sh = { };
|
ntfy-sh = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
users.users = optionalAttrs (cfg.user == "ntfy-sh") {
|
users.users = lib.optionalAttrs (cfg.user == "ntfy-sh") {
|
||||||
ntfy-sh = {
|
ntfy-sh = {
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
group = cfg.group;
|
group = cfg.group;
|
||||||
|
Loading…
Reference in New Issue
Block a user