fix: honor nix config overrides in mac app
This commit is contained in:
@@ -2,16 +2,27 @@ import Foundation
|
||||
|
||||
enum ClawdisConfigFile {
|
||||
private static let logger = Logger(subsystem: "com.steipete.clawdis", category: "config")
|
||||
private static let configPathEnv = "CLAWDIS_CONFIG_PATH"
|
||||
private static let stateDirEnv = "CLAWDIS_STATE_DIR"
|
||||
|
||||
static func url() -> URL {
|
||||
FileManager.default.homeDirectoryForCurrentUser
|
||||
.appendingPathComponent(".clawdis")
|
||||
if let override = self.envPath(self.configPathEnv) {
|
||||
return URL(fileURLWithPath: override)
|
||||
}
|
||||
return self.stateDirURL()
|
||||
.appendingPathComponent("clawdis.json")
|
||||
}
|
||||
|
||||
static func stateDirURL() -> URL {
|
||||
if let override = self.envPath(self.stateDirEnv) {
|
||||
return URL(fileURLWithPath: override, isDirectory: true)
|
||||
}
|
||||
return FileManager.default.homeDirectoryForCurrentUser
|
||||
.appendingPathComponent(".clawdis", isDirectory: true)
|
||||
}
|
||||
|
||||
static func defaultWorkspaceURL() -> URL {
|
||||
FileManager.default.homeDirectoryForCurrentUser
|
||||
.appendingPathComponent(".clawdis")
|
||||
self.stateDirURL()
|
||||
.appendingPathComponent("workspace", isDirectory: true)
|
||||
}
|
||||
|
||||
@@ -96,4 +107,12 @@ enum ClawdisConfigFile {
|
||||
self.saveDict(root)
|
||||
self.logger.debug("agent workspace updated set=\(!trimmed.isEmpty)")
|
||||
}
|
||||
|
||||
private static func envPath(_ key: String) -> String? {
|
||||
guard let value = ProcessInfo.processInfo.environment[key]?.trimmingCharacters(in: .whitespacesAndNewlines),
|
||||
!value.isEmpty else {
|
||||
return nil
|
||||
}
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user