mkModule various
This commit is contained in:
@@ -5,227 +5,221 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib.${namespace}) mkOpt mkReverseProxyOpt;
|
name = "glance";
|
||||||
cfg = config.${namespace}.services.glance;
|
cfg = config.${namespace}.services.${name};
|
||||||
in
|
|
||||||
with lib;
|
|
||||||
{
|
|
||||||
options.${namespace}.services.glance = {
|
|
||||||
enable = mkEnableOption "glance service";
|
|
||||||
|
|
||||||
port = mkOpt types.int 80 "Port for glance to be hosted on";
|
glanceConfig = lib.${namespace}.mkModule {
|
||||||
|
inherit config name;
|
||||||
localAddress = mkOpt types.str "127.0.0.1" "local address of the service";
|
description = "glance";
|
||||||
|
options = { };
|
||||||
dataDir = mkOpt types.str "" "Path to the data dir";
|
moduleConfig = {
|
||||||
|
services.glance = {
|
||||||
reverseProxy = mkReverseProxyOpt;
|
enable = true;
|
||||||
};
|
openFirewall = true;
|
||||||
|
settings = {
|
||||||
config = lib.mkIf cfg.enable {
|
server = {
|
||||||
services.glance = {
|
host = "0.0.0.0";
|
||||||
enable = true;
|
port = cfg.port;
|
||||||
openFirewall = true;
|
};
|
||||||
settings = {
|
pages = [
|
||||||
server = {
|
{
|
||||||
host = "0.0.0.0";
|
name = "Startpage";
|
||||||
port = cfg.port;
|
width = "default";
|
||||||
|
hide-desktop-navigation = true;
|
||||||
|
center-vertically = true;
|
||||||
|
columns = [
|
||||||
|
{
|
||||||
|
size = "small";
|
||||||
|
widgets = [
|
||||||
|
{
|
||||||
|
type = "calendar";
|
||||||
|
first-day-of-week = "sunday";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
type = "weather";
|
||||||
|
units = "metric";
|
||||||
|
hour-format = "12h";
|
||||||
|
location = "Saint Paul, Minnesota, United States";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
type = "server-stats";
|
||||||
|
servers = [
|
||||||
|
{
|
||||||
|
type = "local";
|
||||||
|
name = "Jallen-NAS";
|
||||||
|
cpu-temp-sensor = "/sys/class/hwmon/hwmon2/temp2_input"; # TODO
|
||||||
|
mountpoints = {
|
||||||
|
"/home" = {
|
||||||
|
name = "Home";
|
||||||
|
};
|
||||||
|
"/media/nas/main" = {
|
||||||
|
name = "nas_pool";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
size = "full";
|
||||||
|
widgets = [
|
||||||
|
{
|
||||||
|
type = "search";
|
||||||
|
autofocus = true;
|
||||||
|
search-engine = "duckduckgo";
|
||||||
|
bangs = [
|
||||||
|
{
|
||||||
|
title = "YouTube";
|
||||||
|
shortcut = "!yt";
|
||||||
|
url = "https://www.youtube.com/results?search_query={QUERY}";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
type = "monitor";
|
||||||
|
cache = "1m";
|
||||||
|
title = "Services";
|
||||||
|
sites = [
|
||||||
|
{
|
||||||
|
title = "Actual";
|
||||||
|
url = "https://actual.mjallen.dev/";
|
||||||
|
icon = "si:actualbudget";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Jellyfin";
|
||||||
|
url = "https://jellyfin.mjallen.dev/";
|
||||||
|
icon = "si:jellyfin";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Gitea";
|
||||||
|
url = "https://gitea.mjallen.dev/";
|
||||||
|
icon = "si:gitea";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Nextcloud";
|
||||||
|
url = "https://cloud.mjallen.dev/";
|
||||||
|
icon = "si:nextcloud";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Immich";
|
||||||
|
url = "https://immich.mjallen.dev/";
|
||||||
|
icon = "si:immich";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "AdGuard Home";
|
||||||
|
url = "http://10.0.1.2:3000/";
|
||||||
|
icon = "si:adguard";
|
||||||
|
allow-insecure = true;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Home Assistant";
|
||||||
|
url = "https://hass.mjallen.dev/";
|
||||||
|
icon = "si:homeassistant";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Manyfold";
|
||||||
|
url = "http://10.0.1.3:3214/collections";
|
||||||
|
icon = "sh:Manyfold";
|
||||||
|
allow-insecure = true;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Sonarr";
|
||||||
|
url = "http://10.0.1.3:8989/";
|
||||||
|
icon = "si:sonarr";
|
||||||
|
allow-insecure = true;
|
||||||
|
basic-auth = {
|
||||||
|
username = "mjallen";
|
||||||
|
password = "BogieDudie1"; # todo
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Radarr";
|
||||||
|
url = "http://10.0.1.3:7878/";
|
||||||
|
icon = "si:radarr";
|
||||||
|
allow-insecure = true;
|
||||||
|
basic-auth = {
|
||||||
|
username = "mjallen";
|
||||||
|
password = "BogieDudie1";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
# {
|
||||||
|
# title = "";
|
||||||
|
# url = "";
|
||||||
|
# icon = "si:";
|
||||||
|
# }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
type = "bookmarks";
|
||||||
|
groups = [
|
||||||
|
{
|
||||||
|
title = "General";
|
||||||
|
links = [
|
||||||
|
{
|
||||||
|
title = "Gmail";
|
||||||
|
url = "https://mail.google.com/mail/u/0/";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Proton Mail";
|
||||||
|
url = "https://mail.proton.me/u/0/inbox";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "MyNixOS";
|
||||||
|
url = "https://www.mynixos.com/";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Github";
|
||||||
|
url = "https://github.com/";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Entertainment";
|
||||||
|
links = [
|
||||||
|
{
|
||||||
|
title = "YouTube";
|
||||||
|
url = "https://www.youtube.com/";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Prime Video";
|
||||||
|
url = "https://www.primevideo.com/";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Disney+";
|
||||||
|
url = "https://www.disneyplus.com/";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Social";
|
||||||
|
links = [
|
||||||
|
{
|
||||||
|
title = "Reddit";
|
||||||
|
url = "https://www.reddit.com/";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Twitter";
|
||||||
|
url = "https://twitter.com/";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
title = "Instagram";
|
||||||
|
url = "https://www.instagram.com/";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
pages = [
|
|
||||||
{
|
|
||||||
name = "Startpage";
|
|
||||||
width = "default";
|
|
||||||
hide-desktop-navigation = true;
|
|
||||||
center-vertically = true;
|
|
||||||
columns = [
|
|
||||||
{
|
|
||||||
size = "small";
|
|
||||||
widgets = [
|
|
||||||
{
|
|
||||||
type = "calendar";
|
|
||||||
first-day-of-week = "sunday";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
type = "weather";
|
|
||||||
units = "metric";
|
|
||||||
hour-format = "12h";
|
|
||||||
location = "Saint Paul, Minnesota, United States";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
type = "server-stats";
|
|
||||||
servers = [
|
|
||||||
{
|
|
||||||
type = "local";
|
|
||||||
name = "Jallen-NAS";
|
|
||||||
cpu-temp-sensor = "/sys/class/hwmon/hwmon2/temp2_input";
|
|
||||||
mountpoints = {
|
|
||||||
"/home" = {
|
|
||||||
name = "Home";
|
|
||||||
};
|
|
||||||
"/media/nas/main" = {
|
|
||||||
name = "nas_pool";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
size = "full";
|
|
||||||
widgets = [
|
|
||||||
{
|
|
||||||
type = "search";
|
|
||||||
autofocus = true;
|
|
||||||
search-engine = "duckduckgo";
|
|
||||||
bangs = [
|
|
||||||
{
|
|
||||||
title = "YouTube";
|
|
||||||
shortcut = "!yt";
|
|
||||||
url = "https://www.youtube.com/results?search_query={QUERY}";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
type = "monitor";
|
|
||||||
cache = "1m";
|
|
||||||
title = "Services";
|
|
||||||
sites = [
|
|
||||||
{
|
|
||||||
title = "Actual";
|
|
||||||
url = "https://actual.mjallen.dev/";
|
|
||||||
icon = "si:actualbudget";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Jellyfin";
|
|
||||||
url = "https://jellyfin.mjallen.dev/";
|
|
||||||
icon = "si:jellyfin";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Gitea";
|
|
||||||
url = "https://gitea.mjallen.dev/";
|
|
||||||
icon = "si:gitea";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Nextcloud";
|
|
||||||
url = "https://cloud.mjallen.dev/";
|
|
||||||
icon = "si:nextcloud";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Immich";
|
|
||||||
url = "https://immich.mjallen.dev/";
|
|
||||||
icon = "si:immich";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "AdGuard Home";
|
|
||||||
url = "http://10.0.1.2:3000/";
|
|
||||||
icon = "si:adguard";
|
|
||||||
allow-insecure = true;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Home Assistant";
|
|
||||||
url = "https://hass.mjallen.dev/";
|
|
||||||
icon = "si:homeassistant";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Manyfold";
|
|
||||||
url = "http://10.0.1.3:3214/collections";
|
|
||||||
icon = "sh:Manyfold";
|
|
||||||
allow-insecure = true;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Sonarr";
|
|
||||||
url = "http://10.0.1.3:8989/";
|
|
||||||
icon = "si:sonarr";
|
|
||||||
allow-insecure = true;
|
|
||||||
basic-auth = {
|
|
||||||
username = "mjallen";
|
|
||||||
password = "BogieDudie1";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Radarr";
|
|
||||||
url = "http://10.0.1.3:7878/";
|
|
||||||
icon = "si:radarr";
|
|
||||||
allow-insecure = true;
|
|
||||||
basic-auth = {
|
|
||||||
username = "mjallen";
|
|
||||||
password = "BogieDudie1";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
# {
|
|
||||||
# title = "";
|
|
||||||
# url = "";
|
|
||||||
# icon = "si:";
|
|
||||||
# }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
type = "bookmarks";
|
|
||||||
groups = [
|
|
||||||
{
|
|
||||||
title = "General";
|
|
||||||
links = [
|
|
||||||
{
|
|
||||||
title = "Gmail";
|
|
||||||
url = "https://mail.google.com/mail/u/0/";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Proton Mail";
|
|
||||||
url = "https://mail.proton.me/u/0/inbox";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "MyNixOS";
|
|
||||||
url = "https://www.mynixos.com/";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Github";
|
|
||||||
url = "https://github.com/";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Entertainment";
|
|
||||||
links = [
|
|
||||||
{
|
|
||||||
title = "YouTube";
|
|
||||||
url = "https://www.youtube.com/";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Prime Video";
|
|
||||||
url = "https://www.primevideo.com/";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Disney+";
|
|
||||||
url = "https://www.disneyplus.com/";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Social";
|
|
||||||
links = [
|
|
||||||
{
|
|
||||||
title = "Reddit";
|
|
||||||
url = "https://www.reddit.com/";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Twitter";
|
|
||||||
url = "https://twitter.com/";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
title = "Instagram";
|
|
||||||
url = "https://www.instagram.com/";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [ glanceConfig ];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,57 +7,57 @@
|
|||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.${namespace}.services.glances;
|
name = "glances";
|
||||||
in
|
cfg = config.${namespace}.services.${name};
|
||||||
{
|
|
||||||
imports = [ ./options.nix ];
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
glancesConfig = lib.${namespace}.mkModule {
|
||||||
# Open firewall for glances if enabled
|
inherit config name;
|
||||||
networking.firewall = mkIf cfg.openFirewall {
|
description = "Glances system monitoring web server";
|
||||||
allowedTCPPorts = [ cfg.port ];
|
options = { };
|
||||||
allowedUDPPorts = [ cfg.port ];
|
moduleConfig = {
|
||||||
};
|
# Install glances package
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
# Install glances package
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
glances
|
|
||||||
];
|
|
||||||
|
|
||||||
# Configure systemd service for glances
|
|
||||||
systemd.services.glances-server = {
|
|
||||||
description = "Glances system monitoring web server";
|
|
||||||
enable = true;
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
after = [ "network.target" ];
|
|
||||||
|
|
||||||
path = with pkgs; [
|
|
||||||
bash
|
|
||||||
glances
|
glances
|
||||||
];
|
];
|
||||||
|
|
||||||
script = ''
|
# Configure systemd service for glances
|
||||||
glances -w --bind ${cfg.bindAddress} --port ${toString cfg.port}
|
systemd.services.glances-server = {
|
||||||
'';
|
description = "Glances system monitoring web server";
|
||||||
|
enable = true;
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "network.target" ];
|
||||||
|
|
||||||
serviceConfig = {
|
path = with pkgs; [
|
||||||
Type = "simple";
|
bash
|
||||||
User = "glances";
|
glances
|
||||||
Group = "glances";
|
];
|
||||||
Restart = "always";
|
|
||||||
RestartSec = "5";
|
script = ''
|
||||||
StandardOutput = "journal";
|
glances -w --bind ${cfg.listenAddress} --port ${toString cfg.port}
|
||||||
StandardError = "journal";
|
'';
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "simple";
|
||||||
|
User = "glances";
|
||||||
|
Group = "glances";
|
||||||
|
Restart = "always";
|
||||||
|
RestartSec = "5";
|
||||||
|
StandardOutput = "journal";
|
||||||
|
StandardError = "journal";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
# Create glances user and group
|
# Create glances user and group
|
||||||
users.users.glances = {
|
users.users.glances = {
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
group = "glances";
|
group = "glances";
|
||||||
description = "Glances monitoring user";
|
description = "Glances monitoring user";
|
||||||
};
|
};
|
||||||
|
|
||||||
users.groups.glances = { };
|
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,98 +6,97 @@
|
|||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
# inherit (lib.${namespace}) mkModule mkOpt mkBoolOpt enableForSystem;
|
name = "grafana";
|
||||||
cfg = config.${namespace}.services.grafana;
|
cfg = config.${namespace}.services.${name};
|
||||||
upsUser = "nas-admin";
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.${namespace}.services.grafana = {
|
|
||||||
enable = mkEnableOption "enable grafana";
|
|
||||||
};
|
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
grafanaConfig = lib.${namespace}.mkModule {
|
||||||
services = {
|
inherit config name;
|
||||||
prometheus = {
|
description = "grafana";
|
||||||
enable = true;
|
options = { };
|
||||||
exporters = {
|
moduleConfig = {
|
||||||
node = {
|
services = {
|
||||||
enable = true;
|
prometheus = {
|
||||||
enabledCollectors = [
|
|
||||||
"filesystem"
|
|
||||||
"diskstats"
|
|
||||||
"meminfo"
|
|
||||||
"cpu"
|
|
||||||
"systemd" # Ensures systemd collector is enabled
|
|
||||||
"processes"
|
|
||||||
];
|
|
||||||
extraFlags = [
|
|
||||||
"--collector.filesystem.mount-points-exclude=^/(dev|proc|sys|run)($|/)"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
libvirt = {
|
|
||||||
enable = false;
|
|
||||||
openFirewall = true;
|
|
||||||
};
|
|
||||||
nut = {
|
|
||||||
enable = true;
|
|
||||||
openFirewall = true;
|
|
||||||
passwordPath = config.sops.secrets."jallen-nas/ups_password".path;
|
|
||||||
nutUser = upsUser;
|
|
||||||
};
|
|
||||||
# restic = {
|
|
||||||
# enable = true;
|
|
||||||
# openFirewall = true;
|
|
||||||
# resticPort = 8008;
|
|
||||||
# };
|
|
||||||
};
|
|
||||||
scrapeConfigs = [
|
|
||||||
{
|
|
||||||
job_name = "node";
|
|
||||||
static_configs = [
|
|
||||||
{
|
|
||||||
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
job_name = "traefik";
|
|
||||||
static_configs = [
|
|
||||||
{
|
|
||||||
targets = [ "localhost:8082" ];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
grafana = {
|
|
||||||
enable = true;
|
|
||||||
settings = {
|
|
||||||
server = {
|
|
||||||
http_port = 9999;
|
|
||||||
http_addr = "0.0.0.0";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
dataDir = "/media/nas/main/nix-app-data/grafana";
|
|
||||||
|
|
||||||
provision = {
|
|
||||||
enable = true;
|
enable = true;
|
||||||
datasources.settings.datasources = [
|
exporters = {
|
||||||
|
node = {
|
||||||
|
enable = true;
|
||||||
|
enabledCollectors = [
|
||||||
|
"filesystem"
|
||||||
|
"diskstats"
|
||||||
|
"meminfo"
|
||||||
|
"cpu"
|
||||||
|
"systemd" # Ensures systemd collector is enabled
|
||||||
|
"processes"
|
||||||
|
];
|
||||||
|
extraFlags = [
|
||||||
|
"--collector.filesystem.mount-points-exclude=^/(dev|proc|sys|run)($|/)"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
libvirt = {
|
||||||
|
enable = false;
|
||||||
|
openFirewall = true;
|
||||||
|
};
|
||||||
|
nut = {
|
||||||
|
enable = true;
|
||||||
|
openFirewall = true;
|
||||||
|
passwordPath = config.sops.secrets."jallen-nas/ups_password".path;
|
||||||
|
nutUser = upsUser;
|
||||||
|
};
|
||||||
|
# restic = {
|
||||||
|
# enable = true;
|
||||||
|
# openFirewall = true;
|
||||||
|
# resticPort = 8008;
|
||||||
|
# };
|
||||||
|
};
|
||||||
|
scrapeConfigs = [
|
||||||
{
|
{
|
||||||
name = "Prometheus";
|
job_name = "node";
|
||||||
type = "prometheus";
|
static_configs = [
|
||||||
access = "proxy";
|
{
|
||||||
url = "http://localhost:${toString config.services.prometheus.port}";
|
targets = [ "localhost:${toString config.services.prometheus.exporters.node.port}" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
job_name = "traefik";
|
||||||
|
static_configs = [
|
||||||
|
{
|
||||||
|
targets = [ "localhost:8082" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
grafana = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
server = {
|
||||||
|
http_port = cfg.port;
|
||||||
|
http_addr = "0.0.0.0";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
dataDir = "/media/nas/main/nix-app-data/grafana";
|
||||||
|
|
||||||
|
provision = {
|
||||||
|
enable = true;
|
||||||
|
datasources.settings.datasources = [
|
||||||
|
{
|
||||||
|
name = "Prometheus";
|
||||||
|
type = "prometheus";
|
||||||
|
access = "proxy";
|
||||||
|
url = "http://localhost:${toString config.services.prometheus.port}";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
# Open firewall ports for Grafana
|
|
||||||
networking.firewall = {
|
|
||||||
allowedTCPPorts = [ 9999 ];
|
|
||||||
allowedUDPPorts = [ 9999 ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
upsUser = "nas-admin";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [ grafanaConfig ];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,57 +6,35 @@
|
|||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
inherit (lib.${namespace}) mkOpt mkReverseProxyOpt;
|
name = "headscale";
|
||||||
cfg = config.${namespace}.services.headscale;
|
cfg = config.${namespace}.services.${name};
|
||||||
|
|
||||||
headscaleConfig = {
|
headscaleConfig = lib.${namespace}.mkModule {
|
||||||
services.headscale = {
|
inherit config name;
|
||||||
enable = true;
|
description = "headscale";
|
||||||
address = "0.0.0.0";
|
options = { };
|
||||||
port = cfg.port;
|
moduleConfig = {
|
||||||
settings = {
|
services.headscale = {
|
||||||
server_url = "https://headscale.mjallen.dev:443";
|
enable = true;
|
||||||
database.sqlite.path = "${cfg.dataDir}/db.sqlite";
|
address = cfg.listenAddress;
|
||||||
dns = {
|
port = cfg.port;
|
||||||
nameservers.global = [
|
settings = {
|
||||||
"1.1.1.1"
|
server_url = "https://headscale.mjallen.dev:443";
|
||||||
"8.8.8.8"
|
database.sqlite.path = "${cfg.configDir}/headscale/db.sqlite";
|
||||||
];
|
dns = {
|
||||||
base_domain = "tailnet.mjallen.dev";
|
nameservers.global = [
|
||||||
magic_dns = true;
|
"1.1.1.1"
|
||||||
|
"8.8.8.8"
|
||||||
|
];
|
||||||
|
base_domain = "tailnet.mjallen.dev";
|
||||||
|
magic_dns = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
# oidc
|
||||||
};
|
};
|
||||||
# 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
|
in
|
||||||
{
|
{
|
||||||
options.${namespace}.services.headscale = {
|
imports = [ headscaleConfig ];
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,33 +6,36 @@
|
|||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.${namespace}.services.immich;
|
name = "immich";
|
||||||
|
cfg = config.${namespace}.services.${name};
|
||||||
immichPort = 2283;
|
|
||||||
dataDir = "/media/nas/main/photos";
|
|
||||||
dbPassword = config.sops.secrets."jallen-nas/immich/db-password".path;
|
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
|
# Enable immich service
|
||||||
services.immich = {
|
services.immich = {
|
||||||
enable = true;
|
|
||||||
port = immichPort;
|
|
||||||
openFirewall = true;
|
|
||||||
secretsFile = dbPassword;
|
|
||||||
mediaLocation = dataDir;
|
|
||||||
|
|
||||||
environment = {
|
|
||||||
IMMICH_HOST = lib.mkForce "0.0.0.0";
|
|
||||||
IMMICH_TRUSTED_PROXIES = "10.0.1.3";
|
|
||||||
TZ = "America/Chicago";
|
|
||||||
};
|
|
||||||
|
|
||||||
machine-learning = {
|
|
||||||
enable = true;
|
enable = true;
|
||||||
|
port = cfg.port;
|
||||||
|
openFirewall = true;
|
||||||
|
secretsFile = dbPassword;
|
||||||
|
mediaLocation = "${cfg.dataDir}/photos";
|
||||||
|
|
||||||
|
environment = {
|
||||||
|
IMMICH_HOST = lib.mkForce cfg.listenAddress;
|
||||||
|
IMMICH_TRUSTED_PROXIES = "10.0.1.3";
|
||||||
|
TZ = "America/Chicago";
|
||||||
|
};
|
||||||
|
|
||||||
|
machine-learning = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
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;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.${namespace}.services.jellyfin;
|
name = "jellyfin";
|
||||||
in
|
cfg = config.${namespace}.services.${name};
|
||||||
{
|
|
||||||
imports = [ ./options.nix ];
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
jellyfinConfig = lib.${namespace}.mkModule {
|
||||||
services.jellyfin = {
|
inherit config name;
|
||||||
enable = true;
|
description = "jellyfin";
|
||||||
openFirewall = true;
|
options = { };
|
||||||
user = "nix-apps";
|
moduleConfig = {
|
||||||
group = "jallen-nas";
|
services.jellyfin = {
|
||||||
dataDir = "/media/nas/main/nix-app-data/jellyfin";
|
enable = true;
|
||||||
# cacheDir = "/cache";
|
openFirewall = cfg.openFirewall;
|
||||||
|
user = "nix-apps";
|
||||||
|
group = "jallen-nas";
|
||||||
|
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;
|
with lib;
|
||||||
let
|
let
|
||||||
inherit (lib.${namespace}) mkOpt;
|
name = "jellyseerr";
|
||||||
cfg = config.${namespace}.services.jellyseerr;
|
cfg = config.${namespace}.services.${name};
|
||||||
in
|
|
||||||
{
|
|
||||||
options.${namespace}.services.jellyseerr = {
|
|
||||||
enable = mkEnableOption "enable jellyseerr";
|
|
||||||
|
|
||||||
port = mkOpt types.int 5055 "jellyseerr port";
|
jellyseerrConfig = lib.${namespace}.mkModule {
|
||||||
|
inherit config name;
|
||||||
|
description = "jellyseerr";
|
||||||
|
options = { };
|
||||||
|
moduleConfig = {
|
||||||
|
# Enable jellyseerr service
|
||||||
|
services.jellyseerr = {
|
||||||
|
enable = true;
|
||||||
|
port = cfg.port;
|
||||||
|
openFirewall = cfg.openFirewall;
|
||||||
|
configDir = "${cfg.configDir}/jellyseerr";
|
||||||
|
};
|
||||||
|
|
||||||
dataDir = mkOpt types.str "" "data dir";
|
systemd.services = {
|
||||||
};
|
jellyseerr = {
|
||||||
|
serviceConfig = {
|
||||||
config = mkIf cfg.enable {
|
WorkingDirectory = lib.mkForce "${cfg.configDir}/jellyseerr";
|
||||||
# Enable jellyseerr service
|
StateDirectory = lib.mkForce "${cfg.configDir}/jellyseerr";
|
||||||
services.jellyseerr = {
|
StateDirectoryMode = lib.mkForce 700;
|
||||||
enable = true;
|
DynamicUser = lib.mkForce false;
|
||||||
port = cfg.port;
|
ProtectSystem = lib.mkForce null;
|
||||||
openFirewall = true;
|
};
|
||||||
configDir = cfg.dataDir;
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services = {
|
|
||||||
jellyseerr = {
|
|
||||||
serviceConfig = {
|
|
||||||
WorkingDirectory = lib.mkForce cfg.dataDir;
|
|
||||||
StateDirectory = lib.mkForce cfg.dataDir;
|
|
||||||
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;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.${namespace}.services.lubelogger;
|
name = "lubelogger";
|
||||||
in
|
cfg = config.${namespace}.services.${name};
|
||||||
{
|
|
||||||
imports = [ ./options.nix ];
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
lubeloggerConfig = lib.${namespace}.mkModule {
|
||||||
|
inherit config name;
|
||||||
|
description = "lubelogger";
|
||||||
|
options = { };
|
||||||
|
moduleConfig = {
|
||||||
virtualisation.oci-containers.containers.lubelogger = {
|
virtualisation.oci-containers.containers.lubelogger = {
|
||||||
autoStart = true;
|
autoStart = true;
|
||||||
image = "ghcr.io/hargata/lubelogger";
|
image = "ghcr.io/hargata/lubelogger";
|
||||||
ports = [ "${toString cfg.port}:8080" ];
|
ports = [ "${toString cfg.port}:8080" ];
|
||||||
volumes = [
|
volumes = [
|
||||||
"/media/nas/main/nix-app-data/lubelogger:/App/data"
|
"${cfg.configDir}/lubelogger:/App/data"
|
||||||
"/media/nas/main/nix-app-data/lubelogger/keys:/root/.aspnet/DataProtection-Keys"
|
"${cfg.configDir}/lubelogger/keys:/root/.aspnet/DataProtection-Keys"
|
||||||
];
|
];
|
||||||
environmentFiles = [
|
environmentFiles = [
|
||||||
"/media/nas/main/nix-app-data/lubelogger/lubelogger.env"
|
"${cfg.configDir}/lubelogger/lubelogger.env"
|
||||||
];
|
];
|
||||||
environment = {
|
environment = {
|
||||||
PUID = toString config.users.users.nix-apps.uid;
|
PUID = toString config.users.users.nix-apps.uid;
|
||||||
@@ -29,11 +31,9 @@ in
|
|||||||
TZ = "America/Chicago";
|
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 = {
|
glances = {
|
||||||
enable = true;
|
enable = true;
|
||||||
port = 61208;
|
port = 61208;
|
||||||
bindAddress = "0.0.0.0";
|
createUser = true;
|
||||||
};
|
};
|
||||||
headscale = {
|
headscale = {
|
||||||
enable = false;
|
enable = false;
|
||||||
port = 2112;
|
port = 2112;
|
||||||
dataDir = "/media/nas/main/nix-app-data/headscale";
|
reverseProxy.enable = true;
|
||||||
reverseProxy = {
|
};
|
||||||
enable = true;
|
immich = {
|
||||||
subdomain = "headscale";
|
enable = true;
|
||||||
middlewares = [
|
port = 2283;
|
||||||
"crowdsec"
|
|
||||||
"whitelist-geoblock"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
immich = enabled;
|
|
||||||
jellyfin = enabled;
|
jellyfin = enabled;
|
||||||
jellyseerr = {
|
jellyseerr = {
|
||||||
enable = true;
|
enable = true;
|
||||||
dataDir = "/media/nas/main/nix-app-data/jellyseerr";
|
port = 5055;
|
||||||
|
createUser = true;
|
||||||
|
};
|
||||||
|
lubelogger = {
|
||||||
|
enable = true;
|
||||||
|
port = 6754;
|
||||||
};
|
};
|
||||||
lubelogger = enabled;
|
|
||||||
manyfold = enabled;
|
manyfold = enabled;
|
||||||
matrix = {
|
matrix = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
@@ -227,7 +227,10 @@ in
|
|||||||
# ###################################################
|
# ###################################################
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
grafana = enabled;
|
grafana = {
|
||||||
|
enable = true;
|
||||||
|
port = 9999;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# ###################################################
|
# ###################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user