diff --git a/src/nix/eval-service.nix b/src/nix/eval-service.nix index cb866ba..6671835 100644 --- a/src/nix/eval-service.nix +++ b/src/nix/eval-service.nix @@ -17,6 +17,7 @@ let ./modules/service/image.nix ./modules/service/nixos.nix ./modules/service/nixos-init.nix + ./modules/service/ngrok.nix ]; argsModule = { diff --git a/src/nix/modules/service/ngrok.nix b/src/nix/modules/service/ngrok.nix new file mode 100644 index 0000000..38cbe32 --- /dev/null +++ b/src/nix/modules/service/ngrok.nix @@ -0,0 +1,32 @@ +{ pkgs, lib, config, ... }: + +let + inherit (lib) types; + + ngrokConfig = pkgs.writeText "ngrok-tunnels.yml" (builtins.toJSON config.ngrok.config); + +in +{ + options.ngrok = { + enable = lib.mkOption { + description = "Turn on ngrok service"; + type = types.bool; + default = false; + }; + config = lib.mkOption { + type = types.attrs; + description = "ngrok.conf configuration"; + }; + userConfigFile = lib.mkOption { + type = types.path; + default = ~/.ngrok2/ngrok.yml; + description = "path to ngrok.conf user configuration"; + }; + }; + + config = lib.mkIf (config.ngrok.enable) { + service.command = [ "${pkgs.ngrok}/bin/ngrok" "start" "--all" "--config" "${ngrokConfig}" "--config" "${config.ngrok.userConfigFile}" ]; + service.ports = [ "4040:4040" ]; + ngrok.config.web_addr = "0.0.0.0:4040"; + }; +}