nixpkgs/nixos/modules/services/misc
Bjørn Forsman 824d82fa0f nixos/geoip-updater: new service
The GeoIP databases from MaxMind have no stable URLs and change every
month (or so). Our current method of packaging these database in Nix and
playing catch-up with ever-changing file hashes is a bad idea. For
instance, it makes it impossible to realize old NixOS configurations.

This patch adds a NixOS service that periodically updates the GeoIP
databases in /var/lib/geoip-databases. Moving NixOS modules over can be
done in later patches.

I tried adding MD5 check, but not all databases have them, so i skipped
it. We are downloading over HTTPS though, it should be good. I also
tried adding zip support, but the first zip file I extracted had a
different filename inside than the archive name, which breaks an
assumption in this service, so I skipped that too.

Changes v9 -> v10:
  - Pass "--max-time" to curl to set upper bound on downloads (ensures
    no indefinite hanging if there's problem with networking).
    Timeout for network connectivity check: 60s.
    Timeout for geoip database (each): 15m.

Changes v8 -> v9:
  - Mention the random timer delay in the documentation for the
    'interval' option.

Changes v7 -> v8:
  - Add "RemainAfterExit=true" for the setup service, so it won't be
    restarted needlessly. (Thanks @danbst!)

Changes v6 -> v7:
  - Add --skip-existing flag to geoip-updater, which skips updating
    existing database files. Pass that flag when we run the service on
    boot (and on any NixOS configuration change).
    (IMHO, this is somewhat a workaround for systemd persistent timers
    not being triggered immediately when a timer has never expired
    before. But it does have the nice side effect of ensuring that the
    installed databases always correspond to the configured ones, since
    the service is now always run after configuration changes.)

Changes v5 -> v6:
  - Update database files atomically (per DB)
  - If a database is removed from the configuration, it'll be removed
    from /var/lib/geoip-databases too (on next run).
  - Add NixOS module assertion so that if user inputs non- .gz or .xz
    file there will be a build time error instead of runtime.
  - Run updater as user "nobody" instead of "root".
  - Rename NixOS service from "geoip-databases" to "geoip-updater".
  - Drop RemainAfterExit, or else the timer won't trigger the unit.
  - Bring back "curl --fail", or else we won't catch and log curl
    failures.

Changes v4 -> v5:
  - Add "GeoLite2-City.mmdb.gz" to default database list.

Changes v3 -> v4:
  - Remove unneeded geoip-updater-setup.service after adding
    'wantedBy = [ "multi-user.target" ]' directly to
    geoip-updater.service
  - Drop unneeded "Service" name from service descriptions.

Changes v2 -> v3:
  - Network may be down when starting from a cold boot, so try a few
    times. Possibly, if using systemd-networkd, it'll pass on the first
    try. But with default DHCP on NixOS, the service is started before
    hostnames can be resolved and thus we need a few extra seconds.
  - Add error handling and mark service as failed if fatal error.
  - Add proper syslog log levels.
  - Add RandomizedDelaySec=3600 to the timer to not put high load on the
    MaxMind servers. Suggested by @Mic92.
  - Set RemainAfterExit on geoip-updater.service instead of
    geoip-updater-setup.service. (The latter is only a proxy that pulls
    in the former service).

Changes v1 -> v2:
From Данило Глинський (Danylo Hlynskyi) <abcz2.uprola@gmail.com>:
  nixos/geoip-databases: add `databases` option and fix initial setup

  There were two great issues when using this service:
  - When you just enable service, databases aren't downloaded, they are
    downloaded when timer triggers. Fixed this with automatic download on
    first system activation.
  - When there is no internet, updater outputs nothing to logs, which is
    IMO misbehavior. Fixed this with removing `--fail` option, better be
    explicit here.
2017-02-12 15:07:34 +01:00
..
taskserver nixos: fix taskserver module to evaluate properly when keys are managed manually 2017-02-07 18:35:41 +01:00
apache-kafka.nix apache-kafka service: change default brokerId to -1 2017-01-24 12:32:22 -05:00
autofs.nix nixos/autofs: fix typo afuese -> afuse 2016-09-19 13:49:47 +02:00
bepasty.nix nixos: use types.lines for extraConfig 2016-10-23 19:41:43 +02:00
calibre-server.nix
canto-daemon.nix
cfdyndns.nix
cgminer.nix
confd.nix confd service: change default etcd port 4001 -> 2379 2016-09-28 23:35:54 +02:00
couchpotato.nix couchpotato module: init 2017-01-16 12:54:43 +01:00
cpuminer-cryptonight.nix
defaultUnicornConfig.rb
devmon.nix
dictd.nix nixos/modules: use defaultText where applicable 2016-11-21 16:35:15 +01:00
disnix.nix nixos/modules: use defaultText where applicable 2016-11-21 16:35:15 +01:00
docker-registry.nix dockerRegistry module: re-init with new underlying software 2016-10-12 14:05:09 +02:00
dysnomia.nix
emby.nix emby: use makeWrapper to supply ffmpeg/probe paths 2016-10-03 12:23:44 +02:00
errbot.nix errbot service: fix import config in plugins 2016-11-08 17:44:52 +01:00
etcd.nix misc.etcd: get closer to upstream service definition 2016-09-13 11:19:22 +02:00
felix.nix
folding-at-home.nix folding-at-home service: network-interfaces.target -> network.target 2016-09-13 11:19:22 +02:00
gammu-smsd.nix
geoip-updater.nix nixos/geoip-updater: new service 2017-02-12 15:07:34 +01:00
gitit.nix
gitlab.nix gitlab service: fix sidekiq queue config 2016-11-29 17:42:46 +01:00
gitlab.xml
gitolite.nix
gogs.nix gogs: fix error on push 2017-02-04 12:16:37 +01:00
gpsd.nix
ihaskell.nix nixos: drop unused 'haskellPackages' option from ihaskell service 2017-01-31 22:38:01 +01:00
leaps.nix leaps: 0.5.1 + add a service + test 2016-11-06 10:34:42 +01:00
mantisbt.nix
mathics.nix
matrix-synapse-log_config.yaml
matrix-synapse.nix matrix-synapse service: Make url_preview_enabled optional (#20609) 2016-11-28 03:33:48 +01:00
mbpfan.nix
mediatomb.nix
mesos-master.nix mesos: 1.0.1 -> 1.1.0 2016-12-29 20:09:46 -05:00
mesos-slave.nix mesos: 1.0.1 -> 1.1.0 2016-12-29 20:09:46 -05:00
mwlib.nix
nix-daemon.nix Add some more details about useSandbox 2017-01-03 14:24:49 -05:00
nix-gc.nix nix gc service: fix use of startAt 2016-10-23 17:56:49 +02:00
nix-optimise.nix nix-optimise module: fix startAt 2016-10-19 02:22:12 +02:00
nix-ssh-serve.nix
nixos-manual.nix
nscd-sssd.conf sssd: init at 1.14.2 2017-01-04 03:07:20 +03:00
nzbget.nix
octoprint.nix nixos/octoprint: fixup extraConfig 2016-10-23 19:47:28 +02:00
packagekit.nix
parsoid.nix parsoid service: update, use declarative configuration 2016-11-20 19:12:14 +03:00
phd.nix
plex.nix Merge pull request #21395 from jerith666/plex-firewall 2016-12-24 23:31:04 +01:00
redmine.nix nixos: use types.lines for extraConfig 2016-10-23 19:41:43 +02:00
ripple-data-api.nix
ripple-rest.nix
rippled.nix
rogue.nix
siproxd.nix
sonarr.nix
spice-vdagentd.nix
sssd.nix sssd: init at 1.14.2 2017-01-04 03:07:20 +03:00
subsonic.nix
sundtek.nix
svnserve.nix svnserve service: network-interfaces.target -> network.target 2016-09-13 11:19:22 +02:00
synergy.nix
uhub.nix
zookeeper.nix zookeeper service: network-interfaces.target -> network.target 2016-09-13 11:19:22 +02:00