feat(server): HF-plant

This commit is contained in:
2025-09-05 19:39:45 +08:00
parent 3652579508
commit e78a3af90c
4 changed files with 96 additions and 0 deletions

View File

@@ -24,5 +24,6 @@
./immich.nix
./efl.nix
./plant.nix
];
}

View File

@@ -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" ];
}
];
}

18
flake.lock generated
View File

@@ -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"

View File

@@ -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";