34 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

2026-03-13 00:21:04 +00:00
#!/usr/bin/env nu
# reflection/modules/env.nu — environment bootstrap for ontoref.
# Sets: ONTOREF_ROOT, NICKEL_IMPORT_PATH, ONTOREF_ACTOR
export-env {
let root = (
$env.CURRENT_FILE
| path expand # canonicalize — resolves ".." from relative `use ../modules/env.nu` paths
2026-03-13 00:21:04 +00:00
| path dirname # reflection/modules
| path dirname # reflection
| path dirname # <root>
)
$env.ONTOREF_ROOT = $root
if ($env.NICKEL_IMPORT_PATH? | is-empty) {
let config_file = $"($root)/.ontoref/config.ncl"
# Guard: config must exist and nickel must be in PATH before reading
let paths = if ($config_file | path exists) and (which nickel | is-not-empty) {
do { ^nickel export $config_file } | complete
| if $in.exit_code == 0 {
$in.stdout | from json | get nickel_import_paths
| each { |p| $"($root)/($p)" }
} else { [$root] }
} else { [$root] }
$env.NICKEL_IMPORT_PATH = ($paths | str join ":")
}
if ($env.ONTOREF_ACTOR? | is-empty) {
$env.ONTOREF_ACTOR = "developer"
}
}