1
0
Fork 0

Services: set default home dirs

This commit is contained in:
Aires 2024-09-07 13:44:14 -04:00
parent f698214b28
commit e0da7c527f
9 changed files with 55 additions and 38 deletions

View file

@ -38,4 +38,12 @@ in
config = lib.mkIf cfg.enable {
# Add changes applied by this module here.
};
systemd.services = {
# Forces systemd to wait for the module's configuration directory to be available before starting the service.
myModule.unitConfig.RequiresMountsFor = cfg.home;
# Tells Nginx to wait for the service to be available before coming online.
nginx.wants = [ config.systemd.services.myModule.name ];
};
}

View file

@ -9,13 +9,11 @@ in
enable = lib.mkEnableOption (
lib.mdDoc "Enable the ACME client (for Let's Encrypt TLS certificates)."
);
certs = lib.mkOption {
default = { };
type = lib.types.attrs;
description = "Cert configurations for ACME.";
};
defaultEmail = lib.mkOption {
default = "";
type = lib.types.str;

View file

@ -70,7 +70,7 @@ in
};
systemd.services = {
airsonic = lib.mkIf (cfg.home != "") { unitConfig.RequiresMountsFor = cfg.home; };
airsonic.unitConfig.RequiresMountsFor = cfg.home;
nginx.wants = [ config.systemd.services.airsonic.name ];
};
};

View file

@ -58,6 +58,7 @@ in
User = "root";
};
path = config.aux.system.corePackages;
unitConfig.RequiresMountsFor = cfg.configDir;
# Git diffing strategy courtesy of https://stackoverflow.com/a/40255467
script = ''
cd ${cfg.configDir}
@ -94,6 +95,7 @@ in
User = cfg.user;
};
path = config.aux.system.corePackages;
unitConfig.RequiresMountsFor = cfg.configDir;
script = ''
set -eu
cd ${cfg.configDir}

View file

@ -52,6 +52,9 @@ in
};
};
systemd.services.deluge = lib.mkIf (cfg.home != "") { unitConfig.RequiresMountsFor = cfg.home; };
systemd.services = {
deluge.unitConfig.RequiresMountsFor = cfg.home;
nginx.wants = [ config.systemd.services.deluge.name ];
};
};
}

View file

@ -46,6 +46,7 @@ in
environment = {
HOME = cfg.home;
};
} // lib.optionalAttrs (cfg.home != "") { unitConfig.RequiresMountsFor = cfg.home; };
unitConfig.RequiresMountsFor = cfg.home;
};
};
}

View file

@ -124,7 +124,7 @@ in
};
systemd.services = {
forgejo = lib.mkIf (cfg.home != "") { unitConfig.RequiresMountsFor = cfg.home; };
forgejo.unitConfig.RequiresMountsFor = cfg.home;
nginx.wants = [ config.systemd.services.forgejo.name ];
};
};

View file

@ -32,41 +32,46 @@ in
config = lib.mkIf cfg.enable {
services = {
home-assistant = {
# opt-out from declarative configuration management
config = null;
lovelaceConfig = null;
# configure the path to your config directory
configDir = cfg.home;
# specify list of components required by your configuration
extraComponents = [
"esphome"
"eufy"
"govee_light_local"
"met"
"radio_browser"
"tplink"
];
};
nginx.virtualHosts."${cfg.url}" = {
useACMEHost = cfg.domain;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:8123";
proxyWebsockets = true;
extraConfig = ''
# Security / XSS Mitigation Headers
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
# opt-out from declarative configuration management
config = null;
lovelaceConfig = null;
# configure the path to your config directory
configDir = cfg.home;
# specify list of components required by your configuration
extraComponents = [
"esphome"
"eufy"
"govee_light_local"
"met"
"radio_browser"
"tplink"
];
};
nginx.virtualHosts."${cfg.url}" = {
useACMEHost = cfg.domain;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:8123";
proxyWebsockets = true;
extraConfig = ''
# Security / XSS Mitigation Headers
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
proxy_ssl_server_name on;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_ssl_server_name on;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_buffering off;
'';
proxy_buffering off;
'';
};
};
};
systemd.services = {
home-assistant.unitConfig.RequiresMountsFor = cfg.home;
nginx.wants = [ config.systemd.services.home-assistant.name ];
};
};
}

View file

@ -97,7 +97,7 @@ in
];
systemd.services = {
jellyfin = lib.mkIf (cfg.home != "") { unitConfig.RequiresMountsFor = cfg.home; };
jellyfin.unitConfig.RequiresMountsFor = cfg.home;
nginx.wants = [ config.systemd.services.jellyfin.name ];
};
};