init tracktrain
This commit is contained in:
parent
82e2831d3a
commit
9af819b4b8
5 changed files with 160 additions and 1 deletions
20
flake.lock
20
flake.lock
|
@ -763,7 +763,8 @@
|
||||||
"nix-hexchen": "nix-hexchen",
|
"nix-hexchen": "nix-hexchen",
|
||||||
"nixos-mailserver": "nixos-mailserver",
|
"nixos-mailserver": "nixos-mailserver",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"nixpkgs-unstable": "nixpkgs-unstable"
|
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||||
|
"tracktrain": "tracktrain"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rotate-text": {
|
"rotate-text": {
|
||||||
|
@ -836,6 +837,23 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"tracktrain": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1674348451,
|
||||||
|
"narHash": "sha256-fkVvjRe8wKKjEdLiRJV62nns0svy2pngE5jvsZjIlvE=",
|
||||||
|
"ref": "main",
|
||||||
|
"rev": "3d0980811d61a78f265ec06dd5bd4ef2cde1cbdf",
|
||||||
|
"revCount": 78,
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://stuebinm.eu/git/tracktrain"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"ref": "main",
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://stuebinm.eu/git/tracktrain"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ts-fold": {
|
"ts-fold": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
nixpkgs-unstable.url = "nixpkgs/nixpkgs-unstable";
|
nixpkgs-unstable.url = "nixpkgs/nixpkgs-unstable";
|
||||||
nix-hexchen.url = "gitlab:hexchen/nixfiles";
|
nix-hexchen.url = "gitlab:hexchen/nixfiles";
|
||||||
nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-22.05";
|
nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-22.05";
|
||||||
|
tracktrain.url = "git+https://stuebinm.eu/git/tracktrain?ref=main";
|
||||||
|
tracktrain.flake = false;
|
||||||
|
|
||||||
deploy-rs.url = "github:serokell/deploy-rs";
|
deploy-rs.url = "github:serokell/deploy-rs";
|
||||||
deploy-rs.inputs.nixpkgs.follows = "nixpkgs";
|
deploy-rs.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
../../services/gitea.nix
|
../../services/gitea.nix
|
||||||
../../services/nginx-pages.nix
|
../../services/nginx-pages.nix
|
||||||
../../services/vaultwarden.nix
|
../../services/vaultwarden.nix
|
||||||
|
../../services/tracktrain.nix
|
||||||
../../services/uffd.nix
|
../../services/uffd.nix
|
||||||
|
|
||||||
./lxc.nix
|
./lxc.nix
|
||||||
|
|
|
@ -10,6 +10,10 @@ let
|
||||||
|
|
||||||
mattermost = callPackage ./mattermost {inherit sources;};
|
mattermost = callPackage ./mattermost {inherit sources;};
|
||||||
|
|
||||||
|
tracktrain = import sources.tracktrain {
|
||||||
|
nixpkgs = pkgs;
|
||||||
|
};
|
||||||
|
|
||||||
# a version of the lounge with some extra css that
|
# a version of the lounge with some extra css that
|
||||||
# hides things the hacc-voc doesn't need
|
# hides things the hacc-voc doesn't need
|
||||||
thelounge-hacked = pkgs.stdenv.mkDerivation {
|
thelounge-hacked = pkgs.stdenv.mkDerivation {
|
||||||
|
|
134
services/tracktrain.nix
Normal file
134
services/tracktrain.nix
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
{ config, lib, pkgs, inputs, evalConfig, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.nginx.virtualHosts."tracktrain.ilztalbahn.eu" = {
|
||||||
|
locations."/api" = {
|
||||||
|
proxyPass = "http://192.168.42.41:4000";
|
||||||
|
proxyWebsockets = true;
|
||||||
|
extraConfig = ''
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
# locations."/metrics/" = {
|
||||||
|
# proxyPass = "http://localhost:2342";
|
||||||
|
# proxyWebsockets = true;
|
||||||
|
# extraConfig = ''
|
||||||
|
# rewrite ^/metrics/(.*) /$1 break;
|
||||||
|
# '';
|
||||||
|
# };
|
||||||
|
enableACME = true;
|
||||||
|
forceSSL = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# services.prometheus = {
|
||||||
|
# enable = true;
|
||||||
|
# port = 9001;
|
||||||
|
# scrapeConfigs = [ {
|
||||||
|
# job_name = "tracktrain";
|
||||||
|
# static_configs = [{
|
||||||
|
# targets = [ "192.168.42.41:4000" ];
|
||||||
|
# }];
|
||||||
|
# } ];
|
||||||
|
# };
|
||||||
|
|
||||||
|
# services.grafana = {
|
||||||
|
# enable = true;
|
||||||
|
# settings.server = {
|
||||||
|
# serve_from_sub_path = true;
|
||||||
|
# domain = "tracktrain.ilztalbahn.eu";
|
||||||
|
# root_url = "%(protocol)s://%(domain)s:/metrics/";
|
||||||
|
# http_port = 2342;
|
||||||
|
# http_addr = "0.0.0.0";
|
||||||
|
# };
|
||||||
|
|
||||||
|
# provision = {
|
||||||
|
# enable = true;
|
||||||
|
# datasources.settings.datasources = [ {
|
||||||
|
# url = "http://localhost:9001";
|
||||||
|
# type = "prometheus";
|
||||||
|
# name = "prometheus";
|
||||||
|
# } ];
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
|
||||||
|
networking.firewall.allowedTCPPorts = [ 443 ];
|
||||||
|
|
||||||
|
containers.tracktrain = {
|
||||||
|
privateNetwork = true;
|
||||||
|
hostAddress = "192.168.42.40";
|
||||||
|
localAddress = "192.168.42.41";
|
||||||
|
autoStart = true;
|
||||||
|
|
||||||
|
bindMounts = {
|
||||||
|
"/persist" = {
|
||||||
|
hostPath = "/persist/containers/tracktrain";
|
||||||
|
isReadOnly = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
path = (evalConfig {
|
||||||
|
hosts = { };
|
||||||
|
groups = { };
|
||||||
|
} ({ config, lib, pkgs, profiles, modules, sources, ... }: {
|
||||||
|
boot.isContainer = true;
|
||||||
|
networking.useDHCP = false;
|
||||||
|
users.users.root.hashedPassword = "";
|
||||||
|
system.stateVersion = "21.11";
|
||||||
|
|
||||||
|
imports = [ sources.nix-hexchen.nixosModules.profiles.nopersist ];
|
||||||
|
networking.firewall.enable = false;
|
||||||
|
networking.defaultGateway = {
|
||||||
|
address = "192.168.100.1";
|
||||||
|
interface = "eth0";
|
||||||
|
};
|
||||||
|
|
||||||
|
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"
|
||||||
|
${(pkgs.tracktrain
|
||||||
|
# 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 --dbString="dbname=tracktrain user=tracktrain" --warp.port=4000 +RTS -T
|
||||||
|
'';
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
services.coredns = {
|
||||||
|
enable = true;
|
||||||
|
config = ''
|
||||||
|
.:53 {
|
||||||
|
forward . 1.1.1.1
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
})).config.system.build.toplevel;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue