From e558859799be192b16d7f294ee95e0c7ddd87330 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Fri, 11 Apr 2025 22:48:23 +0200 Subject: [PATCH] Enable actualbudget on alto --- hosts/alto/default.nix | 14 ++++++-- modules/system/actualbudget/backups.nix | 33 +++++++++++++++++++ modules/system/actualbudget/default.nix | 44 +++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 modules/system/actualbudget/backups.nix create mode 100644 modules/system/actualbudget/default.nix diff --git a/hosts/alto/default.nix b/hosts/alto/default.nix index 3c101e3..f386f4f 100644 --- a/hosts/alto/default.nix +++ b/hosts/alto/default.nix @@ -17,8 +17,13 @@ in target = "localhost:${toString myConfig.hedgedoc.port}"; }; - caddyServe.nextcloud = { - inherit (myConfig.nextcloud) subdomain port; + caddyServe = { + nextcloud = { + inherit (myConfig.nextcloud) subdomain port; + }; + actualbudget = { + inherit (myConfig.actualbudget) subdomain port; + }; }; }; @@ -27,6 +32,11 @@ in backups.enable = true; subdomain = "cloud"; }; + actualbudget = { + enable = true; + backups.enable = true; + subdomain = "budget"; + }; hedgedoc = { enable = true; backups.enable = true; diff --git a/modules/system/actualbudget/backups.nix b/modules/system/actualbudget/backups.nix new file mode 100644 index 0000000..4f0a2b2 --- /dev/null +++ b/modules/system/actualbudget/backups.nix @@ -0,0 +1,33 @@ +{ + config, + pkgs, + lib, + ... +}: +{ + options.myConfig.actualbudget.backups.enable = lib.mkEnableOption ""; + + config = lib.mkIf config.myConfig.actualbudget.backups.enable { + myConfig.resticBackup.actual = { + enable = true; + healthchecks.enable = true; + + extraConfig = { + backupPrepareCommand = "${lib.getExe' pkgs.systemd "systemctl"} stop actual.service"; + backupCleanupCommand = "${lib.getExe' pkgs.systemd "systemctl"} start actual.service"; + paths = [ "/var/lib/actual" ]; + }; + }; + + environment.systemPackages = [ + (pkgs.writeShellApplication { + name = "actual-restore"; + text = '' + sudo systemctl stop actual.service + sudo restic-actual restore latest --target / + sudo systemctl start actual.service + ''; + }) + ]; + }; +} diff --git a/modules/system/actualbudget/default.nix b/modules/system/actualbudget/default.nix new file mode 100644 index 0000000..dc31a87 --- /dev/null +++ b/modules/system/actualbudget/default.nix @@ -0,0 +1,44 @@ +{ + config, + inputs, + pkgs-unstable, + lib, + ... +}: +let + cfg = config.myConfig.actualbudget; +in +{ + disabledModules = [ "services/web-apps/actual.nix" ]; + imports = [ "${inputs.nixpkgs-unstable}/nixos/modules/services/web-apps/actual.nix" ]; + + options.myConfig.actualbudget = { + enable = lib.mkEnableOption ""; + subdomain = lib.mkOption { + type = lib.types.nonEmptyStr; + default = ""; + }; + port = lib.mkOption { + type = lib.types.port; + default = 8080; + }; + }; + + config = lib.mkIf cfg.enable { + users.groups.actual = { }; + users.users.actual = { + isSystemUser = true; + group = "actual"; + }; + + services.actual = { + enable = true; + package = pkgs-unstable.actual-server; + + settings = { + hostname = "localhost"; + inherit (cfg) port; + }; + }; + }; +}