mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-12 03:51:07 +01:00
opencode: make the rules option also accept a path
This commit is contained in:
parent
c199de6cd8
commit
fddb33a1a5
4 changed files with 29 additions and 9 deletions
|
|
@ -45,8 +45,15 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
rules = lib.mkOption {
|
rules = lib.mkOption {
|
||||||
type = lib.types.lines;
|
type = lib.types.either lib.types.lines lib.types.path;
|
||||||
default = "";
|
default = "";
|
||||||
|
description = ''
|
||||||
|
You can provide global custom instructions to opencode.
|
||||||
|
The value is either:
|
||||||
|
- Inline content as a string
|
||||||
|
- A path to a file containing the content
|
||||||
|
This value is written to {file}`$XDG_CONFIG_HOME/opencode/AGENTS.md`.
|
||||||
|
'';
|
||||||
example = lib.literalExpression ''
|
example = lib.literalExpression ''
|
||||||
'''
|
'''
|
||||||
# TypeScript Project Rules
|
# TypeScript Project Rules
|
||||||
|
|
@ -73,10 +80,6 @@ in
|
||||||
Read the following file immediately as it's relevant to all workflows: @rules/general-guidelines.md.
|
Read the following file immediately as it's relevant to all workflows: @rules/general-guidelines.md.
|
||||||
'''
|
'''
|
||||||
'';
|
'';
|
||||||
description = ''
|
|
||||||
You can provide global custom instructions to opencode; this value is
|
|
||||||
written to {file}`$XDG_CONFIG_HOME/opencode/AGENTS.md`.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
commands = lib.mkOption {
|
commands = lib.mkOption {
|
||||||
|
|
@ -162,9 +165,14 @@ in
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
"opencode/AGENTS.md" = mkIf (cfg.rules != "") {
|
"opencode/AGENTS.md" = (
|
||||||
|
if lib.isPath cfg.rules then
|
||||||
|
{ source = cfg.rules; }
|
||||||
|
else
|
||||||
|
(mkIf (cfg.rules != "") {
|
||||||
text = cfg.rules;
|
text = cfg.rules;
|
||||||
};
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// lib.mapAttrs' (
|
// lib.mapAttrs' (
|
||||||
name: content:
|
name: content:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
opencode-settings = ./settings.nix;
|
opencode-settings = ./settings.nix;
|
||||||
opencode-empty-settings = ./empty-settings.nix;
|
opencode-empty-settings = ./empty-settings.nix;
|
||||||
opencode-rules = ./rules.nix;
|
opencode-rules-inline = ./rules-inline.nix;
|
||||||
|
opencode-rules-path = ./rules-path.nix;
|
||||||
opencode-empty-rules = ./empty-rules.nix;
|
opencode-empty-rules = ./empty-rules.nix;
|
||||||
opencode-agents-inline = ./agents-inline.nix;
|
opencode-agents-inline = ./agents-inline.nix;
|
||||||
opencode-commands-inline = ./commands-inline.nix;
|
opencode-commands-inline = ./commands-inline.nix;
|
||||||
|
|
|
||||||
11
tests/modules/programs/opencode/rules-path.nix
Normal file
11
tests/modules/programs/opencode/rules-path.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
programs.opencode = {
|
||||||
|
enable = true;
|
||||||
|
rules = ./AGENTS.md;
|
||||||
|
};
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/opencode/AGENTS.md
|
||||||
|
assertFileContent home-files/.config/opencode/AGENTS.md \
|
||||||
|
${./AGENTS.md}
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue