From d7c3bd07752f62931cfb0d1be299fb9585923fe6 Mon Sep 17 00:00:00 2001 From: ashisgreat22 Date: Tue, 17 Mar 2026 21:26:51 +0100 Subject: [PATCH] Fix EnvironmentFile merge with mkMerge --- modules/openclaw.nix | 57 +++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/modules/openclaw.nix b/modules/openclaw.nix index 8335b1a..412ea58 100644 --- a/modules/openclaw.nix +++ b/modules/openclaw.nix @@ -75,38 +75,41 @@ in after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; - serviceConfig = { - Type = "simple"; - User = "openclaw"; - Group = "openclaw"; - WorkingDirectory = dataDir; + serviceConfig = lib.mkMerge [ + { + Type = "simple"; + User = "openclaw"; + Group = "openclaw"; + WorkingDirectory = dataDir; - Environment = [ - "NODE_ENV=production" - "OPENCLAW_CONFIG_DIR=${configDir}" - "OPENCLAW_DATA_DIR=${dataDir}" - "OPENCLAW_WORKSPACE_DIR=${workspaceDir}" - "PATH=${pkgs.nodejs_22}/bin:${pkgs.git}/bin:${pkgs.bash}/bin:${pkgs.coreutils}/bin" - ]; + Environment = [ + "NODE_ENV=production" + "OPENCLAW_CONFIG_DIR=${configDir}" + "OPENCLAW_DATA_DIR=${dataDir}" + "OPENCLAW_WORKSPACE_DIR=${workspaceDir}" + "PATH=${pkgs.nodejs_22}/bin:${pkgs.git}/bin:${pkgs.bash}/bin:${pkgs.coreutils}/bin" + ]; - EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile; + ExecStartPre = [ + "${pkgs.coreutils}/bin/mkdir -p ${configDir} ${dataDir} ${workspaceDir}" + "${pkgs.bash}/bin/bash -c 'cp -n /etc/openclaw/openclaw.json ${configDir}/ || true'" + ]; - ExecStartPre = [ - "${pkgs.coreutils}/bin/mkdir -p ${configDir} ${dataDir} ${workspaceDir}" - "${pkgs.bash}/bin/bash -c 'cp -n /etc/openclaw/openclaw.json ${configDir}/ || true'" - ]; + ExecStart = "${pkgs.nodejs_22}/bin/npx openclaw gateway --port ${toString cfg.port} --allow-unconfigured"; - ExecStart = "${pkgs.nodejs_22}/bin/npx openclaw gateway --port ${toString cfg.port} --allow-unconfigured"; + Restart = "on-failure"; + RestartSec = "10s"; - Restart = "on-failure"; - RestartSec = "10s"; - - # Security - PrivateTmp = true; - ProtectSystem = "strict"; - ReadWritePaths = [ "/var/lib/openclaw" configDir dataDir workspaceDir ]; - NoNewPrivileges = true; - }; + # Security + PrivateTmp = true; + ProtectSystem = "strict"; + ReadWritePaths = [ "/var/lib/openclaw" configDir dataDir workspaceDir ]; + NoNewPrivileges = true; + } + (lib.mkIf (cfg.environmentFile != null) { + EnvironmentFile = cfg.environmentFile; + }) + ]; }; }; }