Files
Austin Horstman 8cfa9c9514 github-copilot-cli: reuse empty settings evaluation
The MCP-only case already evaluates an empty settings configuration.
Check its activation output there instead of repeating the evaluation,
while retaining the separate mutable-empty and file ownership cases.
2026-10-04 09:16:29 -05:00

53 lines
1.7 KiB
Nix

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 (mode != "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}'
'';
}