Add nixos-logs system with Grafana, Prometheus, and Loki; fix Traefik config formatting

This commit is contained in:
Root User 2026-02-14 14:34:24 +01:00
parent 11a870a60f
commit e6b7a95b57
Signed by: root
GPG key ID: 087F0A95E5766D72
4 changed files with 126 additions and 11 deletions

View file

@ -15,6 +15,7 @@ configs=(
"nixos-teamspeak"
"nixos-traefik"
"nixos-build-machine"
"nixos-logs"
)
if [[ -n "$1" ]]; then

View file

@ -52,6 +52,11 @@
inherit system;
modules = [./nix-system-configs/modules/system/build_machine.nix];
};
"nixos-logs" = nixpkgs.lib.nixosSystem {
inherit system;
modules = [./nix-system-configs/modules/system/gramethus.nix];
};
};
};
}

View file

@ -0,0 +1,110 @@
{
config,
pkgs,
lib,
...
}: let
choose = paths: lib.findFirst builtins.pathExists null paths;
# Dummy filesystem config for dry-run evaluation
dummyFileSystems = {
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
};
in {
options.local = {
hostname = lib.mkOption {
type = lib.types.str;
default = "nixos-default";
description = "System hostname";
};
username = lib.mkOption {
type = lib.types.str;
default = "user";
description = "Primary user username";
};
userDescription = lib.mkOption {
type = lib.types.str;
default = "NixOS User";
description = "Primary user description";
};
address = lib.mkOption {
type = lib.types.str;
default = "10.1.1.100";
description = "Static IP address";
};
};
imports =
lib.filter (x: x != null) [
(choose [./modules/local/hostname_username.nix ../local/hostname_username.nix])
(choose [./modules/local/networking_local.nix ../local/networking_local.nix])
(choose [./modules/bootloader/seabios-assigned-iso-at-birth.nix ../bootloader/seabios-assigned-iso-at-birth.nix])
(choose [./modules/lix-default.nix ../lix-default.nix])
(choose [./modules/secrets-config/sops-the-blank-system.nix ../secrets-config/sops-the-blank-system.nix])
]
# TODO: Make this more clean, migrate over to seabios-assigned-iso-at-birth.nix?
#++ lib.optional (builtins.pathExists ./hardware-configuration.nix) ./hardware-configuration.nix
#++ lib.optional (!builtins.pathExists ./hardware-configuration.nix) dummyFileSystems
;
config = {
local.hostname = "nixos-grametheus";
local.username = "prglogs";
local.userDescription = "NixOS PRG Grafana Prometheus Service";
local.address = "10.1.1.10";
system.stateVersion = "25.11";
services.grafana = {
enable = true;
settings = {
server = {
http_addr = "127.0.0.1";
http_port = 3005;
enforce_domain = true;
enable_gzip = true;
domain = "grafana.prg-radio.org";
# Alternatively, if you want to serve Grafana from a subpath:
# domain = "your.domain";
# root_url = "https://your.domain/grafana/";
# serve_from_sub_path = true;
};
# Prevents Grafana from phoning home
#analytics.reporting_enabled = false;
};
};
services.prometheus = {
enable = true;
port = 9001;
exporters.node.enabledCollectors = [
"ethtool"
"softirqs"
"systemd"
"tcpstat"
];
};
services.loki = {
enable = true;
configuration = {
auth_enabled = false;
server.http_listen_port = 3100;
# etc.
};
# or alternatively
#configFile = ./loki-config.yaml;
};
# Enable Tailscale for remote access to Traefik dashboard and configuration
services.tailscale.enable = true;
};
}

View file

@ -90,7 +90,6 @@ in {
COOKIE_SAME_SITE = "None"; # Only if Secure=true and you need cross-site
};
};
};
};