From 227319b662ea07b903fa119167ed0a3b4015804f Mon Sep 17 00:00:00 2001 From: Joakim Repomaa Date: Tue, 11 Feb 2025 10:31:10 +0200 Subject: [PATCH] refactor --- hosts/freun.dev/services.nix | 13 ++++--- modules/services/bin.nix | 65 ----------------------------------- modules/services/default.nix | 2 +- modules/services/hastebin.nix | 55 +++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 71 deletions(-) delete mode 100644 modules/services/bin.nix create mode 100644 modules/services/hastebin.nix diff --git a/hosts/freun.dev/services.nix b/hosts/freun.dev/services.nix index 188696b..c13ff87 100644 --- a/hosts/freun.dev/services.nix +++ b/hosts/freun.dev/services.nix @@ -67,11 +67,6 @@ in }; }; - bin = { - enable = true; - subdomain = "bin"; - }; - workout-tracker = { enable = true; subdomain = "fit"; @@ -104,4 +99,12 @@ in tailscale.enable = true; }; + + services = { + hastebin = { + enable = true; + subdomain = "bin"; + }; + }; + } diff --git a/modules/services/bin.nix b/modules/services/bin.nix deleted file mode 100644 index f8f090e..0000000 --- a/modules/services/bin.nix +++ /dev/null @@ -1,65 +0,0 @@ -{ lib, config, inputs, ... }: -let - cfg = config.modules.services.bin; - fqdn = "${cfg.subdomain}.${config.networking.domain}"; -in -{ - imports = [ - inputs.hastebin.nixosModules.default - ]; - - options.modules.services.bin = { - enable = lib.mkEnableOption "Enable Rustypaste"; - subdomain = lib.mkOption { - type = lib.types.str; - }; - port = lib.mkOption { - type = lib.types.int; - default = 3600; - }; - }; - - config = lib.mkIf cfg.enable { - services.hastebin = { - enable = true; - settings = { - port = cfg.port; - host = "::1"; - max_size = "1 GiB"; - mime_overrides = { - "text/plain" = [ - "log" - "txt" - "diff" - "sh" - "rs" - "toml" - "cr" - "nix" - "rb" - "ts" - "tsx" - "jsx" - ]; - }; - auth_tokens_file = "/var/secrets/hastebin-tokens"; - }; - }; - - modules.services.webserver = { - enable = lib.mkDefault true; - vHosts.${fqdn} = { - proxyBuffering = false; - locations."/" = { - proxyPort = cfg.port; - extraConfig = '' - client_max_body_size 0; - proxy_send_timeout 300; - proxy_read_timeout 300; - send_timeout 300; - ''; - }; - }; - }; - }; -} diff --git a/modules/services/default.nix b/modules/services/default.nix index c6f380e..9bad03f 100644 --- a/modules/services/default.nix +++ b/modules/services/default.nix @@ -12,7 +12,7 @@ ./tailscale.nix ./workout-tracker.nix ./gotosocial.nix - ./bin.nix + ./hastebin.nix ./workout-sync.nix ]; } diff --git a/modules/services/hastebin.nix b/modules/services/hastebin.nix new file mode 100644 index 0000000..5335773 --- /dev/null +++ b/modules/services/hastebin.nix @@ -0,0 +1,55 @@ +{ lib, config, inputs, ... }: +let + cfg = config.services.hastebin; + fqdn = "${cfg.subdomain}.${config.networking.domain}"; +in +{ + imports = [ + inputs.hastebin.nixosModules.default + ]; + + options.services.hastebin.subdomain = lib.mkOption { + type = lib.types.str; + }; + + config = lib.mkIf cfg.enable { + services.hastebin.settings = lib.mkDefault { + max_size = "1 GiB"; + host = "::1"; + port = 3600; + mime_overrides = { + "text/plain" = [ + "log" + "txt" + "diff" + "sh" + "rs" + "toml" + "cr" + "nix" + "rb" + "ts" + "tsx" + "jsx" + ]; + }; + auth_tokens_file = "/var/secrets/hastebin-tokens"; + }; + + modules.services.webserver = { + enable = lib.mkDefault true; + vHosts.${fqdn} = { + proxyBuffering = false; + locations."/" = { + proxyPort = cfg.settings.port; + extraConfig = '' + client_max_body_size 0; + proxy_send_timeout 300; + proxy_read_timeout 300; + send_timeout 300; + ''; + }; + }; + }; + }; +}