From 4389503e0727971223991720c8c728fff0291639 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Mon, 29 Jul 2024 21:16:34 -0600 Subject: [PATCH] modules/ts-reverse-proxy: remove in favor of input's module --- flake.nix | 31 +++++---- modules/default.nix | 1 - modules/ts-reverse-proxy.nix | 128 ----------------------------------- 3 files changed, 17 insertions(+), 143 deletions(-) delete mode 100644 modules/ts-reverse-proxy.nix diff --git a/flake.nix b/flake.nix index 1441481..3cc21b6 100644 --- a/flake.nix +++ b/flake.nix @@ -108,25 +108,27 @@ outputs = { self + , beyt , darwin + , emacs-overlay , gostart - , mcchunkie , kogs + , lix-module + , mcchunkie + , microca + , nixos-hardware , po , pots , pr-status + , simple-nixos-mailserver , stable - , ts-reverse-proxy , traygent + , ts-reverse-proxy , tsvnstat , unstable , unstableSmall , xin-secrets , xintray - , simple-nixos-mailserver - , nixos-hardware - , beyt - , lix-module , ... } @ inputs: let @@ -152,18 +154,19 @@ xin-secrets.nixosModules.sops xin-secrets.nixosModules.xin-secrets lix-module.nixosModules.default + ts-reverse-proxy.nixosModule ]; }; overlays = [ - inputs.emacs-overlay.overlay - inputs.gostart.overlay - inputs.mcchunkie.overlay - inputs.kogs.overlay - inputs.microca.overlay - inputs.pots.overlay - inputs.pr-status.overlay - inputs.ts-reverse-proxy.overlay + emacs-overlay.overlay + gostart.overlay + kogs.overlay + mcchunkie.overlay + microca.overlay + pots.overlay + pr-status.overlay + ts-reverse-proxy.overlay ]; buildSys = sys: sysBase: extraMods: name: diff --git a/modules/default.nix b/modules/default.nix index e5cde3a..b32d0f5 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -6,7 +6,6 @@ ./rtlamr2mqtt.nix ./sliding-sync.nix ./ssh-fido-agent.nix - ./ts-reverse-proxy.nix ./tsvnstat.nix ./veilid-server.nix ./wallabag.nix diff --git a/modules/ts-reverse-proxy.nix b/modules/ts-reverse-proxy.nix deleted file mode 100644 index bc3406b..0000000 --- a/modules/ts-reverse-proxy.nix +++ /dev/null @@ -1,128 +0,0 @@ -{ lib -, config -, pkgs -, ... -}: -with lib; -let - cfg = config.services.ts-reverse-proxy; - enabledServers = filterAttrs (_: conf: conf.enable) cfg.servers; -in -{ - options = { - services.ts-reverse-proxy = { - package = mkPackageOption pkgs "ts-reverse-proxy" { }; - - servers = mkOption { - description = "Configuration of multiple `ts-reverse-proxy` instalces."; - default = { }; - - type = with types; attrsOf (submodule ({ name, ... }: { - options = { - enable = lib.mkEnableOption "Enable ts-reverse-proxy for ${name}"; - reversePort = mkOption { - type = types.int; - default = 5000; - description = '' - Port to forward connections to. - ''; - }; - - reverseIP = mkOption { - type = types.str; - default = "127.0.0.1"; - description = '' - IP to forward connections to. - ''; - }; - - reverseName = mkOption { - type = types.str; - default = name; - description = '' - Name used in for the front facing http server (will be a tailscale name). - ''; - }; - - hostHeader = mkOption { - type = types.str; - default = ""; - description = '' - Manually set the Host header - ''; - }; - - user = mkOption { - type = with types; oneOf [ str int ]; - default = name; - description = '' - The user the service will use. - ''; - }; - - group = mkOption { - type = with types; oneOf [ str int ]; - default = name; - description = '' - The group the service will use. - ''; - }; - - dataDir = mkOption { - type = types.path; - default = "/var/lib/${name}"; - description = "Path ts-reverse-proxy home directory"; - }; - - envFile = mkOption { - type = types.path; - default = "/run/secrets/ts_proxy_env-${name}"; - description = '' - Path to a file containing the ts-reverse-proxy token information - ''; - }; - }; - })); - }; - }; - }; - - config = mkIf (enabledServers != { }) { - environment.systemPackages = [ cfg.package ]; - - users.groups = mapAttrs' - (name: _: nameValuePair name { }) - enabledServers; - users.users = mapAttrs' - (name: conf: nameValuePair name { - description = "System user for ts-reverse-proxy instance ${name}"; - isSystemUser = true; - group = name; - home = "${conf.dataDir}"; - createHome = true; - }) - enabledServers; - - systemd.services = mapAttrs' - (name: conf: nameValuePair name { - description = "ts-reverse-proxy instance ${name}"; - enable = true; - after = [ "network-online.target" ]; - wants = [ "network-online.target" ]; - wantedBy = [ "multi-user.target" ]; - - environment = { HOME = "${conf.dataDir}"; }; - - serviceConfig = { - User = conf.user; - Group = conf.group; - - ExecStart = "${cfg.package}/bin/ts-reverse-proxy ${lib.optionalString (conf.hostHeader != "") "-host-header '${conf.hostHeader}'"} -name ${conf.reverseName} -port ${ - toString conf.reversePort - } -ip ${conf.reverseIP}"; - #EnvironmentFile = conf.envFile; - }; - }) - enabledServers; - }; -}