forked from mirrors/nixpkgs
nixos/gotify: init module and test
This commit is contained in:
parent
a66e5106fd
commit
3461ec2ffd
|
@ -793,6 +793,7 @@
|
||||||
./services/web-apps/cryptpad.nix
|
./services/web-apps/cryptpad.nix
|
||||||
./services/web-apps/documize.nix
|
./services/web-apps/documize.nix
|
||||||
./services/web-apps/frab.nix
|
./services/web-apps/frab.nix
|
||||||
|
./services/web-apps/gotify-server.nix
|
||||||
./services/web-apps/icingaweb2/icingaweb2.nix
|
./services/web-apps/icingaweb2/icingaweb2.nix
|
||||||
./services/web-apps/icingaweb2/module-monitoring.nix
|
./services/web-apps/icingaweb2/module-monitoring.nix
|
||||||
./services/web-apps/limesurvey.nix
|
./services/web-apps/limesurvey.nix
|
||||||
|
|
49
nixos/modules/services/web-apps/gotify-server.nix
Normal file
49
nixos/modules/services/web-apps/gotify-server.nix
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{ pkgs, lib, config, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.gotify;
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
services.gotify = {
|
||||||
|
enable = mkEnableOption "Gotify webserver";
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
type = types.port;
|
||||||
|
description = ''
|
||||||
|
Port the server listens to.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
stateDirectoryName = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "gotify-server";
|
||||||
|
description = ''
|
||||||
|
The name of the directory below <filename>/var/lib</filename> where
|
||||||
|
gotify stores its runtime data.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
WorkingDirectory = "/var/lib/${cfg.stateDirectoryName}";
|
||||||
|
StateDirectory = cfg.stateDirectoryName;
|
||||||
|
Restart = "always";
|
||||||
|
DynamicUser = "yes";
|
||||||
|
ExecStart = "${pkgs.gotify-server}/bin/server";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -93,6 +93,7 @@ in
|
||||||
fsck = handleTest ./fsck.nix {};
|
fsck = handleTest ./fsck.nix {};
|
||||||
fwupd = handleTestOn ["x86_64-linux"] ./fwupd.nix {}; # libsmbios is unsupported on aarch64
|
fwupd = handleTestOn ["x86_64-linux"] ./fwupd.nix {}; # libsmbios is unsupported on aarch64
|
||||||
gdk-pixbuf = handleTest ./gdk-pixbuf.nix {};
|
gdk-pixbuf = handleTest ./gdk-pixbuf.nix {};
|
||||||
|
gotify-server = handleTest ./gotify-server.nix {};
|
||||||
gitea = handleTest ./gitea.nix {};
|
gitea = handleTest ./gitea.nix {};
|
||||||
gitlab = handleTest ./gitlab.nix {};
|
gitlab = handleTest ./gitlab.nix {};
|
||||||
gitolite = handleTest ./gitolite.nix {};
|
gitolite = handleTest ./gitolite.nix {};
|
||||||
|
|
45
nixos/tests/gotify-server.nix
Normal file
45
nixos/tests/gotify-server.nix
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
import ./make-test.nix ({ pkgs, lib, ...} : {
|
||||||
|
name = "gotify-server";
|
||||||
|
meta = with pkgs.stdenv.lib.maintainers; {
|
||||||
|
maintainers = [ ma27 ];
|
||||||
|
};
|
||||||
|
|
||||||
|
machine = { pkgs, ... }: {
|
||||||
|
environment.systemPackages = [ pkgs.jq ];
|
||||||
|
|
||||||
|
services.gotify = {
|
||||||
|
enable = true;
|
||||||
|
port = 3000;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
startAll;
|
||||||
|
|
||||||
|
$machine->waitForUnit("gotify-server");
|
||||||
|
$machine->waitForOpenPort(3000);
|
||||||
|
|
||||||
|
my $token = $machine->succeed(
|
||||||
|
"curl --fail -sS -X POST localhost:3000/application -F name=nixos " .
|
||||||
|
'-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" ' .
|
||||||
|
'| jq .token | xargs echo -n'
|
||||||
|
);
|
||||||
|
|
||||||
|
my $usertoken = $machine->succeed(
|
||||||
|
"curl --fail -sS -X POST localhost:3000/client -F name=nixos " .
|
||||||
|
'-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" ' .
|
||||||
|
'| jq .token | xargs echo -n'
|
||||||
|
);
|
||||||
|
|
||||||
|
$machine->succeed(
|
||||||
|
"curl --fail -sS -X POST 'localhost:3000/message?token=$token' -H 'Accept: application/json' " .
|
||||||
|
'-F title=Gotify -F message=Works'
|
||||||
|
);
|
||||||
|
|
||||||
|
my $title = $machine->succeed(
|
||||||
|
"curl --fail -sS 'localhost:3000/message?since=0&token=$usertoken' | jq '.messages|.[0]|.title' | xargs echo -n"
|
||||||
|
);
|
||||||
|
|
||||||
|
$title eq "Gotify" or die "Wrong title ($title), expected 'Gotify'!";
|
||||||
|
'';
|
||||||
|
})
|
Loading…
Reference in a new issue