This commit is contained in:
mjallen18
2025-12-14 21:50:50 -06:00
parent 0012a019fc
commit 34539045e5
41 changed files with 164 additions and 251 deletions

View File

@@ -15,7 +15,7 @@ let
'';
in
{
options.mjallen.desktop.hyprland = {
options.${namespace}.desktop.hyprland = {
enable = mkEnableOption "enable hyprland desktop environment";
wallpaperSource = mkOpt (types.enum [

View File

@@ -29,7 +29,7 @@ let
{ }
else
{
address = cfg.ipv4.address;
address = "${cfg.ipv4.address}\\24";
gateway = cfg.ipv4.gateway;
dns = cfg.ipv4.dns;
}

View File

@@ -7,59 +7,42 @@
}:
with lib;
let
cfg = config.${namespace}.services.actual;
name = "actual";
cfg = config.${namespace}.services.${name};
actualConfig = {
services.actual = {
enable = true;
openFirewall = true;
settings = {
trustedProxies = [ "10.0.1.3" ];
port = cfg.port;
dataDir = cfg.dataDir;
serverFiles = "${cfg.dataDir}/server-files";
userFiles = "${cfg.dataDir}/user-files";
actualConfig = lib.${namespace}.mkModule rec {
inherit name;
description = "Actual Personal Finance Planner";
options = { };
moduleConfig = {
services.actual = {
enable = true;
openFirewall = true;
settings = {
trustedProxies = [ config.${namespace}.network.ipv4.address ];
port = cfg.port;
configDir = cfg.configDir;
serverFiles = "${cfg.configDir}/server-files";
userFiles = "${cfg.configDir}/user-files";
};
};
};
systemd.services = {
actual = {
environment.ACTUAL_CONFIG_PATH = lib.mkForce "${cfg.dataDir}/config.json";
serviceConfig = {
ExecStart = lib.mkForce "${lib.getExe pkgs.actual-server} --config ${cfg.dataDir}/config.json";
WorkingDirectory = lib.mkForce cfg.dataDir;
StateDirectoryMode = lib.mkForce 700;
DynamicUser = lib.mkForce false;
ProtectSystem = lib.mkForce "full";
systemd.services = lib.mkIf cfg.createUser {
actual = {
environment.ACTUAL_CONFIG_PATH = lib.mkForce "${cfg.configDir}/config.json";
serviceConfig = {
ExecStart = lib.mkForce "${lib.getExe pkgs.actual-server} --config ${cfg.configDir}/config.json";
WorkingDirectory = lib.mkForce cfg.configDir;
StateDirectoryMode = lib.mkForce 700;
DynamicUser = lib.mkForce false;
ProtectSystem = lib.mkForce "full";
};
};
};
};
users.users.actual = {
isSystemUser = true;
group = "actual";
home = cfg.dataDir;
};
users.groups.actual = { };
inherit config;
};
# Create reverse proxy configuration using mkReverseProxy
reverseProxyConfig = lib.${namespace}.mkReverseProxy {
name = "actual";
subdomain = cfg.reverseProxy.subdomain;
url = "http://${cfg.localAddress}:${toString cfg.port}";
middlewares = cfg.reverseProxy.middlewares;
};
fullConfig = {
"${namespace}".services.traefik = lib.mkIf cfg.reverseProxy.enable {
reverseProxies = [ reverseProxyConfig ];
};
}
// actualConfig;
in
{
imports = [ ./options.nix ];
config = mkIf cfg.enable fullConfig;
imports = [ actualConfig ];
}

View File

@@ -1,104 +0,0 @@
{
config,
pkgs,
lib,
namespace,
...
}:
with lib;
let
cfg = config.${namespace}.services.actual;
dataDir = "/data";
hostAddress = "10.0.1.3";
actualUserId = config.users.users.nix-apps.uid;
actualGroupId = config.users.groups.jallen-nas.gid;
actualConfig = {
services.actual = {
enable = true;
openFirewall = true;
settings = {
trustedProxies = [ hostAddress ];
port = cfg.port;
dataDir = dataDir;
serverFiles = "${dataDir}/server-files";
userFiles = "${dataDir}/user-files";
};
};
users.users.actual = {
isSystemUser = true;
uid = lib.mkForce actualUserId;
group = "actual";
};
users.groups = {
actual = {
gid = lib.mkForce actualGroupId;
};
};
# System packages
environment.systemPackages = with pkgs; [
sqlite
];
# Create and set permissions for required directories
system.activationScripts.actual-dirs = ''
mkdir -p ${dataDir}
chown -R actual:actual ${dataDir}
chmod -R 0700 ${dataDir}
'';
systemd.services = {
actual = {
environment.ACTUAL_CONFIG_PATH = lib.mkForce "${dataDir}/config.json";
serviceConfig = {
ExecStart = lib.mkForce "${lib.getExe pkgs.actual-server} --config ${dataDir}/config.json";
WorkingDirectory = lib.mkForce dataDir;
StateDirectory = lib.mkForce dataDir;
StateDirectoryMode = lib.mkForce 700;
DynamicUser = lib.mkForce false;
ProtectSystem = lib.mkForce null;
};
};
};
};
bindMounts = {
"${dataDir}" = {
hostPath = cfg.dataDir;
isReadOnly = false;
};
};
# Create reverse proxy configuration using mkReverseProxy
reverseProxyConfig = lib.${namespace}.mkReverseProxy {
name = "actual";
subdomain = cfg.reverseProxy.subdomain;
url = "http://${cfg.localAddress}:${toString cfg.port}";
middlewares = cfg.reverseProxy.middlewares;
};
actualContainer =
(lib.${namespace}.mkContainer {
name = "actual";
localAddress = cfg.localAddress;
ports = [ cfg.port ];
bindMounts = bindMounts;
config = actualConfig;
})
{ inherit lib; };
fullConfig = {
"${namespace}".services.traefik = lib.mkIf cfg.reverseProxy.enable {
reverseProxies = [ reverseProxyConfig ];
};
}
// actualContainer;
in
{
imports = [ ./options.nix ];
config = mkIf cfg.enable fullConfig;
}

View File

@@ -1,18 +0,0 @@
{ lib, namespace, ... }:
let
inherit (lib.${namespace}) mkOpt mkReverseProxyOpt;
in
with lib;
{
options.${namespace}.services.actual = {
enable = mkEnableOption "actual service";
port = mkOpt types.int 80 "Port for Actual to be hosted on";
localAddress = mkOpt types.str "127.0.0.1" "local address of the service";
dataDir = mkOpt types.str "" "Path to the data dir";
reverseProxy = mkReverseProxyOpt;
};
}

View File

@@ -7,7 +7,7 @@
with lib;
let
cfg = config.${namespace}.services.gitea;
rootUrl = "https://gitea.mjallen.dev/";
rootUrl = "https://gitea.${namespace}.dev/";
mailerPasswordFile = config.sops.secrets."jallen-nas/gitea/mail-key".path;
metricsTokenFile = config.sops.secrets."jallen-nas/gitea/metrics-key".path;

View File

@@ -1,7 +1,7 @@
{ lib, ... }:
{ lib, namespace, ... }:
with lib;
{
options.mjallen.sops = {
options.${namespace}.sops = {
enable = mkEnableOption "enable sops";
defaultSopsFile = mkOption {