summaryrefslogtreecommitdiff
path: root/chaski/services/tracktrain.nix
blob: 3841a42435b223aab49f07e1d33c93b4d8694ee7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{ config, lib, pkgs, inputs, ... }:

{
  services.nginx.virtualHosts."tracktrain.stuebinm.eu" = {
    locations."/" = {
      proxyPass = "http://localhost:4000";
      proxyWebsockets = true;
    };
    enableACME = true;
    forceSSL = true;
  };

  networking.firewall.allowedTCPPorts = [ 443 ];

  systemd.services.tracktrain = {
    enable = true;

    description = "tracks trains, hopefully";
    wantedBy = [ "multi-user.target" ];
    after = [ "network.target" ];
    serviceConfig.Type = "simple";
    path = [ pkgs.wget ];
    script = ''
      cd /tmp
      wget "https://ilztalbahn.eu/wp-content/uploads/2020/07/gtfs.zip"
      ${((import inputs.tracktrain {nixpkgs = pkgs;}))
        # have to remove version constraints because some aren't in 22.05
        .overrideAttrs (old: { patchPhase = ''
          sed -i "s/base.*/base/g" *.cabal
          sed -i "s/^>=.*//g" *.cabal
          sed -i "s/>=.*//g" *.cabal
        ''; })
       }/bin/haskell-gtfs
    '';
    startAt = "daily";
  };
}