Compare commits

..

3 commits

Author SHA1 Message Date
bb37a6c3a8 feat(y2q): add grafana
- Add runit service for Grafana
- Add Caddy route for grafana.ts.toast.name
2025-12-08 19:27:27 +09:00
18997b1fef feat(y2q): add prometheus 2025-12-08 19:26:02 +09:00
c10916f47a feat(nixos): migrate restic backups from b2 to rest-server 2025-12-08 19:23:05 +09:00
4 changed files with 55 additions and 3 deletions

View file

@ -19,6 +19,11 @@
# Glances # Glances
reverse_proxy http://localhost:61208 reverse_proxy http://localhost:61208
} }
http://grafana.ts.toast.name {
# Grafana
reverse_proxy http://localhost:${config.runit.services.grafana.environment.GF_SERVER_HTTP_PORT}
}
''; '';
runit.services.caddy = { runit.services.caddy = {

View file

@ -0,0 +1,21 @@
{ pkgs, config, ... }:
{
runit.services.grafana = {
script = ''
HOME_PATH=$HOME/services/grafana
mkdir -p "$HOME_PATH"
exec ${pkgs.grafana}/bin/grafana server \
--homepath ${pkgs.grafana}/share/grafana
'';
environment = {
GF_SERVER_HTTP_ADDR = "127.0.0.1";
GF_SERVER_HTTP_PORT = "3000";
GF_PATHS_DATA = "${config.home.homeDirectory}/services/grafana";
};
log.enable = true;
};
}

View file

@ -0,0 +1,25 @@
{ pkgs, config, ... }:
{
home.file.".config/prometheus/prometheus.yml".text = ''
global:
scrape_interval: 1m
scrape_configs:
- job_name: 'restic_rest_server'
static_configs:
- targets: ['${config.runit.services.restic-rest-server.environment.LISTEN_ADDR}']
'';
runit.services.prometheus = {
script = ''
TSDB_PATH=$HOME/services/prometheus
mkdir -p TSDB_PATH
exec ${pkgs.prometheus}/bin/prometheus \
--config.file=$HOME/.config/prometheus/prometheus.yml \
--storage.tsdb.path=$TSDB_PATH \
--web.listen-address="127.0.0.1:9090"
'';
};
}

View file

@ -6,7 +6,7 @@
"restic/env" = {}; "restic/env" = {};
}; };
services.restic.backups.b2 = { services.restic.backups.y2q = {
initialize = true; initialize = true;
inhibitsSleep = true; inhibitsSleep = true;
passwordFile = config.sops.secrets."restic/password".path; passwordFile = config.sops.secrets."restic/password".path;
@ -15,15 +15,16 @@
"/home/toast/workspace" "/home/toast/workspace"
]; ];
exclude = [ "node_modules" ]; exclude = [ "node_modules" ];
repository = "s3:https://s3.us-east-005.backblazeb2.com/restic-backups-0"; repository = "rest:http://y2q:9000/nixos/";
environmentFile = config.sops.secrets."restic/env".path; environmentFile = config.sops.secrets."restic/env".path;
pruneOpts = [ pruneOpts = [
"--keep-hourly 6"
"--keep-daily 7" "--keep-daily 7"
"--keep-weekly 3" "--keep-weekly 3"
"--keep-monthly 3" "--keep-monthly 3"
]; ];
timerConfig = { timerConfig = {
OnCalendar = "daily"; OnCalendar = "hourly";
Persistent = true; Persistent = true;
}; };
}; };