diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-06-10 13:06:48 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-06-10 18:58:25 +0530 |
| commit | 2a73a5899124fa15c3962b9bd385ebd415a0ccf9 (patch) | |
| tree | 3b0c29a29cf9ef4c844afc90aafcd61ef8122d21 /modules/dashboard/bacchus-dashboard.service.nix | |
| parent | 279241632b566fd26011409672277ca02ed697d1 (diff) | |
| download | homeserver-nixos-config-2a73a5899124fa15c3962b9bd385ebd415a0ccf9.tar.gz homeserver-nixos-config-2a73a5899124fa15c3962b9bd385ebd415a0ccf9.zip | |
Add dashboard for linking services
Diffstat (limited to 'modules/dashboard/bacchus-dashboard.service.nix')
| -rw-r--r-- | modules/dashboard/bacchus-dashboard.service.nix | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/modules/dashboard/bacchus-dashboard.service.nix b/modules/dashboard/bacchus-dashboard.service.nix new file mode 100644 index 0000000..c14111b --- /dev/null +++ b/modules/dashboard/bacchus-dashboard.service.nix @@ -0,0 +1,46 @@ +{ 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 = []; + }; + 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 ]; + }; +} |
