Skip to content

Commit

Permalink
Add homepage service, consolidate observability stack into one toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitawootten committed Mar 20, 2024
1 parent e5eeac2 commit d4724ef
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions hostModules/homelab/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ in
imports = [
./observability
./acme.nix
./homepage.nix
];

options.homelab = {
Expand Down
26 changes: 26 additions & 0 deletions hostModules/homelab/homepage.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{ lib, config, ... }:
let
cfg = config.homelab.homepage;
in
{
options.homelab.homepage = {
enable = lib.mkEnableOption "Homepage dashboard";
domain = lib.mkOption {
type = lib.types.str;
default = config.homelab.domain;
description = "Homepage domain";
};
};

config = lib.mkIf cfg.enable {
services.homepage-dashboard = {
enable = true;
};

services.nginx.virtualHosts."${cfg.domain}" = {
forceSSL = true;
useACMEHost = config.homelab.domain;
locations."/".proxyPass = "http://localhost:${toString config.services.homepage-dashboard.listenPort}";
};
};
}
14 changes: 14 additions & 0 deletions hostModules/homelab/observability/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
{ lib, config, ... }:
let
cfg = config.homelab.observability;
in
{
imports = [
./grafana.nix
./prometheus.nix
./loki.nix
];

options.homelab.observability = {
enable = lib.mkEnableOption "Enable basic observability stack";
};

config = lib.mkIf cfg.enable {
homelab.observability.grafana.enable = true;
homelab.observability.prometheus.enable = true;
homelab.observability.loki.enable = true;
};
}
6 changes: 6 additions & 0 deletions hostModules/homelab/observability/grafana.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ in
description = "Grafana's domain";
readOnly = true;
};
url = lib.mkOption {
type = lib.types.str;
default = "https://${cfg.domain}";
description = "Grafana's URL";
readOnly = true;
};
};

config = lib.mkIf cfg.enable {
Expand Down

0 comments on commit d4724ef

Please sign in to comment.