Merge branch 'master' of github.com:/kropatz/nix-config

This commit is contained in:
Kopatz
2024-04-27 22:07:35 +02:00
7 changed files with 552 additions and 30 deletions

17
flake.lock generated
View File

@@ -229,22 +229,6 @@
"type": "github"
}
},
"nixpkgs-fixed-kavita": {
"locked": {
"lastModified": 1711893330,
"narHash": "sha256-XUZvnZGGptiAtUhxAjnCDjF6Ov6D0/Ag61L+sPyjVHA=",
"owner": "davidkna",
"repo": "nixpkgs",
"rev": "9c2c6f35de1ed1e18467cf224ed86689e6f589c4",
"type": "github"
},
"original": {
"owner": "davidkna",
"ref": "kavita-fix-migrations",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1697935651,
@@ -315,7 +299,6 @@
"nixos-hardware": "nixos-hardware",
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs_2",
"nixpkgs-fixed-kavita": "nixpkgs-fixed-kavita",
"nixpkgs-unstable": "nixpkgs-unstable",
"nur": "nur"
}

View File

@@ -6,7 +6,6 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
nixpkgs-unstable.url = "nixpkgs/nixos-unstable";
nixpkgs-fixed-kavita.url = "github:davidkna/nixpkgs/kavita-fix-migrations";
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
@@ -28,7 +27,6 @@
nixos-hardware,
nixos-wsl,
nixpkgs-unstable,
nixpkgs-fixed-kavita,
agenix,
home-manager,
home-manager-unstable,
@@ -47,7 +45,7 @@
./users/anon
./modules/collections/server.nix
./systems/server/configuration.nix
({ config, outputs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages fixed-kavita]; })
({ config, outputs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages]; })
home-manager-unstable.nixosModules.home-manager
agenix.nixosModules.default
];

View File

@@ -80,6 +80,22 @@ in
disabledCollectors = [ "arp" ];
port = 9001;
};
nginx = {
enable = false;
port = 9003;
};
nginxlog = {
enable = true;
port = 9004;
group = "nginx";
settings.namespaces = [
{
name = "nginxlog";
source.files = ["/var/log/nginx/access.log"];
format = "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\"";
}
];
};
};
scrapeConfigs = [
{
@@ -87,7 +103,11 @@ in
static_configs = [{
targets = [
"127.0.0.1:${toString config.services.prometheus.exporters.node.port}"
] ++ (lib.optional config.services.cadvisor.enable "${config.services.cadvisor.listenAddress}:${toString config.services.cadvisor.port}");
] ++
(lib.optional config.services.cadvisor.enable "${config.services.cadvisor.listenAddress}:${toString config.services.cadvisor.port}") ++
(lib.optional config.services.prometheus.exporters.nginx.enable "127.0.0.1:${toString config.services.prometheus.exporters.nginx.port}") ++
(lib.optional config.services.prometheus.exporters.nginxlog.enable "127.0.0.1:${toString config.services.prometheus.exporters.nginxlog.port}")
;
}];
}
];

View File

@@ -0,0 +1,527 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 10,
"links": [],
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "PBFE396EC0B189D67"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
}
},
"mappings": [],
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 3,
"x": 0,
"y": 0
},
"id": 6,
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"pieType": "pie",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "PBFE396EC0B189D67"
},
"editorMode": "code",
"expr": "sum by (status) (nginxlog_http_response_count_total)",
"instant": false,
"legendFormat": "{{status}}",
"range": true,
"refId": "A"
}
],
"title": "Requests by response status total",
"type": "piechart"
},
{
"datasource": {
"type": "prometheus",
"uid": "PBFE396EC0B189D67"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 3,
"y": 0
},
"id": 3,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "PBFE396EC0B189D67"
},
"editorMode": "code",
"expr": "sum by (status) (rate(nginxlog_http_response_count_total[$__rate_interval]))",
"instant": false,
"legendFormat": "{{status}}",
"range": true,
"refId": "A"
}
],
"title": "Requests by response status",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "PBFE396EC0B189D67"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 3,
"x": 15,
"y": 0
},
"id": 7,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showPercentChange": false,
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "10.4.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "PBFE396EC0B189D67"
},
"editorMode": "code",
"expr": "nginxlog_parse_errors_total",
"instant": false,
"legendFormat": "{{status}}",
"range": true,
"refId": "A"
}
],
"title": "Parse errors total",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "PBFE396EC0B189D67"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
}
},
"mappings": [],
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 3,
"x": 0,
"y": 8
},
"id": 5,
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"pieType": "pie",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "PBFE396EC0B189D67"
},
"editorMode": "code",
"expr": "sum by (method) (nginxlog_http_response_count_total)",
"instant": false,
"legendFormat": "{{status}}",
"range": true,
"refId": "A"
}
],
"title": "Requests by method total",
"type": "piechart"
},
{
"datasource": {
"type": "prometheus",
"uid": "PBFE396EC0B189D67"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 3,
"y": 8
},
"id": 4,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "PBFE396EC0B189D67"
},
"editorMode": "code",
"expr": "sum by (method) (rate(nginxlog_http_response_count_total[$__rate_interval]))",
"instant": false,
"legendFormat": "{{status}}",
"range": true,
"refId": "A"
}
],
"title": "Requests by method",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "PBFE396EC0B189D67"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 15,
"x": 0,
"y": 16
},
"id": 1,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "PBFE396EC0B189D67"
},
"editorMode": "code",
"expr": "rate(nginxlog_http_response_size_bytes[$__rate_interval])",
"instant": false,
"legendFormat": "{{method}} {{status}}",
"range": true,
"refId": "A"
}
],
"title": "Response bytes",
"type": "timeseries"
}
],
"schemaVersion": 39,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "Nginxlog",
"uid": "bdk0dib38e0w0e",
"version": 2,
"weekStart": ""
}

View File

@@ -22,7 +22,7 @@ in
services.kavita = {
enable = true;
user = "kavita";
package = pkgs.fixed-kavita.kavita;
package = pkgs.kavita;
settings.Port = 5000;
dataDir = baseDir;
tokenKeyFile = config.age.secrets.kavita.path;

View File

@@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, lib, config, ... }:
{
networking.firewall.allowedTCPPorts = [ 80 443 ];
networking.firewall.allowedUDPPorts = [ 80 443 ];
@@ -18,6 +18,7 @@
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
statusPage = lib.mkIf config.services.prometheus.exporters.nginx.enable true;
# Only allow PFS-enabled ciphers with AES256
sslCiphers = "AES256+EECDH:AES256+EDH:!aNULL";

View File

@@ -20,11 +20,4 @@
config.allowUnfree = true;
};
};
fixed-kavita = final: _prev: {
fixed-kavita = import inputs.nixpkgs-fixed-kavita {
system = final.system;
config.allowUnfree = true;
};
};
}