mkModule various
This commit is contained in:
@@ -5,24 +5,14 @@
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib.${namespace}) mkOpt mkReverseProxyOpt;
|
||||
cfg = config.${namespace}.services.glance;
|
||||
in
|
||||
with lib;
|
||||
{
|
||||
options.${namespace}.services.glance = {
|
||||
enable = mkEnableOption "glance service";
|
||||
name = "glance";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
|
||||
port = mkOpt types.int 80 "Port for glance 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;
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
glanceConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "glance";
|
||||
options = { };
|
||||
moduleConfig = {
|
||||
services.glance = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
@@ -57,7 +47,7 @@ with lib;
|
||||
{
|
||||
type = "local";
|
||||
name = "Jallen-NAS";
|
||||
cpu-temp-sensor = "/sys/class/hwmon/hwmon2/temp2_input";
|
||||
cpu-temp-sensor = "/sys/class/hwmon/hwmon2/temp2_input"; # TODO
|
||||
mountpoints = {
|
||||
"/home" = {
|
||||
name = "Home";
|
||||
@@ -140,7 +130,7 @@ with lib;
|
||||
allow-insecure = true;
|
||||
basic-auth = {
|
||||
username = "mjallen";
|
||||
password = "BogieDudie1";
|
||||
password = "BogieDudie1"; # todo
|
||||
};
|
||||
}
|
||||
{
|
||||
@@ -228,4 +218,8 @@ with lib;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ glanceConfig ];
|
||||
}
|
||||
|
||||
@@ -7,18 +7,14 @@
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.services.glances;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# Open firewall for glances if enabled
|
||||
networking.firewall = mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [ cfg.port ];
|
||||
allowedUDPPorts = [ cfg.port ];
|
||||
};
|
||||
name = "glances";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
|
||||
glancesConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "Glances system monitoring web server";
|
||||
options = { };
|
||||
moduleConfig = {
|
||||
# Install glances package
|
||||
environment.systemPackages = with pkgs; [
|
||||
glances
|
||||
@@ -37,7 +33,7 @@ in
|
||||
];
|
||||
|
||||
script = ''
|
||||
glances -w --bind ${cfg.bindAddress} --port ${toString cfg.port}
|
||||
glances -w --bind ${cfg.listenAddress} --port ${toString cfg.port}
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
@@ -60,4 +56,8 @@ in
|
||||
|
||||
users.groups.glances = { };
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ glancesConfig ];
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
{ lib, namespace, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.${namespace}.services.glances = {
|
||||
enable = mkEnableOption "glances system monitoring service";
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 61208;
|
||||
description = "Port for glances web interface";
|
||||
};
|
||||
|
||||
openFirewall = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to open firewall for glances";
|
||||
};
|
||||
|
||||
bindAddress = mkOption {
|
||||
type = types.str;
|
||||
default = "0.0.0.0";
|
||||
description = "Address to bind glances web server to";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -6,16 +6,14 @@
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
# inherit (lib.${namespace}) mkModule mkOpt mkBoolOpt enableForSystem;
|
||||
cfg = config.${namespace}.services.grafana;
|
||||
upsUser = "nas-admin";
|
||||
in
|
||||
{
|
||||
options.${namespace}.services.grafana = {
|
||||
enable = mkEnableOption "enable grafana";
|
||||
};
|
||||
name = "grafana";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
grafanaConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "grafana";
|
||||
options = { };
|
||||
moduleConfig = {
|
||||
services = {
|
||||
prometheus = {
|
||||
enable = true;
|
||||
@@ -74,7 +72,7 @@ in
|
||||
enable = true;
|
||||
settings = {
|
||||
server = {
|
||||
http_port = 9999;
|
||||
http_port = cfg.port;
|
||||
http_addr = "0.0.0.0";
|
||||
};
|
||||
};
|
||||
@@ -94,10 +92,11 @@ in
|
||||
};
|
||||
};
|
||||
};
|
||||
# Open firewall ports for Grafana
|
||||
networking.firewall = {
|
||||
allowedTCPPorts = [ 9999 ];
|
||||
allowedUDPPorts = [ 9999 ];
|
||||
};
|
||||
};
|
||||
|
||||
upsUser = "nas-admin";
|
||||
in
|
||||
{
|
||||
imports = [ grafanaConfig ];
|
||||
}
|
||||
|
||||
@@ -6,17 +6,21 @@
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
inherit (lib.${namespace}) mkOpt mkReverseProxyOpt;
|
||||
cfg = config.${namespace}.services.headscale;
|
||||
name = "headscale";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
|
||||
headscaleConfig = {
|
||||
headscaleConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "headscale";
|
||||
options = { };
|
||||
moduleConfig = {
|
||||
services.headscale = {
|
||||
enable = true;
|
||||
address = "0.0.0.0";
|
||||
address = cfg.listenAddress;
|
||||
port = cfg.port;
|
||||
settings = {
|
||||
server_url = "https://headscale.mjallen.dev:443";
|
||||
database.sqlite.path = "${cfg.dataDir}/db.sqlite";
|
||||
database.sqlite.path = "${cfg.configDir}/headscale/db.sqlite";
|
||||
dns = {
|
||||
nameservers.global = [
|
||||
"1.1.1.1"
|
||||
@@ -29,34 +33,8 @@ let
|
||||
# oidc
|
||||
};
|
||||
};
|
||||
|
||||
# Create reverse proxy configuration using mkReverseProxy
|
||||
reverseProxyConfig = lib.${namespace}.mkReverseProxy {
|
||||
name = "headscale";
|
||||
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 ];
|
||||
};
|
||||
}
|
||||
// headscaleConfig;
|
||||
in
|
||||
{
|
||||
options.${namespace}.services.headscale = {
|
||||
enable = mkEnableOption "headscale service";
|
||||
|
||||
port = mkOpt types.int 8080 "Port for headscale 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;
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable fullConfig;
|
||||
imports = [ headscaleConfig ];
|
||||
}
|
||||
|
||||
@@ -6,26 +6,25 @@
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.services.immich;
|
||||
|
||||
immichPort = 2283;
|
||||
dataDir = "/media/nas/main/photos";
|
||||
name = "immich";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
dbPassword = config.sops.secrets."jallen-nas/immich/db-password".path;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
immichConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "immich";
|
||||
options = { };
|
||||
moduleConfig = {
|
||||
# Enable immich service
|
||||
services.immich = {
|
||||
enable = true;
|
||||
port = immichPort;
|
||||
port = cfg.port;
|
||||
openFirewall = true;
|
||||
secretsFile = dbPassword;
|
||||
mediaLocation = dataDir;
|
||||
mediaLocation = "${cfg.dataDir}/photos";
|
||||
|
||||
environment = {
|
||||
IMMICH_HOST = lib.mkForce "0.0.0.0";
|
||||
IMMICH_HOST = lib.mkForce cfg.listenAddress;
|
||||
IMMICH_TRUSTED_PROXIES = "10.0.1.3";
|
||||
TZ = "America/Chicago";
|
||||
};
|
||||
@@ -35,4 +34,8 @@ in
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ immichConfig ];
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
{ lib, namespace, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.${namespace}.services.immich = {
|
||||
enable = mkEnableOption "enable immich";
|
||||
};
|
||||
}
|
||||
@@ -6,19 +6,25 @@
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.services.jellyfin;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
name = "jellyfin";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
jellyfinConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "jellyfin";
|
||||
options = { };
|
||||
moduleConfig = {
|
||||
services.jellyfin = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
openFirewall = cfg.openFirewall;
|
||||
user = "nix-apps";
|
||||
group = "jallen-nas";
|
||||
dataDir = "/media/nas/main/nix-app-data/jellyfin";
|
||||
dataDir = "${cfg.configDir}/jellyfin";
|
||||
# cacheDir = "/cache";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ jellyfinConfig ];
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
{ lib, namespace, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.${namespace}.services.jellyfin = {
|
||||
enable = mkEnableOption "enable jellyfin";
|
||||
};
|
||||
}
|
||||
@@ -6,44 +6,36 @@
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
inherit (lib.${namespace}) mkOpt;
|
||||
cfg = config.${namespace}.services.jellyseerr;
|
||||
in
|
||||
{
|
||||
options.${namespace}.services.jellyseerr = {
|
||||
enable = mkEnableOption "enable jellyseerr";
|
||||
name = "jellyseerr";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
|
||||
port = mkOpt types.int 5055 "jellyseerr port";
|
||||
|
||||
dataDir = mkOpt types.str "" "data dir";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
jellyseerrConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "jellyseerr";
|
||||
options = { };
|
||||
moduleConfig = {
|
||||
# Enable jellyseerr service
|
||||
services.jellyseerr = {
|
||||
enable = true;
|
||||
port = cfg.port;
|
||||
openFirewall = true;
|
||||
configDir = cfg.dataDir;
|
||||
openFirewall = cfg.openFirewall;
|
||||
configDir = "${cfg.configDir}/jellyseerr";
|
||||
};
|
||||
|
||||
systemd.services = {
|
||||
jellyseerr = {
|
||||
serviceConfig = {
|
||||
WorkingDirectory = lib.mkForce cfg.dataDir;
|
||||
StateDirectory = lib.mkForce cfg.dataDir;
|
||||
WorkingDirectory = lib.mkForce "${cfg.configDir}/jellyseerr";
|
||||
StateDirectory = lib.mkForce "${cfg.configDir}/jellyseerr";
|
||||
StateDirectoryMode = lib.mkForce 700;
|
||||
DynamicUser = lib.mkForce false;
|
||||
ProtectSystem = lib.mkForce null;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
users.users.jellyseerr = {
|
||||
isSystemUser = true;
|
||||
group = "jellyseerr";
|
||||
home = cfg.dataDir;
|
||||
};
|
||||
users.groups.jellyseerr = { };
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ jellyseerrConfig ];
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
namespace,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.services.jellyseerr;
|
||||
|
||||
jellyseerrPort = 5055;
|
||||
dataDir = "/var/lib/private/jellyseerr";
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
containers.jellyseerr = {
|
||||
autoStart = true;
|
||||
privateNetwork = true;
|
||||
hostAddress = "10.0.1.3";
|
||||
localAddress = "10.0.1.52";
|
||||
hostAddress6 = "fc00::1";
|
||||
localAddress6 = "fc00::4";
|
||||
|
||||
bindMounts = {
|
||||
${dataDir} = {
|
||||
hostPath = "/media/nas/main/nix-app-data/jellyseerr";
|
||||
isReadOnly = false;
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
{
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
# Enable jellyseerr service
|
||||
services.jellyseerr = {
|
||||
enable = true;
|
||||
port = jellyseerrPort;
|
||||
# package = package;
|
||||
openFirewall = true;
|
||||
};
|
||||
|
||||
networking = {
|
||||
firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [ jellyseerrPort ];
|
||||
};
|
||||
# Use systemd-resolved inside the container
|
||||
# Workaround for bug https://github.com/NixOS/nixpkgs/issues/162686
|
||||
useHostResolvConf = lib.mkForce false;
|
||||
};
|
||||
|
||||
# Create and set permissions for required directories
|
||||
system.activationScripts.jellyseerr-dirs = ''
|
||||
mkdir -p /var/lib/private/jellyseerr
|
||||
|
||||
chown -R jellyseerr:jellyseerr /var/lib/private/jellyseerr
|
||||
|
||||
chmod -R 775 /var/lib/private/jellyseerr
|
||||
|
||||
ln -sf /var/lib/private/jellyseerr /var/lib/jellyfin
|
||||
|
||||
'';
|
||||
|
||||
services.resolved.enable = true;
|
||||
system.stateVersion = "23.11";
|
||||
};
|
||||
};
|
||||
|
||||
networking.nat = {
|
||||
forwardPorts = [
|
||||
{
|
||||
destination = "10.0.1.52:5055";
|
||||
sourcePort = jellyseerrPort;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{ lib, namespace, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.${namespace}.services.jellyseerr = {
|
||||
enable = mkEnableOption "enable jellyseerr";
|
||||
};
|
||||
}
|
||||
@@ -6,22 +6,24 @@
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.services.lubelogger;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
name = "lubelogger";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
lubeloggerConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "lubelogger";
|
||||
options = { };
|
||||
moduleConfig = {
|
||||
virtualisation.oci-containers.containers.lubelogger = {
|
||||
autoStart = true;
|
||||
image = "ghcr.io/hargata/lubelogger";
|
||||
ports = [ "${toString cfg.port}:8080" ];
|
||||
volumes = [
|
||||
"/media/nas/main/nix-app-data/lubelogger:/App/data"
|
||||
"/media/nas/main/nix-app-data/lubelogger/keys:/root/.aspnet/DataProtection-Keys"
|
||||
"${cfg.configDir}/lubelogger:/App/data"
|
||||
"${cfg.configDir}/lubelogger/keys:/root/.aspnet/DataProtection-Keys"
|
||||
];
|
||||
environmentFiles = [
|
||||
"/media/nas/main/nix-app-data/lubelogger/lubelogger.env"
|
||||
"${cfg.configDir}/lubelogger/lubelogger.env"
|
||||
];
|
||||
environment = {
|
||||
PUID = toString config.users.users.nix-apps.uid;
|
||||
@@ -29,11 +31,9 @@ in
|
||||
TZ = "America/Chicago";
|
||||
};
|
||||
};
|
||||
|
||||
# Open firewall for lubelogger if enabled
|
||||
networking.firewall = mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [ cfg.port ];
|
||||
allowedUDPPorts = [ cfg.port ];
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ lubeloggerConfig ];
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
{ lib, namespace, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.${namespace}.services.lubelogger = {
|
||||
enable = mkEnableOption "enable lubelogger";
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 6754;
|
||||
description = "Port for lubelogger web interface";
|
||||
};
|
||||
|
||||
openFirewall = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to open firewall for lubelogger";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -81,28 +81,27 @@ in
|
||||
glances = {
|
||||
enable = true;
|
||||
port = 61208;
|
||||
bindAddress = "0.0.0.0";
|
||||
createUser = true;
|
||||
};
|
||||
headscale = {
|
||||
enable = false;
|
||||
port = 2112;
|
||||
dataDir = "/media/nas/main/nix-app-data/headscale";
|
||||
reverseProxy = {
|
||||
reverseProxy.enable = true;
|
||||
};
|
||||
immich = {
|
||||
enable = true;
|
||||
subdomain = "headscale";
|
||||
middlewares = [
|
||||
"crowdsec"
|
||||
"whitelist-geoblock"
|
||||
];
|
||||
port = 2283;
|
||||
};
|
||||
};
|
||||
immich = enabled;
|
||||
jellyfin = enabled;
|
||||
jellyseerr = {
|
||||
enable = true;
|
||||
dataDir = "/media/nas/main/nix-app-data/jellyseerr";
|
||||
port = 5055;
|
||||
createUser = true;
|
||||
};
|
||||
lubelogger = {
|
||||
enable = true;
|
||||
port = 6754;
|
||||
};
|
||||
lubelogger = enabled;
|
||||
manyfold = enabled;
|
||||
matrix = {
|
||||
enable = true;
|
||||
|
||||
@@ -227,7 +227,10 @@ in
|
||||
# ###################################################
|
||||
|
||||
services = {
|
||||
grafana = enabled;
|
||||
grafana = {
|
||||
enable = true;
|
||||
port = 9999;
|
||||
};
|
||||
};
|
||||
|
||||
# ###################################################
|
||||
|
||||
Reference in New Issue
Block a user