diff options
Diffstat (limited to '')
-rw-r--r-- | chaski/services/tracktrain.nix | 89 | ||||
-rw-r--r-- | flake.lock | 9 | ||||
-rw-r--r-- | flake.nix | 2 |
3 files changed, 74 insertions, 26 deletions
diff --git a/chaski/services/tracktrain.nix b/chaski/services/tracktrain.nix index 3841a42..b78014f 100644 --- a/chaski/services/tracktrain.nix +++ b/chaski/services/tracktrain.nix @@ -3,7 +3,7 @@ { services.nginx.virtualHosts."tracktrain.stuebinm.eu" = { locations."/" = { - proxyPass = "http://localhost:4000"; + proxyPass = "http://192.168.42.41:4000"; proxyWebsockets = true; }; enableACME = true; @@ -12,26 +12,73 @@ networking.firewall.allowedTCPPorts = [ 443 ]; - systemd.services.tracktrain = { - enable = true; + containers.tracktrain = { + autoStart = true; + privateNetwork = true; + hostAddress6 = "fd00::42:40"; + localAddress6 = "fd00::42:41"; + hostAddress = "192.168.42.40"; + localAddress = "192.168.42.41"; + + config = { config, pkgs, ... }: { + + 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/tracktrain "dbname=tracktrain user=tracktrain" + ''; + startAt = "daily"; + }; + + services.postgresql = { + enable = true; + + ensureDatabases = [ "tracktrain" ]; + ensureUsers = [ { + name = "tracktrain"; + ensurePermissions = { + "DATABASE tracktrain" = "ALL PRIVILEGES"; + }; + } ]; + authentication = '' + local all all trust + host all all 127.0.0.1/32 trust + ''; + }; - 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"; + networking.firewall.allowedTCPPorts = [ 4000 ]; + system.stateVersion = "22.05"; + + services.coredns = { + enable = true; + config = '' + .:53 { + forward . 1.1.1.1 + } + ''; + }; + }; + }; + + networking.nat = { + enable = true; + internalInterfaces = [ "ve-tracktrain" ]; + externalInterface = "ens3"; }; + } @@ -271,16 +271,17 @@ "tracktrain": { "flake": false, "locked": { - "lastModified": 1654892572, - "narHash": "sha256-BJXYM+CM4rPfeR1/loJKNe2/U08DzRkRNEQFDfxGE3g=", + "lastModified": 1655500338, + "narHash": "sha256-XEhoT7bWlzxsZ0wFUPgL9/64Itxsbx2E++l6Shiq4Fk=", "ref": "main", - "rev": "c37d12f82eea235295c50014acd41c094b426f14", - "revCount": 6, + "rev": "9d6ffed9e0bd623f84fef5d085d86c4b298e5394", + "revCount": 14, "type": "git", "url": "https://stuebinm.eu/git/tracktrain" }, "original": { "ref": "main", + "rev": "9d6ffed9e0bd623f84fef5d085d86c4b298e5394", "type": "git", "url": "https://stuebinm.eu/git/tracktrain" } @@ -17,7 +17,7 @@ uplcg.url = "git+https://stuebinm.eu/git/uplcg?ref=main"; uplcg.flake = false; - tracktrain.url = "git+https://stuebinm.eu/git/tracktrain?ref=main"; + tracktrain.url = "git+https://stuebinm.eu/git/tracktrain?rev=9d6ffed9e0bd623f84fef5d085d86c4b298e5394&ref=main"; tracktrain.flake = false; blog.url = "path:/home/stuebinm/projects/blog"; blog.flake = false; |