| rxp_jl | R Documentation |
Create a Nix Expression Running a Julia Function
rxp_jl(
name,
expr,
additional_files = "",
user_functions = "",
nix_env = "default.nix",
encoder = NULL,
decoder = NULL,
env_var = NULL,
noop_build = FALSE
)
name |
Symbol, name of the derivation. |
expr |
Character, Julia code to generate the expression. Ideally it should be a call to a pure function. Multi-line expressions are not supported. |
additional_files |
Character vector, additional files to include during the build process. For example, if a function expects a certain file to be available, this is where you should include it. |
user_functions |
Character vector, user-defined functions to include. This should be a script (or scripts) containing user-defined functions to include during the build process for this derivation. It is recommended to use one script per function, and only include the required script(s) in the derivation. |
nix_env |
Character, path to the Nix environment file, default is "default.nix". |
encoder |
Character, defaults to NULL. The name of the Julia
function used to serialize the object. It must accept two arguments: the
object to serialize (first), and the target file path (second). If NULL,
the default behaviour uses the built‐in |
decoder |
Character or named vector/list, defaults to NULL. Can be:
|
env_var |
Character vector, defaults to NULL. A named vector of
environment variables to set before running the Julia script, e.g.,
|
noop_build |
Logical, defaults to FALSE. If TRUE, the derivation produces a no-op build (a stub output with no actual build steps). Any downstream derivations depending on a no-op build will themselves also become no-op builds. |
At a basic level,
rxp_jl(filtered_data, "filter(df, :col .> 10)") is equivalent to
filtered_data = filter(df, :col .> 10) in Julia. rxp_jl() generates the
required Nix boilerplate to output a so‐called "derivation" in Nix jargon.
A Nix derivation is a recipe that defines how to create an output (in this
case filtered_data) including its dependencies, build steps, and output
paths.
An object of class derivation which inherits from lists.
Other derivations:
rxp_jl_file(),
rxp_py(),
rxp_py_file(),
rxp_qmd(),
rxp_r(),
rxp_r_file(),
rxp_rmd()
## Not run:
# Basic usage, no custom serializer
rxp_jl(
name = filtered_df,
expr = "filter(df, :col .> 10)"
)
# Skip building this derivation
rxp_jl(
name = model_result,
expr = "train_model(data)",
noop_build = TRUE
)
# Custom serialization: assume `save_my_obj(obj, path)` is defined in functions.jl
rxp_jl(
name = model_output,
expr = "train_model(data)",
encoder = "save_my_obj",
user_functions = "functions.jl"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.