mirror of
https://github.com/tuxdotrs/nix-config.git
synced 2026-09-19 16:49:04 +05:30
refactor(services): standardize service module options
This commit is contained in:
@@ -8,19 +8,29 @@
|
|||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.tnix.services.aiostreams;
|
cfg = config.tnix.services.aiostreams;
|
||||||
|
port = toString cfg.port;
|
||||||
|
acmeHost = config.tnix.services.nginx.domain;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.tnix.services.aiostreams = {
|
options.tnix.services.aiostreams = {
|
||||||
enable = mkEnableOption "Enable AIOStreams";
|
enable = mkEnableOption "AIOStreams";
|
||||||
|
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.int;
|
type = types.port;
|
||||||
default = 3000;
|
default = 3000;
|
||||||
|
description = "Port on which AIOStreams listens";
|
||||||
};
|
};
|
||||||
|
|
||||||
domain = mkOption {
|
domain = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "";
|
default = "";
|
||||||
|
description = "Domain on which nginx serves AIOStreams (disabled when empty)";
|
||||||
|
};
|
||||||
|
|
||||||
|
image = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "ghcr.io/viren070/aiostreams:latest";
|
||||||
|
description = "Container image to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
dataDir = mkOption {
|
dataDir = mkOption {
|
||||||
@@ -30,33 +40,33 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
environmentFile = mkOption {
|
environmentFile = mkOption {
|
||||||
type = with types; path;
|
type = types.nullOr types.path;
|
||||||
default = "";
|
default = null;
|
||||||
|
description = "Environment file with secrets passed to the container";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
virtualisation.oci-containers.containers.aiostreams = {
|
virtualisation.oci-containers.containers.aiostreams = {
|
||||||
autoStart = true;
|
image = cfg.image;
|
||||||
image = "ghcr.io/viren070/aiostreams:latest";
|
|
||||||
ports = [
|
ports = [
|
||||||
"${toString cfg.port}:3000"
|
"127.0.0.1:${port}:3000"
|
||||||
];
|
];
|
||||||
environment = {
|
environment = {
|
||||||
ADDON_ID = "${cfg.domain}";
|
ADDON_ID = cfg.domain;
|
||||||
BASE_URL = "https://${cfg.domain}";
|
BASE_URL = "https://${cfg.domain}";
|
||||||
};
|
};
|
||||||
environmentFiles = [ cfg.environmentFile ];
|
environmentFiles = optional (cfg.environmentFile != null) cfg.environmentFile;
|
||||||
volumes = [
|
volumes = [
|
||||||
"${cfg.dataDir}:/app/data"
|
"${cfg.dataDir}:/app/data"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx.virtualHosts.${cfg.domain} = {
|
services.nginx.virtualHosts.${cfg.domain} = mkIf (cfg.domain != "") {
|
||||||
forceSSL = true;
|
forceSSL = acmeHost != "";
|
||||||
useACMEHost = config.tnix.services.nginx.domain;
|
useACMEHost = mkIf (acmeHost != "") acmeHost;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://localhost:${toString cfg.port}";
|
proxyPass = "http://127.0.0.1:${port}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
dataDir = mkOption {
|
dataDir = mkOption {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
default = "/var/lib/cyber-tux";
|
default = "/var/lib/cyber-tux";
|
||||||
description = "Directory where CyberTux stores its data.";
|
description = "Directory where CyberTux stores its data (must be under /var/lib).";
|
||||||
};
|
};
|
||||||
|
|
||||||
environmentFile = mkOption {
|
environmentFile = mkOption {
|
||||||
@@ -41,7 +41,8 @@
|
|||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
systemd.services.cyber-tux = {
|
systemd.services.cyber-tux = {
|
||||||
description = "CyberTux Discord bot";
|
description = "CyberTux Discord bot";
|
||||||
after = [ "network.target" ];
|
after = [ "network-online.target" ];
|
||||||
|
wants = [ "network-online.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
|||||||
@@ -8,46 +8,56 @@
|
|||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.tnix.services.mediaflow-proxy;
|
cfg = config.tnix.services.mediaflow-proxy;
|
||||||
|
port = toString cfg.port;
|
||||||
|
acmeHost = config.tnix.services.nginx.domain;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.tnix.services.mediaflow-proxy = {
|
options.tnix.services.mediaflow-proxy = {
|
||||||
enable = mkEnableOption "Enable MediaFlow Proxy";
|
enable = mkEnableOption "MediaFlow Proxy";
|
||||||
|
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.int;
|
type = types.port;
|
||||||
default = 8888;
|
default = 8888;
|
||||||
|
description = "Port on which MediaFlow Proxy listens";
|
||||||
};
|
};
|
||||||
|
|
||||||
domain = mkOption {
|
domain = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "";
|
default = "";
|
||||||
|
description = "Domain on which nginx serves MediaFlow Proxy (disabled when empty)";
|
||||||
|
};
|
||||||
|
|
||||||
|
image = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "ghcr.io/mhdzumair/mediaflow-proxy-light:latest";
|
||||||
|
description = "Container image to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
environmentFile = mkOption {
|
environmentFile = mkOption {
|
||||||
type = with types; path;
|
type = types.nullOr types.path;
|
||||||
default = "";
|
default = null;
|
||||||
|
description = "Environment file with secrets passed to the container";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
virtualisation.oci-containers.containers.mediaflow-proxy = {
|
virtualisation.oci-containers.containers.mediaflow-proxy = {
|
||||||
autoStart = true;
|
image = cfg.image;
|
||||||
image = "ghcr.io/mhdzumair/mediaflow-proxy-light:latest";
|
|
||||||
ports = [
|
ports = [
|
||||||
"${toString cfg.port}:8888"
|
"${port}:${port}"
|
||||||
];
|
];
|
||||||
environment = {
|
environment = {
|
||||||
APP__SERVER__HOST = "0.0.0.0";
|
APP__SERVER__HOST = "0.0.0.0";
|
||||||
APP__SERVER__PORT = "${toString cfg.port}";
|
APP__SERVER__PORT = port;
|
||||||
};
|
};
|
||||||
environmentFiles = [ cfg.environmentFile ];
|
environmentFiles = optional (cfg.environmentFile != null) cfg.environmentFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx.virtualHosts.${cfg.domain} = {
|
services.nginx.virtualHosts.${cfg.domain} = mkIf (cfg.domain != "") {
|
||||||
forceSSL = true;
|
forceSSL = acmeHost != "";
|
||||||
useACMEHost = config.tnix.services.nginx.domain;
|
useACMEHost = mkIf (acmeHost != "") acmeHost;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://localhost:${toString cfg.port}";
|
proxyPass = "http://127.0.0.1:${port}";
|
||||||
proxyWebsockets = true;
|
proxyWebsockets = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,11 +12,12 @@
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.tnix.services.nginx = {
|
options.tnix.services.nginx = {
|
||||||
enable = mkEnableOption "Enable Nginx";
|
enable = mkEnableOption "Nginx";
|
||||||
|
|
||||||
domain = mkOption {
|
domain = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "";
|
default = "";
|
||||||
|
description = "Base domain for the wildcard ACME certificate (disabled when empty)";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -24,8 +25,8 @@
|
|||||||
security = {
|
security = {
|
||||||
acme = {
|
acme = {
|
||||||
acceptTerms = true;
|
acceptTerms = true;
|
||||||
defaults.email = "${userEmail}";
|
defaults.email = userEmail;
|
||||||
certs = {
|
certs = mkIf (cfg.domain != "") {
|
||||||
"${cfg.domain}" = {
|
"${cfg.domain}" = {
|
||||||
group = "nginx";
|
group = "nginx";
|
||||||
domain = "*.${cfg.domain}";
|
domain = "*.${cfg.domain}";
|
||||||
|
|||||||
@@ -8,19 +8,23 @@
|
|||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.tnix.services.vaultwarden;
|
cfg = config.tnix.services.vaultwarden;
|
||||||
|
port = toString cfg.port;
|
||||||
|
acmeHost = config.tnix.services.nginx.domain;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.tnix.services.vaultwarden = {
|
options.tnix.services.vaultwarden = {
|
||||||
enable = mkEnableOption "Enable Vaultwarden";
|
enable = mkEnableOption "Vaultwarden";
|
||||||
|
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.int;
|
type = types.port;
|
||||||
default = 8000;
|
default = 8000;
|
||||||
|
description = "Port on which Vaultwarden listens";
|
||||||
};
|
};
|
||||||
|
|
||||||
domain = mkOption {
|
domain = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "";
|
default = "";
|
||||||
|
description = "Domain on which nginx serves Vaultwarden (disabled when empty)";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,11 +45,11 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
nginx.virtualHosts.${cfg.domain} = {
|
nginx.virtualHosts.${cfg.domain} = mkIf (cfg.domain != "") {
|
||||||
forceSSL = true;
|
forceSSL = acmeHost != "";
|
||||||
useACMEHost = config.tnix.services.nginx.domain;
|
useACMEHost = mkIf (acmeHost != "") acmeHost;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://localhost:${toString cfg.port}";
|
proxyPass = "http://127.0.0.1:${port}";
|
||||||
proxyWebsockets = true;
|
proxyWebsockets = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user