opencode: use lib.hm.strings.isPathLike

This commit is contained in:
Austin Horstman
2026-05-20 09:23:08 -05:00
parent 6d4fb02e34
commit c321a1c8a7

View File

@@ -63,9 +63,6 @@ let
else
cfg.package;
isStorePathString =
content: builtins.isString content && lib.hasPrefix "${builtins.storeDir}/" content;
isPathLikeContent = content: lib.isPath content || isStorePathString content;
in
{
meta.maintainers = with lib.maintainers; [ delafthi ];
@@ -435,7 +432,7 @@ in
message = "`programs.opencode.tools` must be a directory when set to a path";
}
{
assertion = !isPathLikeContent cfg.skills || lib.pathIsDirectory cfg.skills;
assertion = !lib.hm.strings.isPathLike cfg.skills || lib.pathIsDirectory cfg.skills;
message = "`programs.opencode.skills` must be a directory when set to a path";
}
{
@@ -522,7 +519,7 @@ in
recursive = true;
};
"opencode/skills" = mkIf (isPathLikeContent cfg.skills) {
"opencode/skills" = mkIf (lib.hm.strings.isPathLike cfg.skills) {
source = cfg.skills;
recursive = true;
};
@@ -558,14 +555,14 @@ in
)
// lib.mapAttrs' (
name: content:
if isPathLikeContent content && lib.pathIsDirectory content then
if lib.hm.strings.isPathLike content && lib.pathIsDirectory content then
lib.nameValuePair "opencode/skills/${name}" {
source = content;
recursive = true;
}
else
lib.nameValuePair "opencode/skills/${name}/SKILL.md" (
if isPathLikeContent content then { source = content; } else { text = content; }
if lib.hm.strings.isPathLike content then { source = content; } else { text = content; }
)
) (if builtins.isAttrs cfg.skills then cfg.skills else { })
// lib.optionalAttrs (builtins.isAttrs cfg.themes) (