refactor
This commit is contained in:
58
modules/hosts/_parts/michael/backups.nix
Normal file
58
modules/hosts/_parts/michael/backups.nix
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
services.restic.backups.gitea = {
|
||||
repository = "s3:s3.eu-central-003.backblazeb2.com/michael-gitea-repositories";
|
||||
paths = ["/var/lib/gitea"];
|
||||
exclude = [
|
||||
"/var/lib/gitea/log"
|
||||
"/var/lib/gitea/data/gitea.db"
|
||||
"/var/lib/gitea/data/gitea.db-shm"
|
||||
"/var/lib/gitea/data/gitea.db-wal"
|
||||
];
|
||||
passwordFile = config.sops.secrets.michael-gitea-restic-password.path;
|
||||
environmentFile = config.sops.secrets.michael-gitea-restic-env.path;
|
||||
pruneOpts = [
|
||||
"--keep-daily 7"
|
||||
"--keep-weekly 4"
|
||||
"--keep-monthly 6"
|
||||
];
|
||||
timerConfig = {
|
||||
OnCalendar = "daily";
|
||||
Persistent = true;
|
||||
RandomizedDelaySec = "1h";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.restic-backups-gitea = {
|
||||
wants = ["restic-init-gitea.service"];
|
||||
after = ["restic-init-gitea.service"];
|
||||
serviceConfig = {
|
||||
User = lib.mkForce "gitea";
|
||||
Group = lib.mkForce "gitea";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.restic-init-gitea = {
|
||||
description = "Initialize Restic repository for Gitea backups";
|
||||
wantedBy = ["multi-user.target"];
|
||||
after = ["network-online.target"];
|
||||
wants = ["network-online.target"];
|
||||
path = [pkgs.restic];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "gitea";
|
||||
Group = "gitea";
|
||||
RemainAfterExit = true;
|
||||
EnvironmentFile = config.sops.secrets.michael-gitea-restic-env.path;
|
||||
};
|
||||
script = ''
|
||||
export RESTIC_PASSWORD=$(cat ${config.sops.secrets.michael-gitea-restic-password.path})
|
||||
restic -r s3:s3.eu-central-003.backblazeb2.com/michael-gitea-repositories snapshots &>/dev/null || \
|
||||
restic -r s3:s3.eu-central-003.backblazeb2.com/michael-gitea-repositories init
|
||||
'';
|
||||
};
|
||||
}
|
||||
37
modules/hosts/_parts/michael/disk-config.nix
Normal file
37
modules/hosts/_parts/michael/disk-config.nix
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
disko.devices = {
|
||||
disk = {
|
||||
main = {
|
||||
type = "disk";
|
||||
device = "/dev/sda";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
boot = {
|
||||
size = "1M";
|
||||
type = "EF02";
|
||||
};
|
||||
ESP = {
|
||||
size = "512M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
mountOptions = ["umask=0077"];
|
||||
};
|
||||
};
|
||||
root = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
114
modules/hosts/_parts/michael/gitea.nix
Normal file
114
modules/hosts/_parts/michael/gitea.nix
Normal file
@@ -0,0 +1,114 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
sops.secrets = {
|
||||
michael-gitea-litestream = {
|
||||
sopsFile = ../../../../secrets/michael-gitea-litestream;
|
||||
format = "binary";
|
||||
owner = "gitea";
|
||||
group = "gitea";
|
||||
path = "/run/secrets/michael-gitea-litestream";
|
||||
};
|
||||
michael-gitea-restic-password = {
|
||||
sopsFile = ../../../../secrets/michael-gitea-restic-password;
|
||||
format = "binary";
|
||||
owner = "gitea";
|
||||
group = "gitea";
|
||||
path = "/run/secrets/michael-gitea-restic-password";
|
||||
};
|
||||
michael-gitea-restic-env = {
|
||||
sopsFile = ../../../../secrets/michael-gitea-restic-env;
|
||||
format = "binary";
|
||||
owner = "gitea";
|
||||
group = "gitea";
|
||||
path = "/run/secrets/michael-gitea-restic-env";
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [80 443];
|
||||
|
||||
services.redis.servers.gitea = {
|
||||
enable = true;
|
||||
port = 6380;
|
||||
bind = "127.0.0.1";
|
||||
settings = {
|
||||
maxmemory = "64mb";
|
||||
maxmemory-policy = "allkeys-lru";
|
||||
};
|
||||
};
|
||||
|
||||
services.gitea = {
|
||||
enable = true;
|
||||
database = {
|
||||
type = "sqlite3";
|
||||
path = "/var/lib/gitea/data/gitea.db";
|
||||
};
|
||||
settings = {
|
||||
server = {
|
||||
ROOT_URL = "https://git.schmatzler.com/";
|
||||
DOMAIN = "git.schmatzler.com";
|
||||
HTTP_ADDR = "127.0.0.1";
|
||||
HTTP_PORT = 3000;
|
||||
LANDING_PAGE = "explore";
|
||||
};
|
||||
service.DISABLE_REGISTRATION = true;
|
||||
security.INSTALL_LOCK = true;
|
||||
cache = {
|
||||
ADAPTER = "redis";
|
||||
HOST = "redis://127.0.0.1:6380/0?pool_size=100&idle_timeout=180s";
|
||||
ITEM_TTL = "16h";
|
||||
};
|
||||
"cache.last_commit" = {
|
||||
ITEM_TTL = "8760h";
|
||||
COMMITS_COUNT = 100;
|
||||
};
|
||||
session = {
|
||||
PROVIDER = "redis";
|
||||
PROVIDER_CONFIG = "redis://127.0.0.1:6380/1?pool_size=100&idle_timeout=180s";
|
||||
COOKIE_SECURE = true;
|
||||
SAME_SITE = "strict";
|
||||
};
|
||||
api.ENABLE_SWAGGER = false;
|
||||
};
|
||||
};
|
||||
|
||||
services.litestream = {
|
||||
enable = true;
|
||||
environmentFile = config.sops.secrets.michael-gitea-litestream.path;
|
||||
settings = {
|
||||
dbs = [
|
||||
{
|
||||
path = "/var/lib/gitea/data/gitea.db";
|
||||
replicas = [
|
||||
{
|
||||
type = "s3";
|
||||
bucket = "michael-gitea-litestream";
|
||||
path = "gitea";
|
||||
endpoint = "s3.eu-central-003.backblazeb2.com";
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.litestream.serviceConfig = {
|
||||
User = lib.mkForce "gitea";
|
||||
Group = lib.mkForce "gitea";
|
||||
};
|
||||
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
virtualHosts."git.schmatzler.com".extraConfig = ''
|
||||
header {
|
||||
Strict-Transport-Security "max-age=31536000; includeSubDomains"
|
||||
X-Content-Type-Options "nosniff"
|
||||
X-Frame-Options "DENY"
|
||||
Referrer-Policy "strict-origin-when-cross-origin"
|
||||
}
|
||||
reverse_proxy localhost:3000
|
||||
'';
|
||||
};
|
||||
}
|
||||
18
modules/hosts/_parts/michael/hardware-configuration.nix
Normal file
18
modules/hosts/_parts/michael/hardware-configuration.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = ["ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod"];
|
||||
boot.initrd.kernelModules = [];
|
||||
boot.kernelModules = [];
|
||||
boot.extraModulePackages = [];
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
}
|
||||
69
modules/hosts/_parts/tahani/adguardhome.nix
Normal file
69
modules/hosts/_parts/tahani/adguardhome.nix
Normal file
@@ -0,0 +1,69 @@
|
||||
{config, ...}: {
|
||||
services.adguardhome = {
|
||||
enable = true;
|
||||
host = "127.0.0.1";
|
||||
port = 10000;
|
||||
settings = {
|
||||
dhcp = {
|
||||
enabled = false;
|
||||
};
|
||||
dns = {
|
||||
upstream_dns = [
|
||||
"1.1.1.1"
|
||||
"1.0.0.1"
|
||||
];
|
||||
};
|
||||
filtering = {
|
||||
protection_enabled = true;
|
||||
filtering_enabled = true;
|
||||
safe_search = {
|
||||
enabled = false;
|
||||
};
|
||||
safebrowsing_enabled = true;
|
||||
blocked_response_ttl = 10;
|
||||
filters_update_interval = 24;
|
||||
blocked_services = {
|
||||
ids = [
|
||||
"reddit"
|
||||
"twitter"
|
||||
];
|
||||
};
|
||||
};
|
||||
filters = [
|
||||
{
|
||||
enabled = true;
|
||||
url = "https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/pro.txt";
|
||||
name = "HaGeZi Multi PRO";
|
||||
id = 1;
|
||||
}
|
||||
{
|
||||
enabled = true;
|
||||
url = "https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/tif.txt";
|
||||
name = "HaGeZi Threat Intelligence Feeds";
|
||||
id = 2;
|
||||
}
|
||||
{
|
||||
enabled = true;
|
||||
url = "https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/gambling.txt";
|
||||
name = "HaGeZi Gambling";
|
||||
id = 3;
|
||||
}
|
||||
{
|
||||
enabled = true;
|
||||
url = "https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/nsfw.txt";
|
||||
name = "HaGeZi NSFW";
|
||||
id = 4;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services.caddy.virtualHosts."adguard.manticore-hippocampus.ts.net" = {
|
||||
extraConfig = ''
|
||||
tls {
|
||||
get_certificate tailscale
|
||||
}
|
||||
reverse_proxy localhost:${toString config.services.adguardhome.port}
|
||||
'';
|
||||
};
|
||||
}
|
||||
10
modules/hosts/_parts/tahani/cache.nix
Normal file
10
modules/hosts/_parts/tahani/cache.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{...}: {
|
||||
services.caddy.virtualHosts."cache.manticore-hippocampus.ts.net" = {
|
||||
extraConfig = ''
|
||||
tls {
|
||||
get_certificate tailscale
|
||||
}
|
||||
reverse_proxy localhost:32843
|
||||
'';
|
||||
};
|
||||
}
|
||||
38
modules/hosts/_parts/tahani/networking.nix
Normal file
38
modules/hosts/_parts/tahani/networking.nix
Normal file
@@ -0,0 +1,38 @@
|
||||
{config, ...}: {
|
||||
services.tailscale.extraSetFlags = ["--accept-routes=false"];
|
||||
|
||||
networking = {
|
||||
useDHCP = false;
|
||||
interfaces.eno1.ipv4.addresses = [
|
||||
{
|
||||
address = "192.168.1.10";
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
defaultGateway = "192.168.1.1";
|
||||
nameservers = ["1.1.1.1"];
|
||||
firewall = {
|
||||
enable = true;
|
||||
trustedInterfaces = ["eno1" "tailscale0" "docker0"];
|
||||
allowedUDPPorts = [
|
||||
53
|
||||
config.services.tailscale.port
|
||||
];
|
||||
allowedTCPPorts = [
|
||||
22
|
||||
53
|
||||
];
|
||||
checkReversePath = "loose";
|
||||
};
|
||||
};
|
||||
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/NIXROOT";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
fileSystems."/boot" = {
|
||||
device = "/dev/disk/by-label/NIXBOOT";
|
||||
fsType = "vfat";
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
I will provide you with the content and title of a document. Your task is to select appropriate tags for the document from the available list.
|
||||
Only select tags from the provided list.
|
||||
|
||||
Rules:
|
||||
1. Focus on WHAT the document IS (document type) and what TOPIC it relates to — not on incidental details mentioned in the content.
|
||||
- GOOD tags for a server hosting invoice: "Invoice", "Hosting"
|
||||
- BAD tags for a server hosting invoice: "IBAN", "VAT", "Bank account" — these are just details that appear on any invoice.
|
||||
2. Pick 1-4 tags maximum. Fewer is better. Every tag must add distinct, meaningful categorisation value.
|
||||
3. All tags must be in English.
|
||||
4. Never tag based on formatting details, payment methods, reference numbers, or boilerplate text.
|
||||
|
||||
The content is likely in {{.Language}}, but tags must always be in English.
|
||||
|
||||
<available_tags>
|
||||
{{.AvailableTags | join ", "}}
|
||||
</available_tags>
|
||||
|
||||
<title>
|
||||
{{.Title}}
|
||||
</title>
|
||||
|
||||
<content>
|
||||
{{.Content}}
|
||||
</content>
|
||||
|
||||
Respond only with the selected tags as a comma-separated list, without any additional information.
|
||||
@@ -0,0 +1,26 @@
|
||||
I will provide you with the content of a document that has been partially read by OCR (so it may contain errors).
|
||||
Your task is to generate a clear, consistent document title for use in paperless-ngx.
|
||||
|
||||
Title format: "YYYY-MM-DD - Sender - Description"
|
||||
- YYYY-MM-DD: The document date (issue date, statement date, etc.). Use the most specific date available. If no date is found, omit the date prefix.
|
||||
- Sender: The company, organisation, or person who sent/issued the document. Use their common short name (e.g. "Hetzner" not "Hetzner Online GmbH").
|
||||
- Description: A brief description of what the document is (e.g. "Server hosting invoice", "Payslip January", "Employment contract", "Tax assessment 2024"). Keep it concise but specific enough to distinguish from similar documents.
|
||||
|
||||
Examples:
|
||||
- "2025-03-01 - Hetzner - Server hosting invoice"
|
||||
- "2024-12-15 - Techniker Krankenkasse - Health insurance statement"
|
||||
- "2024-06-30 - Acme Corp - Payslip June"
|
||||
- "2024-01-10 - Finanzamt Berlin - Tax assessment 2023"
|
||||
|
||||
Rules:
|
||||
1. Always write the title in English, regardless of the document language.
|
||||
2. Keep the description part under 6 words.
|
||||
3. If the original title contains useful information, use it to inform your suggestion.
|
||||
4. Respond only with the title, without any additional information.
|
||||
|
||||
The content is likely in {{.Language}}.
|
||||
|
||||
<original_title>{{.Title}}</original_title>
|
||||
<content>
|
||||
{{.Content}}
|
||||
</content>
|
||||
87
modules/hosts/_parts/tahani/paperless.nix
Normal file
87
modules/hosts/_parts/tahani/paperless.nix
Normal file
@@ -0,0 +1,87 @@
|
||||
{config, ...}: {
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
enableReload = false;
|
||||
globalConfig = ''
|
||||
admin off
|
||||
'';
|
||||
virtualHosts."docs.manticore-hippocampus.ts.net" = {
|
||||
extraConfig = ''
|
||||
tls {
|
||||
get_certificate tailscale
|
||||
}
|
||||
reverse_proxy localhost:${toString config.services.paperless.port}
|
||||
'';
|
||||
};
|
||||
virtualHosts."docs-ai.manticore-hippocampus.ts.net" = {
|
||||
extraConfig = ''
|
||||
tls {
|
||||
get_certificate tailscale
|
||||
}
|
||||
reverse_proxy localhost:8081
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
virtualisation.oci-containers = {
|
||||
backend = "docker";
|
||||
containers.paperless-gpt = {
|
||||
image = "icereed/paperless-gpt:latest";
|
||||
autoStart = true;
|
||||
ports = [
|
||||
"127.0.0.1:8081:8080"
|
||||
];
|
||||
volumes = [
|
||||
"paperless-gpt-data:/app/data"
|
||||
"paperless-gpt-prompts:/app/prompts"
|
||||
"${./paperless-gpt-prompts/tag_prompt.tmpl}:/app/prompts/tag_prompt.tmpl:ro"
|
||||
"${./paperless-gpt-prompts/title_prompt.tmpl}:/app/prompts/title_prompt.tmpl:ro"
|
||||
];
|
||||
environment = {
|
||||
PAPERLESS_BASE_URL = "http://host.docker.internal:${toString config.services.paperless.port}";
|
||||
LLM_PROVIDER = "openai";
|
||||
LLM_MODEL = "gpt-5.4";
|
||||
LLM_LANGUAGE = "German";
|
||||
VISION_LLM_PROVIDER = "openai";
|
||||
VISION_LLM_MODEL = "gpt-5.4";
|
||||
LOG_LEVEL = "info";
|
||||
};
|
||||
environmentFiles = [
|
||||
config.sops.secrets.tahani-paperless-gpt-env.path
|
||||
];
|
||||
extraOptions = [
|
||||
"--add-host=host.docker.internal:host-gateway"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services.redis.servers.paperless = {
|
||||
enable = true;
|
||||
port = 6379;
|
||||
bind = "127.0.0.1";
|
||||
settings = {
|
||||
maxmemory = "256mb";
|
||||
maxmemory-policy = "allkeys-lru";
|
||||
};
|
||||
};
|
||||
|
||||
services.paperless = {
|
||||
enable = true;
|
||||
address = "0.0.0.0";
|
||||
consumptionDir = "/var/lib/paperless/consume";
|
||||
passwordFile = config.sops.secrets.tahani-paperless-password.path;
|
||||
settings = {
|
||||
PAPERLESS_DBENGINE = "sqlite";
|
||||
PAPERLESS_REDIS = "redis://127.0.0.1:6379";
|
||||
PAPERLESS_CONSUMER_IGNORE_PATTERN = [
|
||||
".DS_STORE/*"
|
||||
"desktop.ini"
|
||||
];
|
||||
PAPERLESS_CONSUMER_POLLING = 30;
|
||||
PAPERLESS_CONSUMER_RECURSIVE = true;
|
||||
PAPERLESS_CONSUMER_SUBDIRS_AS_TAGS = true;
|
||||
PAPERLESS_OCR_LANGUAGE = "deu+eng";
|
||||
PAPERLESS_CSRF_TRUSTED_ORIGINS = "https://docs.manticore-hippocampus.ts.net";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user