diff --git a/nixos/roles/frontpage/default.nix b/nixos/roles/frontpage/default.nix new file mode 100644 index 0000000..e69de29 diff --git a/nixos/roles/frontpage/frontpage-calvin.nix b/nixos/roles/frontpage/frontpage-calvin.nix new file mode 100644 index 0000000..b62df46 --- /dev/null +++ b/nixos/roles/frontpage/frontpage-calvin.nix @@ -0,0 +1,47 @@ +{ + config, + pkgs, + lib, + ... +}: + +let + address = config.systemd.network.networks."10-ethernet".networkConfig.Address; + ip = builtins.elemAt (lib.splitString "/" address) 0; + port = 15006; + + calvinConfig = pkgs.writeText "config.yml" '' + title: "Calvin's Dashboard" + subtitle: "" + header: true + footer: false + defaults: + colorTheme: dark + services: + - name: "Services" + items: [] + ''; + + calvinRoot = pkgs.runCommand "homer-calvin" { } '' + cp -r ${pkgs.homer}/. $out + chmod -R u+w $out + cp ${calvinConfig} $out/config.yml + ''; +in +{ + services.nginx.virtualHosts."homer-calvin" = { + listen = [ + { + addr = "0.0.0.0"; + port = port; + } + ]; + root = "${calvinRoot}"; + locations."/" = { + index = "index.html"; + tryFiles = "$uri $uri/ /index.html"; + }; + }; + + networking.firewall.allowedTCPPorts = [ port ]; +} diff --git a/nixos/roles/frontpage/frontpage.nix b/nixos/roles/frontpage/frontpage.nix new file mode 100644 index 0000000..43c96f6 --- /dev/null +++ b/nixos/roles/frontpage/frontpage.nix @@ -0,0 +1,65 @@ +{ + config, + pkgs, + lib, + ... +}: + +let + address = config.systemd.network.networks."10-ethernet".networkConfig.Address; + ip = builtins.elemAt (lib.splitString "/" address) 0; + port = 15005; + + catppuccinFlavor = "mocha"; + logo = if catppuccinFlavor == "latte" then "assets/light_circle.png" else "assets/dark_circle.png"; + + mainConfig = pkgs.writeText "config.yml" '' + title: "Dashboard" + subtitle: "" + header: true + footer: false + logo: "${logo}" + stylesheet: + - "assets/catppuccin-${catppuccinFlavor}.css" + defaults: + colorTheme: dark + services: + - name: "Services" + items: + - name: "Vaultwarden" + url: "https://${ip}:8222" + - name: "SearXNG" + url: "http://${ip}:11080" + ''; + + mainRoot = pkgs.runCommand "homer-main" { } '' + cp -r ${pkgs.homer}/. $out + chmod -R u+w $out + cp ${mainConfig} $out/config.yml + mkdir -p $out/assets/icons + cp ${./assets/catppuccin-${catppuccinFlavor}.css} $out/assets/catppuccin-${catppuccinFlavor}.css + cp ${./assets/dark_circle.png} $out/assets/dark_circle.png + cp ${./assets/light_circle.png} $out/assets/light_circle.png + cp -r ${./assets/icons}/. $out/assets/icons/ + ''; +in +{ + services.nginx = { + enable = true; + virtualHosts."homer-main" = { + listen = [ + { + addr = "0.0.0.0"; + port = port; + } + ]; + root = "${mainRoot}"; + locations."/" = { + index = "index.html"; + tryFiles = "$uri $uri/ /index.html"; + }; + }; + }; + + networking.firewall.allowedTCPPorts = [ port ]; +}