aboutsummaryrefslogtreecommitdiff
path: root/services/bacchus-dashboard/bacchus-dashboard.service.nix
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-06-14 16:40:48 +0530
committerAkshay Nair <phenax5@gmail.com>2025-06-14 16:40:48 +0530
commit42df69164dbc74e5ddb54f5a7a01fd66260fef57 (patch)
treebc8b19c39df9edf16ca6827005b3d5e1ef564764 /services/bacchus-dashboard/bacchus-dashboard.service.nix
parent58519ea7b12e8ad58c0f97d9636d30572a789b41 (diff)
downloadhomeserver-nixos-config-42df69164dbc74e5ddb54f5a7a01fd66260fef57.tar.gz
homeserver-nixos-config-42df69164dbc74e5ddb54f5a7a01fd66260fef57.zip
Switch to coredns + refactor dns hosts mapping into service + more refactor
Diffstat (limited to 'services/bacchus-dashboard/bacchus-dashboard.service.nix')
-rw-r--r--services/bacchus-dashboard/bacchus-dashboard.service.nix47
1 files changed, 47 insertions, 0 deletions
diff --git a/services/bacchus-dashboard/bacchus-dashboard.service.nix b/services/bacchus-dashboard/bacchus-dashboard.service.nix
new file mode 100644
index 0000000..8b0fcb9
--- /dev/null
+++ b/services/bacchus-dashboard/bacchus-dashboard.service.nix
@@ -0,0 +1,47 @@
+{ config, lib, pkgs, ... }:
+with lib;
+let
+ cfg = config.services.bacchus-dashboard;
+
+ rootHTML = import ./dashboard-template.nix cfg;
+ indexHTMLFile = pkgs.writeText "index.html" rootHTML;
+
+ pageDir = pkgs.stdenv.mkDerivation {
+ pname = "dashboard-page";
+ version = "0.0.0";
+ unpackPhase = "true"; # no source
+ installPhase = ''
+ mkdir -p $out;
+ cp ${indexHTMLFile} $out/index.html;
+ '';
+ };
+in
+{
+ options.services.bacchus-dashboard = {
+ enable = mkEnableOption "Enable dashboard";
+ title = mkOption { type = types.str; default = "Dashboard"; };
+ links = mkOption {
+ type = types.listOf (types.attrs);
+ default = [];
+ };
+ embedLink = mkOption { type = types.str; };
+ openFirewall = mkEnableOption "Open firewall ports";
+ host = mkOption { type = types.str; default = "_"; };
+ port = mkOption { type = types.int; default = 80; };
+ };
+
+ config = {
+ services.nginx = mkIf cfg.enable {
+ enable = true;
+ virtualHosts.${cfg.host} = {
+ listen = [ { addr = toString cfg.port; } ];
+ locations."/" = {
+ root = pageDir;
+ tryFiles = "$uri /index.html";
+ };
+ };
+ };
+
+ networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ 80 ];
+ };
+}