Skip to content

Commit

Permalink
mob next [ci skip]
Browse files Browse the repository at this point in the history
lastFile:configs/all-configurations.nix
  • Loading branch information
lorenzleutgeb committed Aug 2, 2023
1 parent 71d3af8 commit f4af99d
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 149 deletions.
1 change: 0 additions & 1 deletion configs/all-configurations.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{ pkgs }: {
liberaforms-container = import ./liberaforms/container.nix;
pretalx-server = import ./pretalx/server.nix;
}
47 changes: 0 additions & 47 deletions configs/pretalx/server.nix

This file was deleted.

156 changes: 67 additions & 89 deletions modules/pretalx.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,107 +73,85 @@ in {
};

config = mkIf cfg.enable {
users.users."${user}" = {
isSystemUser = true;
isNormalUser = false;
createHome = true;
home = "/var/lib/pretalx";
description = "Pretalx user";
group = "${user}";
};

users.users."${user}" = {
isSystemUser = true;
isNormalUser = false;
createHome = true;
home = "/var/lib/pretalx";
description = "Pretalx user";
group = "${user}";
};

#users.groups."${user}" = {};
#users.groups."${user}" = {};

environment.etc."pretalx/pretalx.cfg".source = pretalxCfgFile;
environment.etc."pretalx/pretalx.cfg".source = pretalxCfgFile;

systemd.services.pretalx-migrate = {
description = "Pretalx DB Migrations";
serviceConfig = {
Type = "oneshot";
EnvironmentFile = environmentFile;
User = user;
systemd.services.pretalx-migrate = {
description = "Pretalx DB Migrations";
serviceConfig = {
Type = "oneshot";
EnvironmentFile = environmentFile;
User = user;
};
script = "${pretalx}/bin/pretalx migrate";
};
script = "${pretalx}/bin/pretalx migrate";
};

systemd.services.pretalx-web = {
description = "Pretalx Web Service";
serviceConfig = {
Type = "simple";
Restart = "on-failure";
EnvironmentFile = environmentFile;
User = user;
ExecStart = pkgs.writeScript "webserver" ''
#!${pkgs.runtimeShell}
set -euo pipefail
${pretalx}/bin/pretalx collectstatic --noinput
exec ${gunicorn}/bin/gunicorn pretalx.wsgi --name ${name} \
--workers 3 \
--log-level=info \
--bind=${server.bind}:${server.port}
'';
systemd.services.pretalx-web = {
description = "Pretalx Web Service";
serviceConfig = {
Type = "simple";
Restart = "on-failure";
EnvironmentFile = environmentFile;
User = user;
ExecStart = pkgs.writeScript "webserver" ''
#!${pkgs.runtimeShell}
set -euo pipefail
${pretalx}/bin/pretalx collectstatic --noinput
exec ${gunicorn}/bin/gunicorn pretalx.wsgi --name ${name} \
--workers 3 \
--log-level=info \
--bind=${server.bind}:${server.port}
'';
};
wantedBy = [ "multi-user.target" ];
requires = [ "pretalx-migrate.service" ];
after = [ "network.target" ];
};
wantedBy = [ "multi-user.target" ];
requires = [ "pretalx-migrate.service" ];
after = [ "network.target" ];
};

systemd.services.pretalx-clearsessions = {
description = "Pretalx clear sessions";
serviceConfig = {
Type = "oneshot";
EnvironmentFile = environmentFile;
User = user;
systemd.services.pretalx-clearsessions = {
description = "Pretalx clear sessions";
serviceConfig = {
Type = "oneshot";
EnvironmentFile = environmentFile;
User = user;
};
script = "${pretalx}/bin/pretalx clearsessions";
};
script = "${pretalx}/bin/pretalx clearsessions";
};

systemd.services.pretalx-runperiodic = {
description = "Pretalx periodic tasks";
serviceConfig = {
Type = "oneshot";
EnvironmentFile = environmentFile;
User = user;
systemd.services.pretalx-runperiodic = {
description = "Pretalx periodic tasks";
serviceConfig = {
Type = "oneshot";
EnvironmentFile = environmentFile;
User = user;
};
script = "${pretalx}/bin/pretalx runperiodic";
};
script = "${pretalx}/bin/pretalx runperiodic";
};

# About once a month
systemd.timers.pretalx-clearsessions = mkTimer {
description = "Clear pretalx sessions";
unit = "pretalx-clearsessions.service";
onCalendar = "monthly";
};

# Once every 5 minutes
systemd.timers.pretalx-runperiodic = mkTimer {
description = "Run pretalx tasks";
unit = "pretalx-runperiodic.service";
onCalendar = "*:0/5";
};


systemd.services.pretalx = {
description = "Pretalx Server";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
environment.PRETALX_CONFIG_FILE = pretalxCfgFile;
path = [ ];
# preStart = ''
# cat ${pretalxCfgFile}
# '';
serviceConfig = {
# ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
# User = "postgres";
# Group = "postgres";
# RuntimeDirectory = "postgresql";
Type = "simple";
# About once a month
systemd.timers.pretalx-clearsessions = mkTimer {
description = "Clear pretalx sessions";
unit = "pretalx-clearsessions.service";
onCalendar = "monthly";
};

ExecStart = "cat ${pretalxCfgFile}";
};
# Once every 5 minutes
systemd.timers.pretalx-runperiodic = mkTimer {
description = "Run pretalx tasks";
unit = "pretalx-runperiodic.service";
onCalendar = "*:0/5";
};
};
}
18 changes: 6 additions & 12 deletions tests/pretalx/pretalx.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ngipkgsModule
];

networking.firewall.allowedTCPPorts = [ 80 ];
networking.firewall.allowedTCPPorts = [ 8001 ];

services.pretalx = {
enable = true;
Expand Down Expand Up @@ -50,24 +50,18 @@
'';
};
};

# client = {
# imports = [
# ];
# };
};

testScript = { nodes, ... }: ''
start_all()
with subtest("Test http service"):
server.wait_for_unit("pretalx.service")
server.wait_for_unit("pretalx-web.service")
server.execute("cat /var/lib/pretalx/pretalx.cfg")
server.execute("journalctl -u pretalx")
# NOTE: Use `server.execute("...")` to execute commands.
# client.succeed("""
# curl --fail http://server:80/test.txtx | grep test
# """)
server.succeed("""
curl --fail --connect-timeout 10 http://localhost:8001/
""")
'';
}

0 comments on commit f4af99d

Please sign in to comment.