diff options
| author | Franck Cuny <franck@fcuny.net> | 2025-11-15 12:11:43 -0800 |
|---|---|---|
| committer | Franck Cuny <franck@fcuny.net> | 2025-11-15 12:11:43 -0800 |
| commit | de1bf48711ca27f3d6e57e46085df1f667d1bf31 (patch) | |
| tree | 89617f9e987390d07efbacb91e0172c9f5d511fa /nix/modules/fcuny.net.nix | |
| parent | ignore errors (diff) | |
| download | x-de1bf48711ca27f3d6e57e46085df1f667d1bf31.tar.gz | |
remove goget as a package and switch to fcuny-net instead
Diffstat (limited to 'nix/modules/fcuny.net.nix')
| -rw-r--r-- | nix/modules/fcuny.net.nix | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/nix/modules/fcuny.net.nix b/nix/modules/fcuny.net.nix new file mode 100644 index 0000000..39f5bef --- /dev/null +++ b/nix/modules/fcuny.net.nix @@ -0,0 +1,66 @@ +{ + config, + lib, + pkgs, + ... +}: + +with lib; + +let + cfg = config.services.fcuny-net; +in +{ + options.services.fcuny-net = { + enable = mkEnableOption "fcuny.net service"; + + package = mkPackageOption pkgs "fcuny.net" { }; + + 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.fcuny.net = { + 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 ]; + }; + }; +} |
