mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
Merge pull request #330956 from DCsunset/gotify-module-update
nixos/gotify-server: support all config options and custom package
This commit is contained in:
commit
e20e12a9c7
@ -1,49 +1,90 @@
|
||||
{ pkgs, lib, config, ... }:
|
||||
|
||||
with lib;
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.services.gotify;
|
||||
in {
|
||||
options = {
|
||||
services.gotify = {
|
||||
enable = mkEnableOption "Gotify webserver";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(lib.mkRenamedOptionModule
|
||||
[
|
||||
"services"
|
||||
"gotify"
|
||||
"port"
|
||||
]
|
||||
[
|
||||
"services"
|
||||
"gotify"
|
||||
"environment"
|
||||
"GOTIFY_SERVER_PORT"
|
||||
]
|
||||
)
|
||||
];
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
description = ''
|
||||
Port the server listens to.
|
||||
'';
|
||||
};
|
||||
options.services.gotify = {
|
||||
enable = lib.mkEnableOption "Gotify webserver";
|
||||
|
||||
stateDirectoryName = mkOption {
|
||||
type = types.str;
|
||||
default = "gotify-server";
|
||||
description = ''
|
||||
The name of the directory below {file}`/var/lib` where
|
||||
gotify stores its runtime data.
|
||||
'';
|
||||
package = lib.mkPackageOption pkgs "gotify-server" { };
|
||||
|
||||
environment = lib.mkOption {
|
||||
type = lib.types.attrsOf (
|
||||
lib.types.oneOf [
|
||||
lib.types.str
|
||||
lib.types.int
|
||||
]
|
||||
);
|
||||
default = { };
|
||||
example = {
|
||||
GOTIFY_SERVER_PORT = 8080;
|
||||
GOTIFY_DATABASE_DIALECT = "sqlite3";
|
||||
};
|
||||
description = ''
|
||||
Config environment variables for the gotify-server.
|
||||
See https://gotify.net/docs/config for more details.
|
||||
'';
|
||||
};
|
||||
|
||||
environmentFiles = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.path;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Files containing additional config environment variables for gotify-server.
|
||||
Secrets should be set in environmentFiles instead of environment.
|
||||
'';
|
||||
};
|
||||
|
||||
stateDirectoryName = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "gotify-server";
|
||||
description = ''
|
||||
The name of the directory below {file}`/var/lib` where
|
||||
gotify stores its runtime data.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.services.gotify-server = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
description = "Simple server for sending and receiving messages";
|
||||
|
||||
environment = {
|
||||
GOTIFY_SERVER_PORT = toString cfg.port;
|
||||
};
|
||||
environment = lib.mapAttrs (_: toString) cfg.environment;
|
||||
|
||||
serviceConfig = {
|
||||
WorkingDirectory = "/var/lib/${cfg.stateDirectoryName}";
|
||||
StateDirectory = cfg.stateDirectoryName;
|
||||
EnvironmentFile = cfg.environmentFiles;
|
||||
Restart = "always";
|
||||
DynamicUser = "yes";
|
||||
ExecStart = "${pkgs.gotify-server}/bin/server";
|
||||
DynamicUser = true;
|
||||
ExecStart = lib.getExe cfg.package;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
meta.maintainers = with lib.maintainers; [ DCsunset ];
|
||||
}
|
||||
|
@ -9,7 +9,9 @@ import ./make-test-python.nix ({ pkgs, lib, ...} : {
|
||||
|
||||
services.gotify = {
|
||||
enable = true;
|
||||
port = 3000;
|
||||
environment = {
|
||||
GOTIFY_SERVER_PORT = 3000;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user