rework actual-budget to be more generic with test
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
clan = {
|
clan = {
|
||||||
modules = {
|
modules = {
|
||||||
stirling-pdf = ../modules/clan/stirling-pdf;
|
stirling-pdf = ../modules/clan/stirling-pdf;
|
||||||
actual-budget = ../modules/clan/actual-budget;
|
|
||||||
victoria-metrics = ../modules/clan/victoria-metrics;
|
victoria-metrics = ../modules/clan/victoria-metrics;
|
||||||
};
|
};
|
||||||
inventory = {
|
inventory = {
|
||||||
|
36
machines/b4l/services/actual-budget.nix
Normal file
36
machines/b4l/services/actual-budget.nix
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
let
|
||||||
|
abDomain = "${config.clan.core.vars.generators.b4l-actual-budget.files.subdomain.value}.${config.networking.fqdn}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
clan.core.vars.generators.b4l-actual-budget = {
|
||||||
|
files.subdomain.secret = false;
|
||||||
|
|
||||||
|
prompts = {
|
||||||
|
subdomain = {
|
||||||
|
persist = true;
|
||||||
|
type = "line";
|
||||||
|
description = "Sub-domain for Actual Budget app. Default:(budget)";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
script = ''cat $prompts/subdomain || echo -n "budget" > $out/subdomain'';
|
||||||
|
};
|
||||||
|
|
||||||
|
services.actual = {
|
||||||
|
settings = {
|
||||||
|
allowedLoginMethods = [
|
||||||
|
"password"
|
||||||
|
"openid"
|
||||||
|
];
|
||||||
|
trustedProxies = [ "127.0.0.1" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
services.nginx.virtualHosts."${abDomain}" = {
|
||||||
|
useACMEHost = "${config.networking.fqdn}";
|
||||||
|
forceSSL = true;
|
||||||
|
locations."/" = {
|
||||||
|
proxyPass = "http://localhost:${builtins.toString config.services.actual.settings.port}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
{ lib, ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
_class = "clan.service";
|
_class = "clan.service";
|
||||||
manifest.name = "actual-budget";
|
manifest.name = "actual-budget";
|
||||||
@@ -6,49 +6,21 @@
|
|||||||
manifest.categories = [ "System" ];
|
manifest.categories = [ "System" ];
|
||||||
|
|
||||||
roles.default = {
|
roles.default = {
|
||||||
interface.options = {
|
|
||||||
domain = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "budget";
|
|
||||||
description = "Sub domain for Actual Budget.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
perInstance =
|
perInstance.nixosModule =
|
||||||
{
|
{
|
||||||
settings,
|
lib,
|
||||||
|
config,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
nixosModule =
|
services.actual = {
|
||||||
{
|
enable = lib.mkDefault true;
|
||||||
config,
|
};
|
||||||
...
|
|
||||||
}:
|
clan.core.state.actual-budget.folders = [
|
||||||
let
|
config.systemd.services.actual.serviceConfig.WorkingDirectory
|
||||||
domain = "${settings.domain}.${config.networking.fqdn}";
|
];
|
||||||
in
|
|
||||||
{
|
|
||||||
services.actual = {
|
|
||||||
enable = true;
|
|
||||||
openFirewall = true;
|
|
||||||
settings = {
|
|
||||||
port = 5006;
|
|
||||||
allowedLoginMethods = [
|
|
||||||
"password"
|
|
||||||
"openid"
|
|
||||||
];
|
|
||||||
trustedProxies = [ "127.0.0.1" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
services.nginx.virtualHosts."${domain}" = {
|
|
||||||
forceSSL = true;
|
|
||||||
useACMEHost = "${config.networking.fqdn}";
|
|
||||||
locations."/" = {
|
|
||||||
proxyPass = "http://localhost:${builtins.toString config.services.actual.settings.port}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
19
modules/clan/actual-budget/flake-module.nix
Normal file
19
modules/clan/actual-budget/flake-module.nix
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
module = lib.modules.importApply ./default.nix { };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
clan.modules = {
|
||||||
|
actual-budget = module;
|
||||||
|
};
|
||||||
|
|
||||||
|
perSystem =
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
clan.nixosTests.actual-budget = {
|
||||||
|
imports = [ ./tests/vm/default.nix ];
|
||||||
|
|
||||||
|
clan.modules."@clan/actual-budget" = module;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
34
modules/clan/actual-budget/tests/vm/default.nix
Normal file
34
modules/clan/actual-budget/tests/vm/default.nix
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
name = "service-actual-budget";
|
||||||
|
|
||||||
|
clan = {
|
||||||
|
directory = ./.;
|
||||||
|
inventory = {
|
||||||
|
machines.server = { };
|
||||||
|
|
||||||
|
instances = {
|
||||||
|
actual-budget-test = {
|
||||||
|
module.name = "@clan/actual-budget";
|
||||||
|
module.input = "self";
|
||||||
|
roles.default.machines."server".settings = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nodes = {
|
||||||
|
server = { };
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
|
||||||
|
server.wait_for_unit("actual")
|
||||||
|
|
||||||
|
server.succeed("systemctl status actual")
|
||||||
|
|
||||||
|
'';
|
||||||
|
}
|
1
vars/per-machine/b4l/b4l-actual-budget/subdomain/value
Normal file
1
vars/per-machine/b4l/b4l-actual-budget/subdomain/value
Normal file
@@ -0,0 +1 @@
|
|||||||
|
budget
|
Reference in New Issue
Block a user