1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
open Ast
(*
--# Inspect Pipeline Logs
--#
--# Reads the latest (or specified) build log and returns a DataFrame showing the pipeline status.
--#
--# @name inspect_pipeline
--# @param which_log :: String (Optional) A regex pattern to match a specific build log filename.
--# @return :: DataFrame A DataFrame with columns = derivation, build_success, path, output.
--# @family pipeline
--# @export
*)
let register env =
let inspect_fn named_args _env =
let get_arg name pos default named_args =
match List.assoc_opt name (List.filter_map (fun (k, v) -> match k with Some s -> Some (s, v) | None -> None) named_args) with
| Some v -> v
| None ->
let positionals = List.filter_map (fun (k, v) -> match k with None -> Some v | Some _ -> None) named_args in
if List.length positionals >= pos then List.nth positionals (pos - 1)
else default
in
match get_arg "which_log" 1 (VNA NAGeneric) named_args with
| VNA _ ->
Builder.inspect_pipeline ()
| VString s ->
Builder.inspect_pipeline ~which_log:s ()
| _ ->
Error.type_error "inspect_pipeline: expected String or NA for argument 'which_log'"
in
let env = Env.add "inspect_pipeline" (make_builtin_named ~name:"inspect_pipeline" ~variadic:true 0 inspect_fn) env in
(*
--# List Pipeline Logs
--#
--# Lists all available build logs in the `_pipeline/` directory.
--#
--# @name list_logs
--# @return :: DataFrame A DataFrame of build log files with their modification times and sizes.
--# @family pipeline
--# @export
*)
let env = Env.add "list_logs" (make_builtin ~name:"list_logs" 0 (fun _args _env -> Builder.list_logs ())) env in
(*
--# Read Node Build Log
--#
--# Fetches the Nix build log for a specific node from the last build attempt.
--#
--# @name read_log
--# @param node_name :: String The name of the node to inspect.
--# @return :: String The build log content.
--# @family pipeline
--# @export
*)
let env = Env.add "read_log" (make_builtin ~name:"read_log" 1 (fun args _env ->
match args with
| [VString s] | [VSymbol s] -> Builder.read_node_log s
| _ -> Error.type_error "read_log: expected a String or Symbol node name"
)) env in
env