aboutsummaryrefslogtreecommitdiff
path: root/nix/modules/website.nix
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2025-11-15 12:27:46 -0800
committerFranck Cuny <franck@fcuny.net>2025-11-15 12:27:46 -0800
commit28b0f67914b11069d3afddd42b574197126b846d (patch)
tree84c1c1ad6d33e38c7d882cd2dac60e45b7bb9cb2 /nix/modules/website.nix
parentfix name of systemd unit for fcuny-net (diff)
downloadx-28b0f67914b11069d3afddd42b574197126b846d.tar.gz
rename fcuny-net to website
Diffstat (limited to 'nix/modules/website.nix')
-rw-r--r--nix/modules/website.nix66
1 files changed, 66 insertions, 0 deletions
diff --git a/nix/modules/website.nix b/nix/modules/website.nix
new file mode 100644
index 0000000..5c82e34
--- /dev/null
+++ b/nix/modules/website.nix
@@ -0,0 +1,66 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+
+with lib;
+
+let
+ cfg = config.services.website;
+in
+{
+ options.services.website = {
+ enable = mkEnableOption "fcuny.net service";
+
+ package = mkPackageOption pkgs "website" { };
+
+ port = mkOption {
+ type = types.port;
+ default = 8070;
+ description = "Port to listen on";
+ };
+
+ openFirewall = mkOption {
+ type = types.bool;
+ default = false;
+ description = "Whether to open the firewall for the goget service";
+ };
+ };
+
+ config = mkIf cfg.enable {
+ systemd.services.website = {
+ description = "fcuny.net service";
+ wantedBy = [ "multi-user.target" ];
+ after = [ "network.target" ];
+ wants = [ "network.target" ];
+
+ serviceConfig = {
+ Type = "exec";
+ DynamicUser = true;
+ ExecStart = "${cfg.package}/bin/fcuny-net";
+ Restart = "always";
+ RestartSec = "5";
+
+ # Security settings
+ NoNewPrivileges = true;
+ ProtectSystem = "strict";
+ ProtectHome = true;
+ PrivateTmp = true;
+ ProtectKernelTunables = true;
+ ProtectKernelModules = true;
+ ProtectControlGroups = true;
+ RestrictSUIDSGID = true;
+ RestrictRealtime = true;
+ RestrictNamespaces = true;
+ LockPersonality = true;
+ MemoryDenyWriteExecute = true;
+ };
+ };
+
+ networking.firewall = mkIf cfg.openFirewall {
+ allowedTCPPorts = [ cfg.port ];
+ };
+ };
+}