nixos/geoipupdate: Create database directory in a separate unit

The database directory needs to be created before the
geoipupdate.service unit is activated; otherwise, systemd will not be
able to set up the mount namespacing to grant the service read-write
access.

talyz ba4d2bd0 7cf55d1f

Changed files
+14 -3
nixos
modules
services
+14 -3
nixos/modules/services/misc/geoipupdate.nix
···
LockFile = "/run/geoipupdate/.lock";
};
+
systemd.services.geoipupdate-create-db-dir = {
+
serviceConfig.Type = "oneshot";
+
script = ''
+
mkdir -p ${cfg.settings.DatabaseDirectory}
+
chmod 0755 ${cfg.settings.DatabaseDirectory}
+
'';
+
};
+
systemd.services.geoipupdate = {
description = "GeoIP Updater";
-
after = [ "network-online.target" "nss-lookup.target" ];
+
requires = [ "geoipupdate-create-db-dir.service" ];
+
after = [
+
"geoipupdate-create-db-dir.service"
+
"network-online.target"
+
"nss-lookup.target"
+
];
wants = [ "network-online.target" ];
startAt = cfg.interval;
serviceConfig = {
···
geoipupdateConf = pkgs.writeText "geoipupdate.conf" (geoipupdateKeyValue cfg.settings);
script = ''
-
mkdir -p "${cfg.settings.DatabaseDirectory}"
-
chmod 755 "${cfg.settings.DatabaseDirectory}"
chown geoip "${cfg.settings.DatabaseDirectory}"
cp ${geoipupdateConf} /run/geoipupdate/GeoIP.conf