depot/ops/nixos/bvm-logger/default.nix

58 lines
1.7 KiB
Nix
Raw Normal View History

2021-12-23 04:11:39 +00:00
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
#
# SPDX-License-Identifier: Apache-2.0
{ config, depot, lib, pkgs, ... }:
let
inherit (depot.ops) secrets;
in {
imports = [
../lib/bvm.nix
];
# Networking!
networking = {
hostName = "bvm-logger";
hostId = "2610e6ae";
tempAddresses = "disabled";
interfaces.enp1s0 = {
ipv4.addresses = [{ address = "10.100.0.209"; prefixLength = 23; }];
};
interfaces.enp2s0 = {
ipv4.addresses = [{ address = "92.118.28.12"; prefixLength = 24; }];
ipv6.addresses = [{ address = "2a09:a441::12"; prefixLength = 32; }];
};
defaultGateway = { address = "92.118.28.1"; interface = "enp2s0"; };
defaultGateway6 = { address = "2a09:a441::1"; interface = "enp2s0"; };
};
my.ip.tailscale = "100.68.134.82";
2021-12-24 01:50:59 +00:00
services.clickhouse.enable = true;
services.clickhouse.package = pkgs.symlinkJoin {
name = "clickhouse-overridden";
paths = [ pkgs.clickhouse ];
postBuild = ''
rm $out/etc/clickhouse-server/config.xml
cp ${./clickhouse-config.xml} $out/etc/clickhouse-server/config.xml
'';
};
2021-12-24 01:50:59 +00:00
time.timeZone = "Etc/UTC";
2022-01-01 15:08:52 +00:00
systemd.services.journal2clickhouse = {
enable = true;
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
2022-01-01 15:08:52 +00:00
serviceConfig = {
ExecStart = let
hosts = lib.concatStringsSep "," (lib.mapAttrsToList (k: v: "${k}=${v.addr}") depot.ops.nixos.scrapeJournalHosts);
in
"${depot.go.journal2clickhouse}/bin/journal2clickhouse -clickhouse_addr http://localhost:8123 -hosts '${hosts}'";
User = "journal2clickhouse";
DynamicUser = true;
2022-01-01 15:08:52 +00:00
};
};
2021-12-23 04:11:39 +00:00
system.stateVersion = "21.11";
}