mirror of
https://github.com/harivansh-afk/nix.git
synced 2026-04-21 17:00:48 +00:00
replace pi with openclaw (#60)
This commit is contained in:
parent
be2370f406
commit
630ec774ce
12 changed files with 160 additions and 114 deletions
61
hosts/netty/openclaw-gateway.nix
Normal file
61
hosts/netty/openclaw-gateway.nix
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
pkgs,
|
||||
username,
|
||||
...
|
||||
}:
|
||||
let
|
||||
homeDir = "/home/${username}";
|
||||
openClawStateDir = "${homeDir}/.openclaw";
|
||||
openClawConfigPath = "${openClawStateDir}/openclaw.json";
|
||||
openClawEnvFile = "${openClawStateDir}/.env";
|
||||
openClawBin = "${homeDir}/.local/share/npm/bin/openclaw";
|
||||
openClawCheck = pkgs.writeShellScript "openclaw-gateway-check" ''
|
||||
[ -x "${openClawBin}" ] && [ -f "${openClawConfigPath}" ] && [ -s "${openClawEnvFile}" ]
|
||||
'';
|
||||
in
|
||||
{
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${openClawStateDir} 0700 ${username} users -"
|
||||
"d ${openClawStateDir}/workspace 0700 ${username} users -"
|
||||
"z ${openClawEnvFile} 0600 ${username} users -"
|
||||
"z ${openClawConfigPath} 0600 ${username} users -"
|
||||
];
|
||||
|
||||
systemd.services.openclaw-gateway = {
|
||||
description = "OpenClaw Gateway";
|
||||
after = [ "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = with pkgs; [
|
||||
nodejs_22
|
||||
git
|
||||
coreutils
|
||||
findutils
|
||||
gnugrep
|
||||
gawk
|
||||
docker
|
||||
];
|
||||
environment = {
|
||||
HOME = homeDir;
|
||||
NODE_NO_WARNINGS = "1";
|
||||
OPENCLAW_NIX_MODE = "1";
|
||||
OPENCLAW_STATE_DIR = openClawStateDir;
|
||||
OPENCLAW_CONFIG_PATH = openClawConfigPath;
|
||||
NPM_CONFIG_USERCONFIG = "${homeDir}/.config/npm/npmrc";
|
||||
XDG_CACHE_HOME = "${homeDir}/.cache";
|
||||
XDG_CONFIG_HOME = "${homeDir}/.config";
|
||||
XDG_DATA_HOME = "${homeDir}/.local/share";
|
||||
};
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = username;
|
||||
Group = "users";
|
||||
WorkingDirectory = openClawStateDir;
|
||||
ExecCondition = openClawCheck;
|
||||
EnvironmentFile = "-${openClawEnvFile}";
|
||||
ExecStart = "${openClawBin} gateway run";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 5;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue