github-copilot-cli: clarify mutable transitions and cover ownership

Check effective file overrides, trust-state parsing, and custom paths without changing the opt-in default. Describe byte-identical relinking accurately during the filename migration.
This commit is contained in:
Austin Horstman
2026-10-02 15:48:37 -05:00
parent 2547d39701
commit d2f65d77f7
7 changed files with 101 additions and 16 deletions

View File

@@ -43,6 +43,8 @@ in
settings = {
model = "claude-sonnet-4-5";
theme = "dark";
trusted_folders = [ "/home/user/ignored" ];
trustedFolders = [ "/home/user/ignored" ];
};
context = inlineContext;
agents = {
@@ -58,6 +60,14 @@ in
};
};
test.asserts.warnings.expected = [
''
programs.github-copilot-cli.settings: trusted_folders and trustedFolders
are not written to settings.json. Copilot CLI keeps trusted folders in
its own state; use programs.github-copilot-cli.trustedFolders instead.
''
];
nmt.script =
assert !(config.home.activation ? githubCopilotCliSettings);
# Turning mutableSettings off removes an unchanged merged copy before

View File

@@ -1,9 +1,14 @@
{
github-copilot-cli-cleanup-disabled = import ./settings-wiring.nix "cleanup-disabled";
github-copilot-cli-cleanup-redirected = import ./settings-wiring.nix "cleanup-redirected";
github-copilot-cli-disabled = import ./settings-wiring.nix "disabled";
github-copilot-cli-config = ./config.nix;
github-copilot-cli-directories = ./directories.nix;
github-copilot-cli-empty-settings = import ./settings-wiring.nix "empty";
github-copilot-cli-lsp = ./lsp.nix;
github-copilot-cli-mcp = ./mcp.nix;
github-copilot-cli-mcp-integration = ./mcp-integration.nix;
github-copilot-cli-mutable-empty-settings = import ./settings-wiring.nix "mutable-empty";
github-copilot-cli-mutable-settings = ./mutable-settings.nix;
github-copilot-cli-path-not-directory = ./path-not-directory.nix;
github-copilot-cli-store-path-dir = ./store-path-dir.nix;

View File

@@ -0,0 +1,60 @@
mode:
{ config, lib, ... }:
let
redirected = mode == "cleanup-redirected";
cleanup = config.home.activation.githubCopilotCliImmutableSettings or null;
target = "copilot profile/declared.json";
in
{
programs.github-copilot-cli = {
enable = mode != "disabled";
package = null;
mutableSettings = lib.elem mode [
"mutable-empty"
"disabled"
];
settings =
lib.optionalAttrs
(
!lib.elem mode [
"empty"
"mutable-empty"
]
)
{
model = "claude-sonnet-4-5";
};
trustedFolders = lib.optionals (mode == "disabled") [ "/srv/projects" ];
};
home.file."${config.home.homeDirectory}/.copilot/settings.json" = lib.mkMerge [
(lib.mkIf (mode == "cleanup-disabled") { enable = lib.mkForce false; })
(lib.mkIf redirected {
inherit target;
source = lib.mkForce (builtins.toFile "copilot-overridden-settings.json" "{}\n");
})
];
nmt.script =
assert !(config.home.activation ? githubCopilotCliSettings);
assert !(config.home.activation ? githubCopilotCliTrustedFolders);
assert (cleanup != null) == redirected;
assert !redirected || cleanup.after == [ "writeBoundary" ];
assert !redirected || cleanup.before == [ "linkGeneration" ];
assert
!redirected
||
cleanup.data == lib.hm.generators.mkImpureConfigCleanup {
file = config.home.file."${config.home.homeDirectory}/.copilot/settings.json";
};
''
assertPathNotExists home-files/.copilot/settings.json
assertPathNotExists home-files/.copilot/config.json
''
+ lib.optionalString redirected ''
assertFileContent "home-files/${target}" ${builtins.toFile "expected-overridden-settings.json" "{}\n"}
assertFileContains activate '${target}'
'';
}

View File

@@ -5,11 +5,11 @@
...
}:
let
configPath = "/home/hm-user/.copilot/config.json";
configPath = "/home/hm-user/copilot profile/config.json";
merge = pkgs.writeShellScript "test-copilot-trusted-folders" ''
set -euo pipefail
errorEcho() { echo "$*" >&2; }
${lib.replaceStrings [ configPath ] [ "$PWD/profile/config.json" ]
${lib.replaceStrings [ (lib.escapeShellArg configPath) ] [ ''"$PWD/profile/config.json"'' ]
config.home.activation.githubCopilotCliTrustedFolders.data
}
'';
@@ -17,6 +17,8 @@ in
{
programs.github-copilot-cli = {
enable = true;
package = null;
configDir = "/home/hm-user/copilot profile";
trustedFolders = [
"/home/user/projects"
"/home/user/other"
@@ -45,11 +47,17 @@ in
assertFileRegex activate '/bin/pyjson5 --as-json'
mkdir profile
umask 022
"${merge}"
test "$(stat -c '%a' profile/config.json)" = 600
${lib.getExe pkgs.jaq} -e '
. == { trustedFolders: ["/home/user/projects", "/home/user/other"] }
' profile/config.json > /dev/null
cat > profile/config.json <<'JSON'
// User settings belong in settings.json.
{
"loggedInUsers": [{ "login": "user" }],
"trustedFolders": ["/srv/interactive", "/home/user/projects"]
loggedInUsers: [{ login: "user" }],
trustedFolders: ["/srv/interactive", "/home/user/projects"],
}
JSON
"${merge}"