Skip to content

Commit

Permalink
setup actualbudget service
Browse files Browse the repository at this point in the history
  • Loading branch information
nmasur committed Dec 26, 2024
1 parent 1cb5827 commit 6d8fb63
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 2 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@
dotfilesRepo = "https://github.com/nmasur/dotfiles";
hostnames = {
audiobooks = "read.${baseName}";
budget = "money.${baseName}";
files = "files.${baseName}";
git = "git.${baseName}";
influxdb = "influxdb.${baseName}";
Expand Down
1 change: 1 addition & 0 deletions hosts/flame/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ inputs.nixpkgs.lib.nixosSystem rec {
dotfiles.enable = true; # Clone dotfiles
neovim.enable = true;
giteaRunner.enable = true;
services.actualbudget.enable = true;
services.caddy.enable = true;
services.grafana.enable = true;
services.thelounge.enable = true;
Expand Down
4 changes: 4 additions & 0 deletions modules/common/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
type = lib.types.str;
description = "Hostname for audiobook server (Audiobookshelf).";
};
budget = lib.mkOption {
type = lib.types.str;
description = "Hostname for budgeting server (ActualBudget).";
};
files = lib.mkOption {
type = lib.types.str;
description = "Hostname for files server (Filebrowser).";
Expand Down
68 changes: 68 additions & 0 deletions modules/nixos/services/actualbudget.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{ config, lib, ... }:
{

options = {
services.actualbudget = {
enable = lib.mkEnableOption "ActualBudget budgeting service";
port = lib.mkOption {
type = lib.types.port;
description = "Port to use for the localhost";
default = 5006;
};
};
};

config = lib.mkIf config.services.actualbudget.enable {

virtualisation.podman.enable = lib.mkDefault true;

users.users.actualbudget = {
isSystemUser = true;
group = "shared";
uid = 980;
};

# Create budget directory, allowing others to manage it
systemd.tmpfiles.rules = [
"d /var/lib/actualbudget 0770 actualbudget shared"
];

virtualisation.oci-containers.containers.actualbudget = {
workdir = null;
volumes = [ "/var/lib/actualbudget:/data" ];
user = "${toString (builtins.toString config.users.users.actualbudget.uid)}";
pull = "missing";
privileged = false;
ports = [ "127.0.0.1:${builtins.toString config.services.actualbudget.port}:5006" ];
networks = [ ];
log-driver = "journald";
labels = {
app = "actualbudget";
};
image = "ghcr.io/actualbudget/actual-server:latest";
hostname = null;
environmentFiles = [ ];
environment = { };
dependsOn = [ ];
autoStart = true;
};

# Allow web traffic to Caddy
caddy.routes = [
{
match = [ { host = [ config.hostnames.budget ]; } ];
handle = [
{
handler = "reverse_proxy";
upstreams = [ { dial = "localhost:${builtins.toString config.services.actualbudget.port}"; } ];
}
];
}
];

# Configure Cloudflare DNS to point to this machine
services.cloudflare-dyndns.domains = [ config.hostnames.budget ];

};

}
4 changes: 2 additions & 2 deletions modules/nixos/services/backups.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@
dest = "${config.secretsDirectory}/restic";
};

services.restic.backups = {
services.restic.backups = lib.mkIf (config.backup.s3.glacierBucket != null) {
default = {
repository = "s3:s3.us-east-1.amazonaws.com/${config.backup.s3.glacierBucket}/restic";
paths = [ "/data/images" ];
paths = [ ];
environmentFile = config.secrets.s3-glacier.dest;
passwordFile = config.secrets.restic.dest;
pruneOpts = [
Expand Down
1 change: 1 addition & 0 deletions modules/nixos/services/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{

imports = [
./actualbudget.nix
./audiobookshelf.nix
./arr.nix
./backups.nix
Expand Down

0 comments on commit 6d8fb63

Please sign in to comment.