From 8bd5cace11e0d803fd8ee0851ea945780aafa2ca Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Mon, 18 Aug 2025 16:17:35 +0200 Subject: [PATCH] update vm file, fix README, add working dir in module --- README.md | 2 +- config.yml.example | 1 - module.nix | 2 ++ vm-eintopf.nix | 29 ----------------------------- vm-mail-quota-warning.py | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 31 deletions(-) delete mode 100644 vm-eintopf.nix create mode 100644 vm-mail-quota-warning.py diff --git a/README.md b/README.md index fb4e9a3..d5a6110 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Add the module to your `flake.nix`: Add this to your `configuration.nix` file ```nix -environment.etc."eintopf-radar-sync-secrets.yml".text = '' +environment.etc."mail-quota-warning-secrets.yml".text = '' accounts: - name: Sales imap_server: mail.example.com diff --git a/config.yml.example b/config.yml.example index 9b3f4ff..dfc6526 100644 --- a/config.yml.example +++ b/config.yml.example @@ -1,6 +1,5 @@ check_interval_days: 7 # Minimum days between warnings for same account quota_warning_threshold_percent: 80 -working_dir: /var/lib/mail-quota-warning accounts: - name: Sales diff --git a/module.nix b/module.nix index 5e729a9..e9f322b 100644 --- a/module.nix +++ b/module.nix @@ -96,6 +96,8 @@ in serviceConfig = { Type = "simple"; ExecStart = "${lib.getExe pkgs.mail-quota-warning}${lib.optionalString (cfg.secretFile != null) " --config ${cfg.secretFile}"}"; + WorkingDirectory = "%S/mail-quota-warning"; + StateDirectory = "mail-quota-warning"; # hardening AmbientCapabilities = ""; diff --git a/vm-eintopf.nix b/vm-eintopf.nix deleted file mode 100644 index f4933d6..0000000 --- a/vm-eintopf.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ pkgs, ... }: -let - - template-karlsunruh = pkgs.stdenv.mkDerivation { - name = "karlsunruh"; - src = pkgs.fetchgit { - url = "https://git.project-insanity.org/onny/eintopf-karlsunruh.git"; - rev = "0c2a36574260da70da80b379d7475af7b29849c9"; - hash = "sha256-GPKlqpztl4INqVyz/4y/vVrkDPHA3rIxtUZB9LNZ96c="; - }; - dontBuild = true; - installPhase = '' - cp -r . $out/ - ''; - }; - -in -{ - - services.eintopf = { - enable = true; - settings = { - EINTOPF_THEMES = "eintopf,${template-karlsunruh}"; - EINTOPF_ADMIN_PASSWORD = "foobar23"; - EINTOPF_ADMIN_EMAIL = "onny@project-insanity.org"; - }; - }; - -} diff --git a/vm-mail-quota-warning.py b/vm-mail-quota-warning.py new file mode 100644 index 0000000..7cfe699 --- /dev/null +++ b/vm-mail-quota-warning.py @@ -0,0 +1,38 @@ +{ pkgs, ... }: +{ + + environment.etc."mail-quota-warning-secrets.yml".text = '' + accounts: + - name: Sales + imap_server: mail.example.com + imap_port: 993 + username: sales@example.com + password: secret + + - name: Support + imap_server: mail.example.com + imap_port: 993 + username: support@example.com + password: secret + + mail: + smtp_server: mail.example.com + smtp_port: 587 + smtp_username: monitoring@example.com + smtp_password: secret + from_address: monitoring@example.com + recipients: + - admin1@example.com + - admin2@example.com + ''; + + services.mail-quota-warning = { + enable = true; + settings = { + CHECK_INTERVAL_DAYS = 7; + QUOTA_WARNING_THRESHOLD_PERCENT = 80; + }; + secretFile = /etc/mail-quota-warning-secrets.yml; + }; + +}