Skip to content

Commit

Permalink
Merge pull request #38 from ngi-nix/algae-pretalx
Browse files Browse the repository at this point in the history
Add pretalx and refactor `flake.nix`
  • Loading branch information
andres-nav authored Aug 23, 2023
2 parents ab5adea + d77172a commit 0893452
Show file tree
Hide file tree
Showing 25 changed files with 2,462 additions and 62 deletions.
14 changes: 14 additions & 0 deletions all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@
liberaforms-env = callPackage ./pkgs/liberaforms/env.nix {};
libgnunetchat = callPackage ./pkgs/libgnunetchat {};
librecast = callPackage ./pkgs/librecast {inherit lcrq;};
pretalx-mysql = callPackage ./pkgs/pretalx {
withMysql = true;
withRedis = true;
};
pretalx-postgresql = callPackage ./pkgs/pretalx {
withPostgresql = true;
withRedis = true;
};
pretalx = callPackage ./pkgs/pretalx {
withMysql = true;
withPostgresql = true;
withRedis = true;
withTest = true;
};
};

nixpkgs-candidates = {
Expand Down
14 changes: 13 additions & 1 deletion configs/all-configurations.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
{pkgs}: {
{
liberaforms-container = import ./liberaforms/container.nix;
pretalx-postgresql = {
imports = [
./pretalx/pretalx.nix
./pretalx/postgresql.nix
];
};
pretalx-mysql = {
imports = [
./pretalx/pretalx.nix
./pretalx/mysql.nix
];
};
}
10 changes: 3 additions & 7 deletions configs/liberaforms/container.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{
pkgs,
lib,
...
}: {
imports = [../../modules/liberaforms.nix];

{...}: {
boot.isContainer = true;

networking.useDHCP = false;
Expand All @@ -26,4 +20,6 @@
};

system.stateVersion = "22.11";

nixpkgs.hostPlatform = "x86_64-linux";
}
24 changes: 24 additions & 0 deletions configs/pretalx/mysql.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
config,
pkgs,
...
}: {
services = {
pretalx.database = {
backend = "mysql";
host = "/var/run/mysqld/mysqld.sock";
};

mysql = {
enable = true;
package = pkgs.mysql;
ensureUsers = [
{
name = config.services.pretalx.database.user;
ensurePermissions."${config.services.pretalx.database.name}.*" = "ALL PRIVILEGES";
}
];
ensureDatabases = [config.services.pretalx.database.name];
};
};
}
17 changes: 17 additions & 0 deletions configs/pretalx/postgresql.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{config, ...}: {
services = {
pretalx.database.backend = "postgresql";

postgresql = {
enable = true;
authentication = "local all all trust";
ensureUsers = [
{
name = config.services.pretalx.database.user;
ensurePermissions."DATABASE \"${config.services.pretalx.database.name}\"" = "ALL PRIVILEGES";
}
];
ensureDatabases = [config.services.pretalx.database.name];
};
};
}
84 changes: 84 additions & 0 deletions configs/pretalx/pretalx.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
config,
pkgs,
...
}: {
imports = [
./vm.nix
];

nixpkgs.hostPlatform = "x86_64-linux";

networking = {
firewall.allowedTCPPorts = [config.services.nginx.defaultHTTPListenPort];
hostName = "server";
domain = "example.com";
};

sops = {
secrets = let
pretalxSecret = {
# For a production configuration also `sopsFile` is required.
# See <https://github.com/Mic92/sops-nix>.
owner = config.services.pretalx.user;
group = config.services.pretalx.group;
};
in {
"pretalx/database/password" = pretalxSecret;
"pretalx/redis/location" = pretalxSecret;
"pretalx/init/admin/password" = pretalxSecret;
"pretalx/celery/backend" = pretalxSecret;
"pretalx/celery/broker" = pretalxSecret;
};
};

services = {
pretalx = {
enable = true;
package = pkgs.pretalx;
nginx = {
# For a production configuration use this attribute set to configure the virtual host for pretalx.
};
database = {
user = "pretalx";
passwordFile = config.sops.secrets."pretalx/database/password".path;
};
redis = {
enable = true;
locationFile = config.sops.secrets."pretalx/redis/location".path;
};
celery = {
enable = true;
backendFile = config.sops.secrets."pretalx/celery/backend".path;
brokerFile = config.sops.secrets."pretalx/celery/broker".path;
};

init = {
admin = {
email = "pretalx@localhost";
passwordFile = config.sops.secrets."pretalx/init/admin/password".path;
};
organiser = {
name = "NGI Packages";
slug = "ngipkgs";
};
};
mail.enable = false;
};

redis.servers."pretalx" = {
enable = true;
user = config.services.pretalx.user;
};

nginx = {
enable = true;
recommendedTlsSettings = true;
recommendedOptimisation = true;
recommendedGzipSettings = true;
recommendedProxySettings = true;
};
};

system.stateVersion = "22.11";
}
10 changes: 10 additions & 0 deletions configs/pretalx/vm.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{modulesPath, ...}: {
imports = [
"${modulesPath}/virtualisation/qemu-vm.nix"
];

sops = {
age.keyFile = ./postgresql.nix;
defaultSopsFile = ./postgresql.nix;
};
}
38 changes: 38 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0893452

Please sign in to comment.