codex: preserve generated local config sections
This commit is contained in:
@@ -4,9 +4,9 @@ service_tier = "fast"
|
||||
personality = "pragmatic"
|
||||
suppress_unstable_features_warning = true
|
||||
|
||||
# Portable Codex defaults. Home Manager appends host-local fragments from
|
||||
# ~/.codex/config.local.toml and ~/.codex/config.local-state.toml when it
|
||||
# regenerates ~/.codex/config.toml.
|
||||
# Portable Codex defaults. Home Manager regenerates ~/.codex/config.toml from
|
||||
# this file, ~/.codex/config.local.toml, and Codex-owned sections preserved in
|
||||
# ~/.codex/config.local-state.toml.
|
||||
|
||||
[mcp_servers.chrome-devtools]
|
||||
command = "npx"
|
||||
|
||||
@@ -31,7 +31,7 @@ in {
|
||||
generatedStateConfig = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "${cfg.codexHome}/config.local-state.toml";
|
||||
description = "Codex-generated host-local state harvested from config.toml.";
|
||||
description = "Codex-owned host-local config sections harvested from config.toml.";
|
||||
};
|
||||
|
||||
skillsDir = lib.mkOption {
|
||||
@@ -156,7 +156,7 @@ in {
|
||||
}
|
||||
|
||||
function flush_block() {
|
||||
if (keep && section != "" && !(section in base_sections) && !rejected_project(section)) {
|
||||
if (section != "" && !(section in base_sections) && !rejected_project(section)) {
|
||||
if (printed) {
|
||||
print ""
|
||||
}
|
||||
@@ -172,7 +172,6 @@ in {
|
||||
/^\[[^]]+\]$/ {
|
||||
flush_block()
|
||||
section = $0
|
||||
keep = ($0 ~ /^\[projects\./ || $0 ~ /^\[tui\./)
|
||||
block = $0 "\n"
|
||||
next
|
||||
}
|
||||
@@ -184,7 +183,9 @@ in {
|
||||
END {
|
||||
flush_block()
|
||||
}
|
||||
' "$base" "$target" > "$local_state"
|
||||
' "$base" "$target" \
|
||||
| ${lib.getExe pkgs.perl} -0pe 's/\n{3,}/\n\n/g' \
|
||||
> "$local_state"
|
||||
|
||||
if [ -s "$local_state" ]; then
|
||||
chmod 600 "$local_state"
|
||||
|
||||
Reference in New Issue
Block a user