diff --git a/hosts/hydra/default.nix b/hosts/hydra/default.nix index 4334057..fa020f5 100644 --- a/hosts/hydra/default.nix +++ b/hosts/hydra/default.nix @@ -1,9 +1,19 @@ { ... }: { - kropcloud = { + kropcloud = + let + serverIp = "192.168.1.160"; + in { + services = { + hydra = { + enable = true; + listenHost = serverIp; + port = 3000; + }; + }; networking = { ipv4 = { - address = "192.168.1.160"; + address = serverIp; prefixLength = 24; defaultGateway = "192.168.1.1"; }; diff --git a/nixosModules/services/default.nix b/nixosModules/services/default.nix index 76b5211..edad497 100644 --- a/nixosModules/services/default.nix +++ b/nixosModules/services/default.nix @@ -3,5 +3,6 @@ imports = [ ./ssh ./tailscale + ./hydra ]; } diff --git a/nixosModules/services/hydra/default.nix b/nixosModules/services/hydra/default.nix new file mode 100644 index 0000000..ee09fc4 --- /dev/null +++ b/nixosModules/services/hydra/default.nix @@ -0,0 +1,45 @@ +{ + config, + lib, + ... +}: +let + cfg = config.kropcloud.services.hydra; +in +{ + options.kropcloud.services.hydra = { + enable = lib.mkEnableOption "Whence to enable hydra service."; + listenHost = lib.mkOption { + description = "Which host should hydra listen at"; + type = lib.types.str; + default = "localhost"; + example = "192.168.1.160"; + }; + port = lib.mkOption { + description = "Which port should hydra listen at"; + type = lib.types.port; + default = 3000; + example = 3000; + }; + hydraURL = lib.mkOption { + description = "Which host should hydra listen at"; + type = lib.types.nullOr lib.types.str; + default = null; + example = "http://192.168.1.160:3000"; + }; + }; + config = lib.mkIf cfg.enable { + services.hydra = { + enable = true; + useSubstitutes = true; + hydraURL = if (cfg.hydraURL != null) then cfg.hydraURL else "http://${cfg.listenHost}:${builtins.toString cfg.port}"; + notificationSender = "hydra@localhost"; + listenHost = cfg.listenHost; + port = cfg.port; + }; + + networking.firewall.allowedTCPPorts = [ + cfg.port + ]; + }; +}