github-copilot-cli: avoid IFD for path inputs

Validate derived agent and skill directories during builds and normalize derived skill files without evaluation-time filesystem reads.
This commit is contained in:
Austin Horstman
2026-08-05 15:07:45 -05:00
parent 2e5052fc72
commit dca466f132
5 changed files with 70 additions and 49 deletions

View File

@@ -6,6 +6,6 @@
github-copilot-cli-mcp-integration = ./mcp-integration.nix;
github-copilot-cli-path-not-directory = ./path-not-directory.nix;
github-copilot-cli-store-path-dir = ./store-path-dir.nix;
github-copilot-cli-store-path-not-directory = ./store-path-not-directory.nix;
github-copilot-cli-store-path-skills = ./store-path-skills.nix;
github-copilot-cli-xdg-config-dir = ./xdg-config-dir.nix;
}

View File

@@ -1,21 +1,13 @@
{ pkgs, ... }:
{ realPkgs, ... }:
let
src = pkgs.writeTextDir "agents/code-reviewer.agent.md" ''
---
description: Review changes from a store-path directory fixture.
tools: ["*"]
---
Focus on correctness and missing coverage.
src = realPkgs.runCommand "github-copilot-cli-ifd-agents-directory" { } ''
mkdir -p "$out/agents"
echo '# Code Reviewer' > "$out/agents/code-reviewer.agent.md"
'';
skillsSrc = pkgs.writeTextDir "skills/external-skill/SKILL.md" ''
---
name: external-skill
description: Store-path directory fixture.
---
Exercise top-level store-path directory handling.
skillsSrc = realPkgs.runCommand "github-copilot-cli-ifd-skills-directory" { } ''
mkdir -p "$out/skills/external-skill"
echo '# External Skill' > "$out/skills/external-skill/SKILL.md"
'';
in
{

View File

@@ -1,28 +0,0 @@
{ pkgs, ... }:
let
agentFile = pkgs.writeText "code-reviewer.agent.md" ''
---
description: Invalid top-level agent file fixture.
tools: ["*"]
---
'';
skillFile = pkgs.writeText "SKILL.md" ''
---
name: invalid-top-level-skill
description: Invalid top-level skill file fixture.
---
'';
in
{
programs.github-copilot-cli = {
enable = true;
agents = "${agentFile}";
skills = "${skillFile}";
};
test.asserts.assertions.expected = [
"`programs.github-copilot-cli.agents` must be a directory when set to a path"
"`programs.github-copilot-cli.skills` must be a directory when set to a path"
];
}

View File

@@ -0,0 +1,24 @@
{ realPkgs, ... }:
let
src = realPkgs.runCommand "github-copilot-cli-ifd-skill-source" { } ''
mkdir -p "$out/skills/external-skill"
echo '# External Skill' > "$out/skills/external-skill/SKILL.md"
'';
in
{
programs.github-copilot-cli = {
enable = true;
skills = {
directory = "${src}/skills/external-skill";
file = "${src}/skills/external-skill/SKILL.md";
};
};
nmt.script = ''
assertFileContent home-files/.copilot/skills/directory/SKILL.md \
"${src}/skills/external-skill/SKILL.md"
assertFileContent home-files/.copilot/skills/file/SKILL.md \
"${src}/skills/external-skill/SKILL.md"
'';
}