Refactor homelab modules
This commit is contained in:
parent
e6f269b123
commit
fe508bd127
9 changed files with 224 additions and 83 deletions
hosts/nixedo
|
@ -19,7 +19,27 @@
|
|||
core.openssh.enable = true;
|
||||
cli.podman.enable = true;
|
||||
desktop.dconf.enable = true;
|
||||
homelab.immich.enable = true;
|
||||
|
||||
homelab = {
|
||||
enable = true;
|
||||
|
||||
baseDomain = "oliverdavies.uk";
|
||||
|
||||
services = {
|
||||
audiobookshelf.enable = true;
|
||||
|
||||
forgejo = {
|
||||
enable = true;
|
||||
|
||||
cloudflared.tunnelId = "e1514105-327f-4984-974e-e2fbaca76466";
|
||||
};
|
||||
|
||||
immich.enable = true;
|
||||
jellyfin.enable = true;
|
||||
paperless.enable = true;
|
||||
uptime-kuma.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.logind.lidSwitchExternalPower = "ignore";
|
||||
|
|
|
@ -1,23 +1,34 @@
|
|||
{ config, ... }:
|
||||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.audiobookshelf;
|
||||
cfg = homelab.services.${service};
|
||||
homelab = config.nixosModules.homelab;
|
||||
service = "audiobookshelf";
|
||||
in
|
||||
{
|
||||
services = {
|
||||
audiobookshelf = {
|
||||
enable = true;
|
||||
options.nixosModules.homelab.services.${service} = {
|
||||
enable = mkEnableOption "Enable ${service}";
|
||||
|
||||
port = 4001;
|
||||
url = mkOption {
|
||||
default = "audiobookshelf.${homelab.baseDomain}";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
nginx.virtualHosts."audiobookshelf.oliverdavies.uk" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "oliverdavies.uk";
|
||||
config = mkIf cfg.enable {
|
||||
services = {
|
||||
${service}.enable = true;
|
||||
|
||||
locations."/" = {
|
||||
proxyPass = "http://localhost:${toString cfg.port}";
|
||||
recommendedProxySettings = true;
|
||||
nginx.virtualHosts.${cfg.url} = {
|
||||
forceSSL = true;
|
||||
useACMEHost = homelab.baseDomain;
|
||||
|
||||
locations."/" = {
|
||||
proxyPass = "http://localhost:${toString cfg.port}";
|
||||
recommendedProxySettings = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
{ lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options.nixosModules.homelab = {
|
||||
enable = mkEnableOption "Enable homelab services and configuration";
|
||||
|
||||
baseDomain = mkOption {
|
||||
description = "The base domain to use for this homelab.";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
imports = [
|
||||
./acme.nix
|
||||
./audiobookshelf.nix
|
||||
|
|
|
@ -1,26 +1,42 @@
|
|||
{ config, ... }:
|
||||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = homelab.services.${service};
|
||||
homelab = config.nixosModules.homelab;
|
||||
service = "forgejo";
|
||||
in
|
||||
{
|
||||
services = {
|
||||
forgejo = {
|
||||
enable = true;
|
||||
stateDir = "/var/www/forgejo";
|
||||
options.nixosModules.homelab.services.${service} = {
|
||||
enable = mkEnableOption "Enable ${service}";
|
||||
|
||||
settings = {
|
||||
server = {
|
||||
DOMAIN = "code.oliverdavies.uk";
|
||||
HTTP_PORT = 2223;
|
||||
};
|
||||
|
||||
service = {
|
||||
DISABLE_REGISTRATION = true;
|
||||
};
|
||||
};
|
||||
cloudflared.tunnelId = mkOption {
|
||||
example = "00000000-0000-0000-0000-000000000000";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
cloudflared.tunnels."e1514105-327f-4984-974e-e2fbaca76466".ingress = {
|
||||
"code.oliverdavies.uk" =
|
||||
"http://localhost:${toString config.services.forgejo.settings.server.HTTP_PORT}";
|
||||
url = mkOption {
|
||||
default = "code.${homelab.baseDomain}";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services = {
|
||||
${service} = {
|
||||
enable = true;
|
||||
stateDir = "/var/www/${service}";
|
||||
|
||||
settings = {
|
||||
server.DOMAIN = cfg.url;
|
||||
service.DISABLE_REGISTRATION = true;
|
||||
};
|
||||
};
|
||||
|
||||
cloudflared.tunnels.${cfg.cloudflared.tunnelId}.ingress = {
|
||||
${cfg.url} = "http://localhost:${toString config.services.${service}.settings.server.HTTP_PORT}";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,24 +8,31 @@
|
|||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.nixosModules.homelab.immich;
|
||||
cfg = homelab.services.${service};
|
||||
homelab = config.nixosModules.homelab;
|
||||
service = "immich";
|
||||
in
|
||||
{
|
||||
options.nixosModules.homelab.immich = {
|
||||
enable = mkEnableOption "Enable immich";
|
||||
options.nixosModules.homelab.services.${service} = {
|
||||
enable = mkEnableOption "Enable ${service}";
|
||||
|
||||
url = mkOption {
|
||||
default = "photos.${homelab.baseDomain}";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services = {
|
||||
immich = {
|
||||
${service} = {
|
||||
enable = true;
|
||||
group = "media";
|
||||
mediaLocation = "/mnt/media/immich";
|
||||
mediaLocation = "/mnt/media/${service}";
|
||||
};
|
||||
|
||||
nginx.virtualHosts."photos.oliverdavies.uk" = {
|
||||
nginx.virtualHosts."${cfg.url}" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "oliverdavies.uk";
|
||||
useACMEHost = homelab.baseDomain;
|
||||
|
||||
locations."/" = {
|
||||
proxyPass = "http://localhost:${toString config.services.immich.port}";
|
||||
|
|
|
@ -1,22 +1,38 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = homelab.services.${service};
|
||||
homelab = config.nixosModules.homelab;
|
||||
service = "jellyfin";
|
||||
in
|
||||
{
|
||||
services =
|
||||
let
|
||||
port = 8096;
|
||||
in
|
||||
{
|
||||
jellyfin = {
|
||||
options.nixosModules.homelab.services.${service} = {
|
||||
enable = mkEnableOption "Enable ${service}";
|
||||
|
||||
url = mkOption {
|
||||
default = "${service}.${homelab.baseDomain}";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services = {
|
||||
${service} = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
|
||||
configDir = "/mnt/media/${service}";
|
||||
group = "media";
|
||||
configDir = "/mnt/media/jellyfin";
|
||||
openFirewall = true;
|
||||
};
|
||||
|
||||
nginx.virtualHosts."jellyfin.oliverdavies.uk" = {
|
||||
nginx.virtualHosts."${cfg.url}" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "oliverdavies.uk";
|
||||
useACMEHost = homelab.baseDomain;
|
||||
|
||||
locations."/" = {
|
||||
proxyPass = "http://localhost:${toString port}";
|
||||
proxyPass = "http://localhost:8096";
|
||||
recommendedProxySettings = true;
|
||||
|
||||
extraConfig = ''
|
||||
|
@ -25,4 +41,5 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,30 +1,43 @@
|
|||
{ config, ... }:
|
||||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = homelab.services.paperless;
|
||||
homelab = config.nixosModules.homelab;
|
||||
service = "paperless";
|
||||
in
|
||||
{
|
||||
services =
|
||||
let
|
||||
cfg = config.services.paperless;
|
||||
hostname = "paperless.oliverdavies.uk";
|
||||
in
|
||||
{
|
||||
paperless = {
|
||||
options.nixosModules.homelab.services.${service} = {
|
||||
enable = mkEnableOption "Enable ${service}";
|
||||
|
||||
url = mkOption {
|
||||
default = "${service}.${homelab.baseDomain}";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services = {
|
||||
${service} = {
|
||||
enable = true;
|
||||
|
||||
dataDir = "/mnt/media/paperless";
|
||||
dataDir = "/mnt/media/${service}";
|
||||
|
||||
settings = {
|
||||
PAPERLESS_URL = "https://${hostname}";
|
||||
PAPERLESS_URL = "https://${cfg.url}";
|
||||
};
|
||||
};
|
||||
|
||||
nginx.virtualHosts."${hostname}" = {
|
||||
nginx.virtualHosts."${cfg.url}" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "oliverdavies.uk";
|
||||
useACMEHost = homelab.baseDomain;
|
||||
|
||||
locations."/" = {
|
||||
proxyPass = "http://localhost:${toString cfg.port}";
|
||||
proxyPass = "http://localhost:${toString config.services.${service}.port}";
|
||||
recommendedProxySettings = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,25 +1,51 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
services =
|
||||
let
|
||||
cfg = config.services.homepage-dashboard;
|
||||
in
|
||||
{
|
||||
homepage-dashboard = {
|
||||
config,
|
||||
lib,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = homelab.services.${service};
|
||||
homelab = config.homelab;
|
||||
opts = options.services.${service};
|
||||
service = "homepage-dashboard";
|
||||
in
|
||||
{
|
||||
options.homelab.services.${service} = {
|
||||
enable = mkEnableOption "Enable ${service}";
|
||||
|
||||
port = mkOption {
|
||||
default = opts.listenPort.default;
|
||||
type = types.port;
|
||||
};
|
||||
|
||||
url = mkOption {
|
||||
default = "${config.networking.hostName}.${homelab.baseDomain}";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services = {
|
||||
${service} = {
|
||||
enable = true;
|
||||
listenPort = 8097;
|
||||
listenPort = cfg.port;
|
||||
openFirewall = true;
|
||||
|
||||
services = (import ./services.nix { inherit config; });
|
||||
widgets = import ./widgets.nix;
|
||||
};
|
||||
|
||||
nginx.virtualHosts."nixedo.oliverdavies.uk" = {
|
||||
nginx.virtualHosts.${cfg.url} = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "oliverdavies.uk";
|
||||
useACMEHost = homelab.baseDomain;
|
||||
|
||||
locations."/".proxyPass = "http://localhost:${toString cfg.listenPort}";
|
||||
locations."/".proxyPass =
|
||||
"http://localhost:${toString config.services.homepage-dashboard.listenPort}";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,16 +1,34 @@
|
|||
{ config, ... }:
|
||||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = homelab.services.${service};
|
||||
homelab = config.nixosModules.homelab;
|
||||
service = "uptime-kuma";
|
||||
in
|
||||
{
|
||||
services = {
|
||||
uptime-kuma.enable = true;
|
||||
options.nixosModules.homelab.services.${service} = {
|
||||
enable = mkEnableOption "Enable ${service}";
|
||||
|
||||
nginx.virtualHosts."uptime.oliverdavies.uk" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "oliverdavies.uk";
|
||||
url = mkOption {
|
||||
default = "uptime.${homelab.baseDomain}";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
locations."/" = {
|
||||
proxyPass = "http://localhost:${toString config.services.uptime-kuma.settings.PORT}";
|
||||
recommendedProxySettings = true;
|
||||
config = mkIf cfg.enable {
|
||||
services = {
|
||||
${service}.enable = true;
|
||||
|
||||
nginx.virtualHosts.${cfg.url} = {
|
||||
forceSSL = true;
|
||||
useACMEHost = homelab.baseDomain;
|
||||
|
||||
locations."/" = {
|
||||
proxyPass = "http://localhost:${toString config.services.${service}.settings.PORT}";
|
||||
recommendedProxySettings = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue