This repository has been archived by the owner on Jun 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bridge.nix
66 lines (56 loc) · 1.47 KB
/
bridge.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ config, pkgs, inputs, ... }:
let
profiles = "/nix/var/nix/profiles/per-user/deploy";
dbname = "bridge";
cfg = config.services.bridge.backend;
user = "bridge";
service = "bridge";
in {
imports = [ inputs.bridge-web.nixosModules.combined ];
networking.firewall.allowedTCPPorts = [ 80 443 ];
users.users.deploy = {
isNormalUser = true;
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIImSq6l4MAGrbI3AyGa6JvP5wE0JtYBrXE52eISoJ8PA bridge-web"
];
};
security.sudo.extraRules = [{
users = [ "deploy" ];
commands = [
{
command = "/run/current-system/sw/bin/systemctl restart bridge";
options = [ "NOPASSWD" ];
}
];
}];
vault-secrets.secrets.${service} = {
inherit user;
};
services.postgresql = {
enable = true;
package = pkgs.postgresql_12;
ensureUsers = map (name: {
inherit name;
ensurePermissions = { "DATABASE \"${dbname}\"" = "ALL"; };
}) [ "gromak" "sashasashasasha151" "martoon" ];
};
systemd.services.bridge.serviceConfig = {
RuntimeMaxSec = 86400;
Restart = "always";
};
services.nginx.addSecurityHeaders = false;
services.bridge = {
enable = true;
frontend = {
package = "${profiles}/frontend";
};
backend = {
package = "${profiles}/backend";
secretFile = "${config.vault-secrets.secrets.${service}}/environment";
serviceName = service;
config = {
};
inherit user;
};
};
}