Services: set default home dirs
This commit is contained in:
parent
f698214b28
commit
1602eb0464
|
@ -38,4 +38,12 @@ in
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
# Add changes applied by this module here.
|
# 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 ];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,11 @@ in
|
||||||
enable = lib.mkEnableOption (
|
enable = lib.mkEnableOption (
|
||||||
lib.mdDoc "Enable the ACME client (for Let's Encrypt TLS certificates)."
|
lib.mdDoc "Enable the ACME client (for Let's Encrypt TLS certificates)."
|
||||||
);
|
);
|
||||||
|
|
||||||
certs = lib.mkOption {
|
certs = lib.mkOption {
|
||||||
default = { };
|
default = { };
|
||||||
type = lib.types.attrs;
|
type = lib.types.attrs;
|
||||||
description = "Cert configurations for ACME.";
|
description = "Cert configurations for ACME.";
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultEmail = lib.mkOption {
|
defaultEmail = lib.mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
|
|
|
@ -12,7 +12,7 @@ in
|
||||||
aux.system.services.airsonic = {
|
aux.system.services.airsonic = {
|
||||||
enable = lib.mkEnableOption (lib.mdDoc "Enables Airsonic Advanced media streaming service.");
|
enable = lib.mkEnableOption (lib.mdDoc "Enables Airsonic Advanced media streaming service.");
|
||||||
home = lib.mkOption {
|
home = lib.mkOption {
|
||||||
default = "";
|
default = "/var/lib/airsonic";
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "Where to store Airsonic's files";
|
description = "Where to store Airsonic's files";
|
||||||
};
|
};
|
||||||
|
@ -70,7 +70,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services = {
|
||||||
airsonic = lib.mkIf (cfg.home != "") { unitConfig.RequiresMountsFor = cfg.home; };
|
airsonic.unitConfig.RequiresMountsFor = cfg.home;
|
||||||
nginx.wants = [ config.systemd.services.airsonic.name ];
|
nginx.wants = [ config.systemd.services.airsonic.name ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,6 +58,7 @@ in
|
||||||
User = "root";
|
User = "root";
|
||||||
};
|
};
|
||||||
path = config.aux.system.corePackages;
|
path = config.aux.system.corePackages;
|
||||||
|
unitConfig.RequiresMountsFor = cfg.configDir;
|
||||||
# Git diffing strategy courtesy of https://stackoverflow.com/a/40255467
|
# Git diffing strategy courtesy of https://stackoverflow.com/a/40255467
|
||||||
script = ''
|
script = ''
|
||||||
cd ${cfg.configDir}
|
cd ${cfg.configDir}
|
||||||
|
@ -94,6 +95,7 @@ in
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
};
|
};
|
||||||
path = config.aux.system.corePackages;
|
path = config.aux.system.corePackages;
|
||||||
|
unitConfig.RequiresMountsFor = cfg.configDir;
|
||||||
script = ''
|
script = ''
|
||||||
set -eu
|
set -eu
|
||||||
cd ${cfg.configDir}
|
cd ${cfg.configDir}
|
||||||
|
|
|
@ -9,7 +9,7 @@ in
|
||||||
aux.system.services.deluge = {
|
aux.system.services.deluge = {
|
||||||
enable = lib.mkEnableOption "Enables Deluge.";
|
enable = lib.mkEnableOption "Enables Deluge.";
|
||||||
home = lib.mkOption {
|
home = lib.mkOption {
|
||||||
default = "";
|
default = "/var/lib/deluge";
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "Where to store Deluge's files";
|
description = "Where to store Deluge's files";
|
||||||
};
|
};
|
||||||
|
@ -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 ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ in
|
||||||
aux.system.services.duplicacy-web = {
|
aux.system.services.duplicacy-web = {
|
||||||
enable = lib.mkEnableOption "Enables duplicacy-web";
|
enable = lib.mkEnableOption "Enables duplicacy-web";
|
||||||
home = lib.mkOption {
|
home = lib.mkOption {
|
||||||
default = "";
|
default = "/var/lib/duplicacy-web";
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "Environment where duplicacy-web stores its config files";
|
description = "Environment where duplicacy-web stores its config files";
|
||||||
};
|
};
|
||||||
|
@ -46,6 +46,7 @@ in
|
||||||
environment = {
|
environment = {
|
||||||
HOME = cfg.home;
|
HOME = cfg.home;
|
||||||
};
|
};
|
||||||
} // lib.optionalAttrs (cfg.home != "") { unitConfig.RequiresMountsFor = cfg.home; };
|
unitConfig.RequiresMountsFor = cfg.home;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ in
|
||||||
aux.system.services.forgejo = {
|
aux.system.services.forgejo = {
|
||||||
enable = lib.mkEnableOption (lib.mdDoc "Enables Forgejo Git hosting service.");
|
enable = lib.mkEnableOption (lib.mdDoc "Enables Forgejo Git hosting service.");
|
||||||
domain = lib.mkOption {
|
domain = lib.mkOption {
|
||||||
default = "";
|
default = "/var/lib/forgejo";
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "The root domain that Forgejo will be hosted on.";
|
description = "The root domain that Forgejo will be hosted on.";
|
||||||
example = "example.com";
|
example = "example.com";
|
||||||
|
@ -124,7 +124,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services = {
|
||||||
forgejo = lib.mkIf (cfg.home != "") { unitConfig.RequiresMountsFor = cfg.home; };
|
forgejo.unitConfig.RequiresMountsFor = cfg.home;
|
||||||
nginx.wants = [ config.systemd.services.forgejo.name ];
|
nginx.wants = [ config.systemd.services.forgejo.name ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,41 +32,46 @@ in
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
services = {
|
services = {
|
||||||
home-assistant = {
|
home-assistant = {
|
||||||
# opt-out from declarative configuration management
|
# opt-out from declarative configuration management
|
||||||
config = null;
|
config = null;
|
||||||
lovelaceConfig = null;
|
lovelaceConfig = null;
|
||||||
# configure the path to your config directory
|
# configure the path to your config directory
|
||||||
configDir = cfg.home;
|
configDir = cfg.home;
|
||||||
# specify list of components required by your configuration
|
# specify list of components required by your configuration
|
||||||
extraComponents = [
|
extraComponents = [
|
||||||
"esphome"
|
"esphome"
|
||||||
"eufy"
|
"eufy"
|
||||||
"govee_light_local"
|
"govee_light_local"
|
||||||
"met"
|
"met"
|
||||||
"radio_browser"
|
"radio_browser"
|
||||||
"tplink"
|
"tplink"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
nginx.virtualHosts."${cfg.url}" = {
|
nginx.virtualHosts."${cfg.url}" = {
|
||||||
useACMEHost = cfg.domain;
|
useACMEHost = cfg.domain;
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://127.0.0.1:8123";
|
proxyPass = "http://127.0.0.1:8123";
|
||||||
proxyWebsockets = true;
|
proxyWebsockets = true;
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
# Security / XSS Mitigation Headers
|
# Security / XSS Mitigation Headers
|
||||||
add_header X-Frame-Options "SAMEORIGIN";
|
add_header X-Frame-Options "SAMEORIGIN";
|
||||||
add_header X-Content-Type-Options "nosniff";
|
add_header X-Content-Type-Options "nosniff";
|
||||||
|
|
||||||
proxy_ssl_server_name on;
|
proxy_ssl_server_name on;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
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 ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ in
|
||||||
aux.system.services.jellyfin = {
|
aux.system.services.jellyfin = {
|
||||||
enable = lib.mkEnableOption (lib.mdDoc "Enables the Jellyfin media streaming service.");
|
enable = lib.mkEnableOption (lib.mdDoc "Enables the Jellyfin media streaming service.");
|
||||||
home = lib.mkOption {
|
home = lib.mkOption {
|
||||||
default = "";
|
default = "/var/lib/jellyfin";
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
description = "Where to store Jellyfin's files";
|
description = "Where to store Jellyfin's files";
|
||||||
};
|
};
|
||||||
|
@ -97,7 +97,7 @@ in
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services = {
|
||||||
jellyfin = lib.mkIf (cfg.home != "") { unitConfig.RequiresMountsFor = cfg.home; };
|
jellyfin.unitConfig.RequiresMountsFor = cfg.home;
|
||||||
nginx.wants = [ config.systemd.services.jellyfin.name ];
|
nginx.wants = [ config.systemd.services.jellyfin.name ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue