Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 1e0d442

Browse files
committed
Affine
1 parent 8575162 commit 1e0d442

File tree

9 files changed

+123
-33
lines changed

9 files changed

+123
-33
lines changed

machines/chaos/default.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@
5353
custom = {
5454
sshd.enable = true;
5555
bash.enable = true;
56-
docker.enable = true;
56+
docker = {
57+
enable = true;
58+
storageDriver = "zfs";
59+
};
5760
dwarffortress.enable = false;
5861
git.enable = true;
5962
gnupg.enable = true;

machines/space/default.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,20 @@ in
6666
autoupgrade.enable = true;
6767
autoupgrade.allowReboot = true;
6868

69+
docker.enable = true;
6970
bash.enable = true;
7071
neovim.enable = true;
7172
sshd.enable = true;
7273

7374
tailscale.enable = true;
7475

76+
affine = {
77+
enable = true;
78+
hostname = "affine.rxn.be";
79+
version = "v0.22.4";
80+
hash = "sha256-0P4ARWXejLshpgIuTKR/BSAGKG0DDz4dxboCyGOaH7A=";
81+
};
82+
7583
actual = {
7684
enable = false;
7785
basicAuthFile = "/run/agenix/actual-auth";

machines/space/postfix-sasl.age

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
age-encryption.org/v1
2-
-> ssh-ed25519 DBh0Pw joYkkNlATYOieN0I2iwLnvOTgfgcWhseGKiYUFPLWWY
3-
wOd5PL/6m2ehMIP3OQt+8f9cptJ3zC32Cd6iE5RF8Do
4-
-> ssh-ed25519 Wam86A j7tveTvyPXjkPWhPfpm7DH8r4Li+UM3EMvrr70NALG8
5-
NfQdZselJCKQM7WvvgNiI6YZdUfxSvJ7LWJaYf/ptaI
6-
--- 1BO5qeIjyRMYY7bcmDBDmU/w8D+TwbqAOJmzBZ5iEKs
7-
����`�[�6v���/���~������E��ķ/yF�sИ���[�~~@|���
8-
{{�gE�
2+
-> ssh-ed25519 DBh0Pw +Up6vR3BunnB7By1jQadmQ9Cp6DHPy6p2oO1EHhWbTM
3+
iC1OkWG2E4JWdeAsHBECCHJGrdxKmXuKZmryWF0aLMQ
4+
-> ssh-ed25519 Wam86A EbsB3xUu2aWP+E28Ib3M0spyeBDlKUGxVxagQj32S0k
5+
ZR4CSETwhBd0c6wx3w7jwMD6M0YO62dkdzQAnSPq2E0
6+
--- l6taRi0o86nFepdsyHwsNuF3eeau5vCPiV3vMxTAJZk
7+
C������������whB�W:�����^���{�ٛ@�"��CD��7!�b����
8+
��)��

machines/space/static-sites.nix

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,6 @@ in {
2525
locations."/" = {
2626
return = "200 \"\\n███████╗ ██████╗ █████╗ ██████╗ ███████╗\\n██╔════╝ ██╔══██╗ ██╔══██╗ ██╔════╝ ██╔════╝\\n███████╗ ██████╔╝ ███████║ ██║ █████╗\\n╚════██║ ██╔═══╝ ██╔══██║ ██║ ██╔══╝\\n███████║ ██║ ██║ ██║ ╚██████╗ ███████╗\\n╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝\\n\"";
2727
};
28-
locations."/hupseflupse/" = {
29-
basicAuthFile = "/run/agenix/static-sites-auth";
30-
alias = "/srv/webhost/rxn.be/";
31-
};
32-
locations."/weday" = {
33-
return = "302 https://ugent.qualtrics.com/jfe/form/SV_1zUwuxySVuSntfU";
34-
};
35-
locations."/iticse" = {
36-
return = "302 https://drive.google.com/file/d/1_PJbr7Lq8MfSSTcYtjkxxf3M0QPoCdfW/view?usp=sharing
37-
";
38-
};
39-
locations."/wedaypres".return = "302 https://ugentbe-my.sharepoint.com/:p:/g/personal/rien_maertens_ugent_be/EXWlCsoB6rZEgaa5qeSYU3MBgb4lsNIhaYsCLgqmWWMgJQ?e=6AARfM";
40-
locations."/brief" = {
41-
return = "302 https://theatervolta.be/weekend/brief";
42-
};
4328
};
4429
"rien.rxn.be" = {
4530
useACMEHost = "rxn.be";

modules/affine/default.nix

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{ config, pkgs, lib, util, ... }:
2+
3+
let cfg = config.custom.affine;
4+
in {
5+
options.custom.affine = {
6+
enable = lib.mkEnableOption "Affine Server";
7+
8+
hostname = lib.mkOption {
9+
example = "example.com";
10+
};
11+
12+
version = lib.mkOption {
13+
example = "v0.22.4";
14+
};
15+
16+
hash = lib.mkOption {
17+
example = "";
18+
};
19+
20+
port = lib.mkOption {
21+
type = lib.types.int;
22+
default = 3010;
23+
};
24+
25+
backupLocation = lib.mkOption {
26+
example = "/data/affine-backups";
27+
};
28+
29+
stateDir = lib.mkOption {
30+
type = lib.types.str;
31+
default = "/var/lib/affine";
32+
description = "Directory for user files";
33+
};
34+
};
35+
36+
config = let
37+
compose-file = pkgs.fetchurl {
38+
url = "https://github.com/toeverything/affine/releases/download/${cfg.version}/docker-compose.yml";
39+
hash = cfg.hash;
40+
};
41+
env-file = pkgs.writeTextFile {
42+
name = ".env";
43+
text = ''
44+
PORT="${toString cfg.port}"
45+
DB_DATA_LOCATION="${cfg.stateDir}/postgres"
46+
UPLOAD_LOCATION="${cfg.stateDir}/storage"
47+
CONFIG_LOCATION="${cfg.stateDir}/compose"
48+
DB_USERNAME="affine"
49+
DB_PASSWORD="affine"
50+
DB_DATABASE="affine"
51+
'';
52+
};
53+
in lib.mkIf cfg.enable {
54+
55+
systemd.tmpfiles.rules = [
56+
"d ${cfg.stateDir}/postgres - - - - -"
57+
"d ${cfg.stateDir}/storage - - - - -"
58+
"d ${cfg.stateDir}/compose - - - - -"
59+
"L+ ${cfg.stateDir}/compose/.env - - - - ${env-file}"
60+
"L+ ${cfg.stateDir}/compose/docker-compose.yml - - - - ${compose-file}"
61+
];
62+
63+
systemd.services.affine-server = {
64+
description = "Affine Server";
65+
after = [ "network.target" ];
66+
wantedBy = [ "multi-user.target" ];
67+
environment = {
68+
};
69+
serviceConfig = {
70+
WorkingDirectory = "${cfg.stateDir}/compose";
71+
ExecStart = "${pkgs.docker}/bin/docker compose up --pull always";
72+
Restart = "always";
73+
StateDirectory = "affine";
74+
DynamicUser = true;
75+
SupplementaryGroups="docker";
76+
};
77+
};
78+
79+
services.nginx.virtualHosts.${cfg.hostname} = {
80+
forceSSL = true;
81+
useACMEHost = util.baseDomain cfg.hostname;
82+
locations."/" = {
83+
proxyPass = "http://localhost:${toString cfg.port}";
84+
};
85+
};
86+
};
87+
}

modules/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ in {
66
imports = [
77
./autoupgrade.nix
88
./actual.nix
9+
./affine
910
./bash.nix
1011
./docker.nix
1112
./dodona-mailer

modules/docker.nix

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,21 @@ with lib;
33
let
44
cfg = config.custom.docker;
55
in {
6-
options.custom.docker.enable = mkOption {
7-
default = false;
8-
example = true;
6+
options.custom.docker = {
7+
enable = mkOption {
8+
default = false;
9+
example = true;
10+
};
11+
storageDriver = mkOption {
12+
default = "overlay2";
13+
};
914
};
1015

16+
1117
config = mkIf cfg.enable {
1218
virtualisation.docker = {
1319
enable = true;
14-
extraOptions = "--experimental";
15-
storageDriver = "zfs";
20+
storageDriver = cfg.storageDriver;
1621
};
1722
programs.criu.enable = true;
1823
systemd.services.docker.path = [ pkgs.gzip pkgs.gnutar pkgs.criu ];

modules/postfix/default.nix

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@ in
7474
domain = host;
7575
networksStyle = "host";
7676

77-
sslCert = "/var/lib/acme/${ util.baseDomain host }/fullchain.pem";
78-
sslKey = "/var/lib/acme/${ util.baseDomain host }/key.pem";
79-
8077
config = {
8178
smtp_tls_security_level = "may";
79+
smtpd_tls_chain_files = [
80+
"/var/lib/acme/${ util.baseDomain host }/key.pem"
81+
"/var/lib/acme/${ util.baseDomain host }/fullchain.pem"
82+
];
8283
};
8384

8485
enableSmtp = true; # Receiving mail from other mail servers

rebuild.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if [[ -n "$1" && ! "$1" =~ ^-.* ]]; then
44
shift
55
fi
66
if [ -z "$host" ]; then
7-
sudo nixos-rebuild switch -v --flake '.#' "$@"
7+
sudo nixos-rebuild switch --flake '.#' "$@"
88
else
9-
nixos-rebuild -v --flake ".#$host" --target-host "root@$host" switch "$@"
9+
nixos-rebuild --flake ".#$host" --target-host "root@$host" switch "$@"
1010
fi

0 commit comments

Comments
 (0)