From b336cdb0cdcdeff54bb7c28d11762d9be71d5de2 Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 23 Apr 2023 03:20:24 -0400 Subject: feat: add nix module --- nix/module.nix | 18 +++++++++++++++--- src/guzzle_api/api.py | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/nix/module.nix b/nix/module.nix index 0dff2d0..e615561 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -5,9 +5,21 @@ ... }: let cfg = config.services.guzzle-api; - inherit (lib) mkDefault mkEnableOption mkIf; + inherit (lib) mkDefault mkEnableOption mkOption mkIf types; in { - options.services.guzzle-api.enable = mkEnableOption "enable guzzle-api"; + options.services.guzzle-api = { + enable = mkEnableOption "enable guzzle-api"; + url = mkOption { + type = types.string; + default = ""; + description = "url string for guzzle-api"; + }; + port = mkOption { + type = types.int; + default = 8080; + description = "port for guzzle-api"; + }; + }; config.systemd.services.guzzle-api = mkIf cfg.enable { guzzle-api = { @@ -16,7 +28,7 @@ in { wantedBy = ["multi-user.target"]; after = ["network.target"]; script = '' - ${pkgs.guzzle-api-server} --host 0.0.0.0 --port 8000 + URL=${cfg.url} ${pkgs.guzzle-api-server} --host 0.0.0.0 --port "${cfg.port}" ''; serviceConfig = mkDefault { Restart = "always"; diff --git a/src/guzzle_api/api.py b/src/guzzle_api/api.py index 180ceb6..76f25f7 100644 --- a/src/guzzle_api/api.py +++ b/src/guzzle_api/api.py @@ -1,11 +1,11 @@ +import os + from fastapi import FastAPI, Query from fastapi.staticfiles import StaticFiles from guzzle_api import lib from guzzle_api.teawie import lib as teawie -import os - URL = os.getenv("URL") TEAWIE_STATIC_ENDPOINT = "/static/teawie" -- cgit v1.2.3