rework actual-budget to be more generic with test
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{ lib, ... }:
|
||||
{ ... }:
|
||||
{
|
||||
_class = "clan.service";
|
||||
manifest.name = "actual-budget";
|
||||
@@ -6,49 +6,21 @@
|
||||
manifest.categories = [ "System" ];
|
||||
|
||||
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 =
|
||||
{
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
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}";
|
||||
};
|
||||
};
|
||||
};
|
||||
services.actual = {
|
||||
enable = lib.mkDefault true;
|
||||
};
|
||||
|
||||
clan.core.state.actual-budget.folders = [
|
||||
config.systemd.services.actual.serviceConfig.WorkingDirectory
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
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")
|
||||
|
||||
'';
|
||||
}
|
Reference in New Issue
Block a user