aboutsummaryrefslogtreecommitdiff
path: root/modules/private/databases
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2021-10-13 02:26:54 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2021-10-16 01:39:24 +0200
commitda30ae4ffdd153a1eb32fb86f9ca9a65aa19e4e2 (patch)
treebd45012713b065829c1991e55d52081a8baef58a /modules/private/databases
parentbd5c5d4e23ebd3863a960976767ed4a83dfd07fe (diff)
downloadNix-da30ae4ffdd153a1eb32fb86f9ca9a65aa19e4e2.tar.gz
Nix-da30ae4ffdd153a1eb32fb86f9ca9a65aa19e4e2.tar.zst
Nix-da30ae4ffdd153a1eb32fb86f9ca9a65aa19e4e2.zip
Move secrets to flakes
Diffstat (limited to 'modules/private/databases')
-rw-r--r--modules/private/databases/mariadb.nix8
-rw-r--r--modules/private/databases/mariadb_replication.nix6
-rw-r--r--modules/private/databases/openldap/default.nix15
-rw-r--r--modules/private/databases/openldap_replication.nix2
-rw-r--r--modules/private/databases/postgresql.nix8
-rw-r--r--modules/private/databases/redis.nix6
-rw-r--r--modules/private/databases/redis_replication.nix4
7 files changed, 28 insertions, 21 deletions
diff --git a/modules/private/databases/mariadb.nix b/modules/private/databases/mariadb.nix
index 36edaeb..75ea747 100644
--- a/modules/private/databases/mariadb.nix
+++ b/modules/private/databases/mariadb.nix
@@ -169,14 +169,14 @@ in {
169 mysql = { 169 mysql = {
170 text = '' 170 text = ''
171 # https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/ 171 # https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/
172 auth required ${pam_ldap} config=${config.secrets.location}/mysql/pam 172 auth required ${pam_ldap} config=${config.secrets.fullPaths."mysql/pam"}
173 account required ${pam_ldap} config=${config.secrets.location}/mysql/pam 173 account required ${pam_ldap} config=${config.secrets.fullPaths."mysql/pam"}
174 ''; 174 '';
175 }; 175 };
176 mysql_replication = { 176 mysql_replication = {
177 text = '' 177 text = ''
178 auth required ${pam_ldap} config=${config.secrets.location}/mysql/pam_replication 178 auth required ${pam_ldap} config=${config.secrets.fullPaths."mysql/pam_replication"}
179 account required ${pam_ldap} config=${config.secrets.location}/mysql/pam_replication 179 account required ${pam_ldap} config=${config.secrets.fullPaths."mysql/pam_replication"}
180 ''; 180 '';
181 }; 181 };
182 }; 182 };
diff --git a/modules/private/databases/mariadb_replication.nix b/modules/private/databases/mariadb_replication.nix
index b89c764..e857c41 100644
--- a/modules/private/databases/mariadb_replication.nix
+++ b/modules/private/databases/mariadb_replication.nix
@@ -140,7 +140,7 @@ in
140 140
141 filename=${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).sql 141 filename=${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).sql
142 ${hcfg.package}/bin/mysqldump \ 142 ${hcfg.package}/bin/mysqldump \
143 --defaults-file=${config.secrets.location}/mysql_replication/${name}/mysqldump \ 143 --defaults-file=${config.secrets.fullPaths."mysql_replication/${name}/mysqldump"} \
144 -S /run/mysqld_${name}/mysqld.sock \ 144 -S /run/mysqld_${name}/mysqld.sock \
145 --gtid \ 145 --gtid \
146 --master-data \ 146 --master-data \
@@ -194,7 +194,7 @@ in
194 if ! test -e ${dataDir}/mysql; then 194 if ! test -e ${dataDir}/mysql; then
195 if ! test -e ${dataDir}/initial.sql; then 195 if ! test -e ${dataDir}/initial.sql; then
196 ${hcfg.package}/bin/mysqldump \ 196 ${hcfg.package}/bin/mysqldump \
197 --defaults-file=${config.secrets.location}/mysql_replication/${name}/mysqldump_remote \ 197 --defaults-file=${config.secrets.fullPaths."mysql_replication/${name}/mysqldump_remote"} \
198 -h ${hcfg.host} \ 198 -h ${hcfg.host} \
199 -P ${hcfg.port} \ 199 -P ${hcfg.port} \
200 --ssl \ 200 --ssl \
@@ -235,7 +235,7 @@ in
235 cat \ 235 cat \
236 ${sql_before} \ 236 ${sql_before} \
237 ${dataDir}/initial.sql \ 237 ${dataDir}/initial.sql \
238 ${config.secrets.location}/mysql_replication/${name}/slave_init_commands \ 238 ${config.secrets.fullPaths."mysql_replication/${name}/slave_init_commands"} \
239 | ${hcfg.package}/bin/mysql \ 239 | ${hcfg.package}/bin/mysql \
240 --defaults-file=/etc/mysql/${name}_my.cnf \ 240 --defaults-file=/etc/mysql/${name}_my.cnf \
241 -S /run/mysqld_${name}/mysqld.sock \ 241 -S /run/mysqld_${name}/mysqld.sock \
diff --git a/modules/private/databases/openldap/default.nix b/modules/private/databases/openldap/default.nix
index e00f4c2..f4851b5 100644
--- a/modules/private/databases/openldap/default.nix
+++ b/modules/private/databases/openldap/default.nix
@@ -98,7 +98,14 @@ in
98 permissions = "0400"; 98 permissions = "0400";
99 user = "openldap"; 99 user = "openldap";
100 group = "openldap"; 100 group = "openldap";
101 text = builtins.readFile "${cfg.accessFile}"; 101 text = builtins.readFile cfg.accessFile;
102 }
103 {
104 dest = "ldap";
105 permissions = "0500";
106 user = "openldap";
107 group = "openldap";
108 isDir = true;
102 } 109 }
103 ]; 110 ];
104 users.users.openldap.extraGroups = [ "keys" ]; 111 users.users.openldap.extraGroups = [ "keys" ];
@@ -115,7 +122,7 @@ in
115 122
116 services.filesWatcher.openldap = { 123 services.filesWatcher.openldap = {
117 restart = true; 124 restart = true;
118 paths = [ "${config.secrets.location}/ldap/" ]; 125 paths = [ config.secrets.fullPaths."ldap" ];
119 }; 126 };
120 127
121 services.openldap = { 128 services.openldap = {
@@ -132,9 +139,9 @@ in
132 overlay syncprov 139 overlay syncprov
133 syncprov-checkpoint 100 10 140 syncprov-checkpoint 100 10
134 141
135 include ${config.secrets.location}/ldap/access 142 include ${config.secrets.fullPaths."ldap/access"}
136 ''; 143 '';
137 rootpwFile = "${config.secrets.location}/ldap/password"; 144 rootpwFile = config.secrets.fullPaths."ldap/password";
138 suffix = cfg.baseDn; 145 suffix = cfg.baseDn;
139 rootdn = cfg.rootDn; 146 rootdn = cfg.rootDn;
140 database = "hdb"; 147 database = "hdb";
diff --git a/modules/private/databases/openldap_replication.nix b/modules/private/databases/openldap_replication.nix
index df4101b..350eecf 100644
--- a/modules/private/databases/openldap_replication.nix
+++ b/modules/private/databases/openldap_replication.nix
@@ -23,7 +23,7 @@ let
23 index uid pres,eq 23 index uid pres,eq
24 index entryUUID eq 24 index entryUUID eq
25 25
26 include ${config.secrets.location}/openldap_replication/${name}/replication_config 26 include ${config.secrets.fullPaths."openldap_replication/${name}/replication_config"}
27 ''; 27 '';
28in 28in
29{ 29{
diff --git a/modules/private/databases/postgresql.nix b/modules/private/databases/postgresql.nix
index c442a63..e73bf69 100644
--- a/modules/private/databases/postgresql.nix
+++ b/modules/private/databases/postgresql.nix
@@ -214,14 +214,14 @@ in {
214 in { 214 in {
215 postgresql = { 215 postgresql = {
216 text = '' 216 text = ''
217 auth required ${pam_ldap} config=${config.secrets.location}/postgresql/pam 217 auth required ${pam_ldap} config=${config.secrets.fullPaths."postgresql/pam"}
218 account required ${pam_ldap} config=${config.secrets.location}/postgresql/pam 218 account required ${pam_ldap} config=${config.secrets.fullPaths."postgresql/pam"}
219 ''; 219 '';
220 }; 220 };
221 postgresql_replication = { 221 postgresql_replication = {
222 text = '' 222 text = ''
223 auth required ${pam_ldap} config=${config.secrets.location}/postgresql/pam_replication 223 auth required ${pam_ldap} config=${config.secrets.fullPaths."postgresql/pam_replication"}
224 account required ${pam_ldap} config=${config.secrets.location}/postgresql/pam_replication 224 account required ${pam_ldap} config=${config.secrets.fullPaths."postgresql/pam_replication"}
225 ''; 225 '';
226 }; 226 };
227 }; 227 };
diff --git a/modules/private/databases/redis.nix b/modules/private/databases/redis.nix
index bc6460f..5c5b8b0 100644
--- a/modules/private/databases/redis.nix
+++ b/modules/private/databases/redis.nix
@@ -49,7 +49,7 @@ in {
49 decrypt = true; 49 decrypt = true;
50 source = "0.0.0.0:16379"; 50 source = "0.0.0.0:16379";
51 target = "/run/redis/redis.sock"; 51 target = "/run/redis/redis.sock";
52 keyfile = "${config.secrets.location}/redis/spiped_keyfile"; 52 keyfile = config.secrets.fullPaths."redis/spiped_keyfile";
53 }; 53 };
54 }; 54 };
55 systemd.services.spiped_redis = { 55 systemd.services.spiped_redis = {
@@ -70,7 +70,7 @@ in {
70 70
71 services.filesWatcher.predixy = { 71 services.filesWatcher.predixy = {
72 restart = true; 72 restart = true;
73 paths = [ "${config.secrets.location}/redis/predixy.conf" ]; 73 paths = [ config.secrets.fullPaths."redis/predixy.conf" ];
74 }; 74 };
75 75
76 networking.firewall.allowedTCPPorts = [ 7617 16379 ]; 76 networking.firewall.allowedTCPPorts = [ 7617 16379 ];
@@ -126,7 +126,7 @@ in {
126 SupplementaryGroups = "keys"; 126 SupplementaryGroups = "keys";
127 Type = "simple"; 127 Type = "simple";
128 128
129 ExecStart = "${pkgs.predixy}/bin/predixy ${config.secrets.location}/redis/predixy.conf"; 129 ExecStart = "${pkgs.predixy}/bin/predixy ${config.secrets.fullPaths."redis/predixy.conf"}";
130 }; 130 };
131 131
132 }; 132 };
diff --git a/modules/private/databases/redis_replication.nix b/modules/private/databases/redis_replication.nix
index a3fe3bb..3caa7e9 100644
--- a/modules/private/databases/redis_replication.nix
+++ b/modules/private/databases/redis_replication.nix
@@ -64,7 +64,7 @@ in
64 encrypt = true; 64 encrypt = true;
65 source = "127.0.0.1:16379"; 65 source = "127.0.0.1:16379";
66 target = "${config.myEnv.servers.eldiron.ips.main.ip4}:16379"; 66 target = "${config.myEnv.servers.eldiron.ips.main.ip4}:16379";
67 keyfile = "${config.secrets.location}/redis/spiped_eldiron_keyfile"; 67 keyfile = config.secrets.fullPaths."redis/spiped_eldiron_keyfile";
68 }; 68 };
69 }; 69 };
70 70
@@ -162,7 +162,7 @@ in
162 unitConfig.RequiresMountsFor = dataDir; 162 unitConfig.RequiresMountsFor = dataDir;
163 163
164 serviceConfig = { 164 serviceConfig = {
165 ExecStart = "${hcfg.package}/bin/redis-server ${config.secrets.location}/redis_replication/${name}/config"; 165 ExecStart = "${hcfg.package}/bin/redis-server ${config.secrets.fullPaths."redis_replication/${name}/config"}";
166 User = "redis"; 166 User = "redis";
167 RuntimeDirectory = "redis_${name}"; 167 RuntimeDirectory = "redis_${name}";
168 }; 168 };