]>
Commit | Line | Data |
---|---|---|
8415083e | 1 | { privateFiles }: |
258dd18b | 2 | { config, pkgs, resources, name, ... }: |
8415083e | 3 | { |
34abd6af IB |
4 | deployment = { |
5 | targetUser = "root"; | |
6 | targetHost = config.hostEnv.ips.main.ip4; | |
7 | substituteOnDestination = true; | |
8 | }; | |
8415083e | 9 | boot.kernelPackages = pkgs.linuxPackages_latest; |
ab8f306d | 10 | myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; }; |
ab8f306d | 11 | |
34abd6af | 12 | imports = [ <nixpkgs/nixos/modules/profiles/qemu-guest.nix> ] ++ builtins.attrValues (import ../..); |
8415083e | 13 | |
ae485806 IB |
14 | fileSystems = { |
15 | "/backup2" = { | |
16 | fsType = "ext4"; | |
17 | device = "UUID=b9425333-f567-435d-94d8-b26c22d93426"; | |
18 | }; | |
34abd6af | 19 | "/" = { device = "/dev/sda1"; fsType = "ext4"; }; |
ae485806 IB |
20 | }; |
21 | ||
22 | networking = { | |
23 | firewall.enable = true; | |
24 | interfaces."ens3".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList | |
25 | (n: ips: { address = ips.ip4; prefixLength = 32; }) | |
619e4f46 | 26 | (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips); |
ae485806 IB |
27 | interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList |
28 | (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or [])) | |
619e4f46 | 29 | config.hostEnv.ips); |
dc0e644a | 30 | defaultGateway6 = { address = "fe80::1"; interface = "ens3"; }; |
285380fe IB |
31 | }; |
32 | ||
34abd6af IB |
33 | boot.loader.grub.device = "nodev"; |
34 | ||
619e4f46 | 35 | myServices.certificates.enable = true; |
258dd18b IB |
36 | security.acme.certs."${name}" = { |
37 | user = config.services.nginx.user; | |
38 | group = config.services.nginx.group; | |
39 | }; | |
619e4f46 IB |
40 | services.nginx = { |
41 | enable = true; | |
42 | recommendedOptimisation = true; | |
43 | recommendedGzipSettings = true; | |
44 | recommendedProxySettings = true; | |
45 | }; | |
46 | networking.firewall.allowedTCPPorts = [ 80 443 ]; | |
47 | ||
4227853a IB |
48 | services.cron = { |
49 | mailto = "cron@immae.eu"; | |
50 | enable = true; | |
51 | }; | |
52 | ||
285380fe IB |
53 | services.rsyncBackup = { |
54 | mountpoint = "/backup2"; | |
ab8f306d IB |
55 | profiles = config.myEnv.rsync_backup.profiles; |
56 | ssh_key_public = config.myEnv.rsync_backup.ssh_key.public; | |
57 | ssh_key_private = config.myEnv.rsync_backup.ssh_key.private; | |
ae485806 IB |
58 | }; |
59 | ||
deca5e9b | 60 | myServices.mailRelay.enable = true; |
619e4f46 | 61 | myServices.mailBackup.enable = true; |
9f202523 | 62 | myServices.monitoring.enable = true; |
ec9b6564 IB |
63 | myServices.databasesReplication = { |
64 | postgresql = { | |
65 | enable = true; | |
66 | base = "/backup2"; | |
9f16e659 | 67 | mainPackage = pkgs.postgresql; |
ec9b6564 IB |
68 | hosts = { |
69 | eldiron = { | |
70 | slot = "backup_2"; | |
619e4f46 | 71 | connection = "postgresql://backup-2:${config.hostEnv.ldap.password}@eldiron.immae.eu"; |
9f16e659 | 72 | package = pkgs.postgresql; |
ec9b6564 IB |
73 | }; |
74 | }; | |
75 | }; | |
9f6a7862 IB |
76 | mariadb = { |
77 | enable = true; | |
78 | base = "/backup2"; | |
79 | hosts = { | |
80 | eldiron = { | |
81 | serverId = 2; | |
82 | # mysql resolves "backup-2" host and checks the ip, but uses /etc/hosts which only contains ip4 | |
ab8f306d | 83 | host = config.myEnv.servers.eldiron.ips.main.ip4; |
9f6a7862 IB |
84 | port = "3306"; |
85 | user = "backup-2"; | |
619e4f46 | 86 | password = config.hostEnv.ldap.password; |
9f6a7862 | 87 | dumpUser = "root"; |
ab8f306d | 88 | dumpPassword = config.myEnv.databases.mysql.systemUsers.root; |
9f6a7862 IB |
89 | }; |
90 | }; | |
91 | }; | |
dded6699 IB |
92 | redis = { |
93 | enable = true; | |
94 | base = "/backup2"; | |
95 | hosts = { | |
96 | eldiron = { | |
97 | host = "127.0.0.1"; | |
98 | port = "16379"; | |
99 | }; | |
100 | }; | |
101 | }; | |
16b80abd IB |
102 | openldap = { |
103 | enable = true; | |
104 | base = "/backup2"; | |
105 | hosts = { | |
106 | eldiron = { | |
ab8f306d IB |
107 | url = "ldaps://${config.myEnv.ldap.host}:636"; |
108 | dn = config.myEnv.ldap.replication_dn; | |
109 | password = config.myEnv.ldap.replication_pw; | |
110 | base = config.myEnv.ldap.base; | |
16b80abd IB |
111 | }; |
112 | }; | |
113 | }; | |
ec9b6564 IB |
114 | }; |
115 | ||
8415083e IB |
116 | # This value determines the NixOS release with which your system is |
117 | # to be compatible, in order to avoid breaking some software such as | |
118 | # database servers. You should change this only after NixOS release | |
119 | # notes say you should. | |
120 | # https://nixos.org/nixos/manual/release-notes.html | |
d43e0c61 | 121 | system.stateVersion = "20.03"; # Did you read the comment? |
8415083e | 122 | } |