From ea99f26b25a8f12ac7b5444d66ecfdf0ee96e546 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Thu, 20 Nov 2025 22:20:19 +0100 Subject: [PATCH] libexpr/builtins: Document fetchMercurial Change-Id: Ic849bd6dd10374b717d3fc257da25208f2c45525 --- lix/libexpr/builtins/fetchMercurial.md | 48 ++++++++++++++++++++++++++ lix/libexpr/extra-primops.hh | 1 + lix/libexpr/meson.build | 1 + lix/libexpr/primops/fetchMercurial.cc | 9 +---- 4 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 lix/libexpr/builtins/fetchMercurial.md diff --git a/lix/libexpr/builtins/fetchMercurial.md b/lix/libexpr/builtins/fetchMercurial.md new file mode 100644 index 000000000..c31b45e3e --- /dev/null +++ b/lix/libexpr/builtins/fetchMercurial.md @@ -0,0 +1,48 @@ +--- +name: fetchMercurial +args: [args] +renameInGlobalScope: false +--- + +Fetch a Mercurial repository. *args* can be a URL, in which case the default +branch of the repo at that URL is fetched. Otherwise, it can be an +attribute with the following attributes (all except `url` optional): + +- `url` + + The URL of the repo. + +- `name` (default: `"source"`) + + The name of the directory the repo should be exported to in the store. + +- `rev` + + The revision to fetch. + This is typically a commit hash. + + > **Note** + > + > Currently, `rev` can either contain a revision or a branch/tag name. + +The return value is an attrset containing the following keys: + +- `outPath` (`string`) + + Resulting store path of the fetch process. + +- `branch` (`string`) + + The branch of the fetch repository. + +- `rev` (`string`) + + The revision that was fetched. + +- `revCount` (`int`) + + The number of revsets for this branch. + +- `shortRev` (`string`) + + The first *12* characters of `rev`. diff --git a/lix/libexpr/extra-primops.hh b/lix/libexpr/extra-primops.hh index 9fd753ad4..8a3390150 100644 --- a/lix/libexpr/extra-primops.hh +++ b/lix/libexpr/extra-primops.hh @@ -11,6 +11,7 @@ struct Value; void prim_addDrvOutputDependencies(EvalState & state, Value * * args, Value & v); void prim_fetchTree(EvalState & state, Value * * args, Value & v); void prim_fetchGit(EvalState & state, Value * * args, Value & v); +void prim_fetchMercurial(EvalState & state, Value ** args, Value & v); void prim_fetchTarball(EvalState & state, Value * * args, Value & v); void prim_fetchurl(EvalState & state, Value * * args, Value & v); void prim_fromTOML(EvalState & state, Value * * args, Value & v); diff --git a/lix/libexpr/meson.build b/lix/libexpr/meson.build index 4aa2ecddc..1be586a91 100644 --- a/lix/libexpr/meson.build +++ b/lix/libexpr/meson.build @@ -77,6 +77,7 @@ builtin_definitions = files( 'builtins/elem.md', 'builtins/elemAt.md', 'builtins/fetchGit.md', + 'builtins/fetchMercurial.md', 'builtins/fetchTarball.md', 'builtins/fetchTree.md', 'builtins/fetchurl.md', diff --git a/lix/libexpr/primops/fetchMercurial.cc b/lix/libexpr/primops/fetchMercurial.cc index 6a7d75702..145adb74f 100644 --- a/lix/libexpr/primops/fetchMercurial.cc +++ b/lix/libexpr/primops/fetchMercurial.cc @@ -5,7 +5,7 @@ namespace nix { -static void prim_fetchMercurial(EvalState & state, Value * * args, Value & v) +void prim_fetchMercurial(EvalState & state, Value ** args, Value & v) { std::string url; std::optional rev; @@ -102,11 +102,4 @@ static void prim_fetchMercurial(EvalState & state, Value * * args, Value & v) state.ctx.paths.allowPath(tree.storePath); } - -static RegisterPrimOp r_fetchMercurial({ - .name = "fetchMercurial", - .arity = 1, - .fun = prim_fetchMercurial -}); - }