From 61cfdd25e7d693005c0aa6034d067d91abb7f845 Mon Sep 17 00:00:00 2001 From: Clara Dautermann Date: Sat, 15 Mar 2025 18:58:55 +0100 Subject: [PATCH] attempt to write paperless config --- configs/container_config.nix | 8 ++++++ configs/services/paperless.nix | 51 ++++++++++++++++++++++++++++++++++ flake.nix | 16 ++++++++++- 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 configs/services/paperless.nix diff --git a/configs/container_config.nix b/configs/container_config.nix index 8976e19..dc8541e 100644 --- a/configs/container_config.nix +++ b/configs/container_config.nix @@ -3,11 +3,19 @@ time.timeZone = "Europe/Berlin"; + # we want at least a possibility to download stuff, monitor activity and sudo environment.systemPackages = with pkgs; [ wget + htop sudo ]; + # because getting a nix shell is super annoying otherwise + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; + # zsh because I like it :3 programs.zsh.enable = true; diff --git a/configs/services/paperless.nix b/configs/services/paperless.nix new file mode 100644 index 0000000..81a4e35 --- /dev/null +++ b/configs/services/paperless.nix @@ -0,0 +1,51 @@ +{ lib, pkgs, config, ... }: +let + dbname = "paperless"; + dbuser = "paperless"; + dbpass = "paperless"; +in +{ + + services.paperless = { + enable = true; + consumptionDirIsPublic = true; + address = "192.168.178.51"; + user = dbuser; + settings = { + PAPERLESS_CONSUMER_IGNORE_PATTERN = [ + ".DS_STORE/*" + "desktop.ini" + ]; + PAPERLESS_OCR_LANGUAGE = "deu+eng"; + PAPERLESS_TIME_ZONE = "Europe/Berlin"; + PAPERLESS_CONSUMER_ENABLE_BARCODES = true; + PAPERLESS_CONSUMER_ENABLE_ASN_BARCODE = true; + PAPERLESS_CONSUMER_BARCODE_SCANNER = "ZXING"; + PAPERLESS_OCR_USER_ARGS = { + optimize = 1; + pdfa_image_compression = "lossless"; + }; + PAPERLESS_DBENGINE = "postgres"; + PAPERLESS_DBHOST = "/run/postgresql"; + PAPERLESS_DUSER = dbuser; + PAPERLESS_DBNAME = dbname; + PAPERLESS_DBPASS = dbpass; + }; + }; + + # enable a PostgreSQL DB + services.postgresql = { + enable = true; + ensureDatabases = [ dbname ]; + ensureUsers = [{ + name = dbuser; + ensureDBOwnership = true; + }]; + }; + + # Paperless-ngx also requires a redis cache + services.redis.enable = true; + + # 28981 is the default paperless web port + networking.firewall.allowedTCPPorts = [ 28981 ]; +} diff --git a/flake.nix b/flake.nix index 91d3cda..a9847e0 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,20 @@ ./configs/services/minecraft-server.nix ]; }; + + testserver = { + deployment = { + targetHost = "192.168.178.51"; + targetPort = 22; + targetUser = "root"; + }; + networking.hostName = "testserver"; + imports = [ + ./configs/container_config.nix + ./configs/services/paperless.nix + ]; + + }; }; }; -} \ No newline at end of file +}