diff options
-rw-r--r-- | modules/root/cgit.nix | 4 | ||||
-rw-r--r-- | modules/root/gitea.nix | 60 |
2 files changed, 62 insertions, 2 deletions
diff --git a/modules/root/cgit.nix b/modules/root/cgit.nix index f3814cd..366c1f8 100644 --- a/modules/root/cgit.nix +++ b/modules/root/cgit.nix @@ -1,7 +1,7 @@ { lib, pkgs, config, userDetails, ... }: let cfg = config.cgit; -in{ +in { options = { cgit = { enable = lib.mkEnableOption "enables cgit service"; @@ -33,7 +33,7 @@ in{ }; }; - config = lib.mkIf config.cgit.enable { + config = lib.mkIf cfg.enable { # Configure cgit container containers.cgit = { autoStart = true; diff --git a/modules/root/gitea.nix b/modules/root/gitea.nix new file mode 100644 index 0000000..32c56db --- /dev/null +++ b/modules/root/gitea.nix @@ -0,0 +1,60 @@ +{ lib, pkgs, config, userDetails, ... }: +let + cfg = config.gitea; +in { + options = { + gitea = { + enable = lib.mkEnableOption "enables gitea service"; + hostAddress = lib.mkOption { + type = lib.types.str; + description = "hostAddress for the container"; + default = "10.0.1.1"; + }; + localAddress = lib.mkOption { + type = lib.types.str; + description = "localAddress for the container"; + default = "10.0.1.3"; + }; + }; + }; + + config = lib.mkIf cfg.enable { + containers.gitea = { + autoStart = true; + privateNetwork = true; + hostAddress = cfg.hostAddress; + localAddress = cfg.localAddress; + + config = { lib, config, ... }: { + # Enable gitea service + services.gitea = { + enable = true; + user = "git"; # So ssh cloning uses git@gitea + settings = { + server = { + HTTP_PORT = 3000; # Can't set as 80 without root permissions, use 3000 instead + }; + }; + }; + + # Networking, etc. + # Redirect 80 to 3000 + networking.nftables = { + enable = true; + ruleset = '' + table ip nat { + chain prerouting { + type nat hook prerouting priority 0; + tcp dport 80 redirect to :3000 + } + } + ''; + }; + networking.firewall.allowedTCPPorts = [ 3000 80 22 ]; # Still need to forward 3000 for nftables rule to work + networking.hostName = "gitea"; + + system.stateVersion = "25.05"; + }; + }; + }; +} |