Skip to content

How CLI Nodes Work

CLI nodes execute shell commands inside Nix-managed environments. You declare the tools you need, Radhflow enters a nix-shell with those packages, runs your command, and captures the output. Nothing is installed globally. The same pipeline runs identically on any machine with Nix.

  1. Declare packages. List Nix packages in nix.packages.
  2. Define the command. Write the shell command in params.command. Use {{ }} templates for input fields.
  3. Radhflow enters nix-shell. At execution time, a transient shell is created with only the declared packages available.
  4. Command runs. stdin, stdout, and exit code are captured.
  5. Output is collected. The result is returned as a Record or Table.

No system-wide installs. No version conflicts. No “works on my machine.”

convert-video:
type: deterministic
op: cli.run
params:
command: >
ffmpeg -i {{ input_path }}
-vf scale=1280:720
-c:v libx264 -preset fast
-c:a aac
{{ output_path }}
nix:
packages:
- ffmpeg
inputs:
request:
type: Record
from: ref(prepare.config)
schema:
input_path: { type: string }
output_path: { type: string }
outputs:
result:
type: Record
schema:
exit_code: { type: number }
stdout: { type: string }
stderr: { type: string }

Radhflow resolves ffmpeg from nixpkgs, enters a shell with it available, runs the command, and returns the result. The host system does not need ffmpeg installed.

When the input is a Table, the command runs once per row. Template expressions resolve against each row independently.

resize-images:
type: deterministic
op: cli.run
params:
command: >
convert {{ source }} -resize 800x600 {{ dest }}
nix:
packages:
- imagemagick
inputs:
files:
type: Table
from: ref(list-images.files)
outputs:
results: { type: Table }

The nix block declares the shell environment. Packages are pulled from nixpkgs. Pin a revision for full reproducibility.

nix:
packages: [pandoc, texlive.combined.scheme-small]
nixpkgs: github:NixOS/nixpkgs/nixos-24.05 # optional pin

By default, CLI nodes capture stdout, stderr, and exit code as a Record.

FieldTypeDescription
exit_codenumberProcess exit code. 0 means success.
stdoutstringStandard output content.
stderrstringStandard error content.

For commands that produce files, reference the output path in downstream nodes.

params:
command: >
pandoc {{ input }} -o artifacts/{{ name }}.pdf
artifacts:
- path: "artifacts/{{ name }}.pdf"
type: file
FieldRequiredDefaultDescription
commandYesShell command to execute. Supports {{ }} templates.
nix.packagesYesList of Nix packages available in the shell.
nix.nixpkgsNoLatest stablePinned nixpkgs revision for reproducibility.
artifactsNoFiles produced by the command.