From e78a3af90c46e0929beea86c04f497490358f63d Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Fri, 5 Sep 2025 19:39:45 +0800 Subject: [PATCH] feat(server): HF-plant --- config/hosts/imxyy-nix-server/default.nix | 1 + config/hosts/imxyy-nix-server/plant.nix | 74 +++++++++++++++++++++++ flake.lock | 18 ++++++ flake.nix | 3 + 4 files changed, 96 insertions(+) create mode 100644 config/hosts/imxyy-nix-server/plant.nix diff --git a/config/hosts/imxyy-nix-server/default.nix b/config/hosts/imxyy-nix-server/default.nix index 009413a..00544ba 100644 --- a/config/hosts/imxyy-nix-server/default.nix +++ b/config/hosts/imxyy-nix-server/default.nix @@ -24,5 +24,6 @@ ./immich.nix ./efl.nix + ./plant.nix ]; } diff --git a/config/hosts/imxyy-nix-server/plant.nix b/config/hosts/imxyy-nix-server/plant.nix new file mode 100644 index 0000000..c567ae7 --- /dev/null +++ b/config/hosts/imxyy-nix-server/plant.nix @@ -0,0 +1,74 @@ +{ + inputs, + pkgs, + lib, + ... +}: +let + app = pkgs.buildNpmPackage (finalAttrs: { + pname = "HF-plant"; + version = "unstable-2025-09-21"; + + src = inputs.plant; + + buildPhase = '' + runHook preBuild + + npm run build + npm run build:proxy + + runHook postBuild + ''; + installPhase = '' + runHook preInstall + + mkdir $out + mv dist $out + cp .env proxy-server-bundled.js $out + + runHook postInstall + ''; + + npmDepsHash = "sha256-ret4BtjrEt8L1nlvJmFiejAKmbz89Z7NSiKs+qlB51w="; + }); +in +{ + systemd.services.HF-plant-proxy = { + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStart = "${lib.getExe pkgs.bash} -c 'source ${app}/.env; export FEISHU_APP_ID FEISHU_APP_SECRET AMAP_JSCODE; ${lib.getExe pkgs.nodejs} ${app}/proxy-server-bundled.js'"; + Restart = "always"; + RestartSec = 120; + }; + }; + services.caddy.virtualHosts."plant.imxyy.top" = { + extraConfig = '' + handle /api/* { + reverse_proxy localhost:3001 + } + + handle /* { + root * ${app}/dist + try_files {path} /index.html + file_server + } + ''; + }; + services.frp.settings.proxies = [ + { + name = "plant-http"; + type = "http"; + localIP = "127.0.0.1"; + localPort = 80; + customDomains = [ "plant.imxyy.top" ]; + } + { + name = "plant-https"; + type = "https"; + localIP = "127.0.0.1"; + localPort = 443; + customDomains = [ "plant.imxyy.top" ]; + } + ]; +} diff --git a/flake.lock b/flake.lock index 651ab10..f0a9770 100644 --- a/flake.lock +++ b/flake.lock @@ -993,6 +993,23 @@ "type": "github" } }, + "plant": { + "flake": false, + "locked": { + "lastModified": 1758423341, + "narHash": "sha256-dHcKh7T8I70bKPwgqO5MxZ9bWHINwzRPhFp5waQy2r8=", + "ref": "refs/heads/master", + "rev": "08dc0b3889797eb3618c7475c3c367ec0e5fdf40", + "revCount": 6, + "type": "git", + "url": "ssh://git@git.imxyy.top:2222/imxyy1soope1/HF-plant.git" + }, + "original": { + "rev": "08dc0b3889797eb3618c7475c3c367ec0e5fdf40", + "type": "git", + "url": "ssh://git@git.imxyy.top:2222/imxyy1soope1/HF-plant.git" + } + }, "root": { "inputs": { "catppuccin": "catppuccin", @@ -1012,6 +1029,7 @@ "nixpkgs-master": "nixpkgs-master", "nixpkgs-stable": "nixpkgs-stable_2", "nixpkgs-unstable": "nixpkgs-unstable", + "plant": "plant", "sops-nix": "sops-nix", "stylix": "stylix", "zen": "zen" diff --git a/flake.nix b/flake.nix index 1a645a1..c600ebb 100644 --- a/flake.nix +++ b/flake.nix @@ -48,6 +48,9 @@ zen.url = "github:0xc000022070/zen-browser-flake"; zen.inputs.nixpkgs.follows = "nixpkgs"; + plant.url = "git+ssh://git@git.imxyy.top:2222/imxyy1soope1/HF-plant.git?rev=08dc0b3889797eb3618c7475c3c367ec0e5fdf40"; + plant.flake = false; + catppuccin.url = "github:catppuccin/nix"; catppuccin.inputs.nixpkgs.follows = "nixpkgs";