nixpkgs/nixos/modules/services
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
..
amqp nixos manuals: bring back package references 2016-02-03 14:47:14 +01:00
audio Merge pull request #21505 from tg-x/mpd-listen 2017-01-01 16:06:17 +01:00
backup tarsnap service: fix multiple simultaneous archives with a single key 2016-11-20 19:15:52 +03:00
cluster kube-controller-manager service: Allow restarts on failure 2017-01-15 13:27:45 +01:00
computing boinc service: use <link> instead of <ulink> 2016-12-08 15:50:52 +00:00
continuous-integration buildbot: 0.9.0.post1 -> 0.9.3 2017-02-07 11:14:42 -05:00
databases Revert "mysql service: specify a default package" 2016-12-17 22:36:38 +01:00
desktops psd service: assert that at least one user must be configured 2016-12-10 20:35:44 +01:00
development hoogle service: fixups 2016-04-22 03:58:08 +02:00
editors ~/.nixpkgs -> ~/.config/nixpkgs 2017-02-01 16:07:55 +01:00
games factorio: remove autosave-interval from command-line options 2017-01-25 21:39:37 +01:00
hardware nixos: drop references to kde4 2017-02-11 14:01:13 -05:00
logging fluentd module: add configurable package option 2017-01-27 15:08:23 +00:00
mail postfix service: don't empty local_recipient_maps 2017-02-06 01:41:27 +03:00
misc nixos/geoip-updater: new service 2017-02-12 15:07:34 +01:00
monitoring arbtt: multi-user.target does not exist in user systemd 2017-01-28 14:29:19 +00:00
network-filesystems nfsd service: don't run exportfs 2017-02-05 03:17:38 +03:00
networking nixos: drop references to kde4 2017-02-11 14:01:13 -05:00
printing use symlink to ensure cupsd.conf PATH always points to a valid store path 2016-12-13 21:35:56 -05:00
scheduling marathon service: remove use of network-interfaces.target 2016-09-13 11:19:22 +02:00
search nixos/modules: use defaultText where applicable 2016-11-21 16:35:15 +01:00
security hologram: 8d86e3f -> d20d1c3 2017-02-02 11:31:42 -05:00
system dbus service: remove {system,session}.conf from config dir 2017-02-01 15:37:24 +03:00
torrent flexget: move out of python-packages.nix 2016-12-31 09:52:45 +01:00
ttys agetty: remove override for container-getty@.service since it's upstream 2016-09-05 15:03:35 +02:00
web-apps frab module: init 2017-01-25 23:58:21 +01:00
web-servers caddy: set file descriptor limit to 8192, fixes #22454 2017-02-11 01:44:29 +01:00
x11 nixos: drop references to kde4 2017-02-11 14:01:13 -05:00