Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

flk import

Imports another tool’s environment file into an flk profile. The only source so far is Devbox’s devbox.json. If there is no flake.nix yet, flk import runs flk init first.

flk import devbox

flk import devbox                      # import ./devbox.json into the default profile
flk import devbox --dry-run            # show the translation, write nothing
flk import devbox --file ../devbox.json
flk import devbox --profile backend    # import into a specific profile

What gets translated

devbox.jsonflk equivalent
packagesthe profile’s packages list
packages with @versionpackages + a pin in .flk/pins.nix
envthe profile’s envVars
shell.scriptsthe profile’s commands (see flk command)
shell.init_hookappended to the profile’s shellHook

packages may be a list or an object:

{ "packages": ["ripgrep", "go@1.22"] }
{ "packages": { "go": { "version": "1.22" } } }

shell.init_hook and each script may be a string or a list of strings. A version of latest is treated as unpinned.

Version pinning

name@version is handled like flk add --version: the pin is resolved against nixpkgs, recorded in .flk/pins.nix, and the profile declares pkgs."name@version". Each pinned package costs several network round-trips, so --dry-run first is a good idea for large manifests.

What does not get translated

These are listed under “Not imported” at the end of the run:

  • include: Devbox plugins have no flk equivalent; translate them by hand.
  • env_from: dotenv sourcing. Add the variables with flk env add.
  • per-package platforms / excluded_platforms: the package is imported for all systems.
  • keys flk doesn’t recognise, for example from a newer Devbox release.

Devbox template variables such as {{ .DevboxDir }} in env values are copied as-is with a warning. They don’t expand, so edit them afterwards.

Conflicts and failures

  • A package that is already declared is replaced, as with flk add.
  • An environment variable or command that already exists is skipped with a warning.
  • An entry that fails (say, a package that isn’t in nixpkgs) doesn’t stop the run. The rest is imported, failures are listed at the end, and the exit code is non-zero.

Options

FlagDescription
-f, --file <PATH>Manifest to read (defaults to ./devbox.json)
-p, --profile <NAME>Target profile (defaults to the project default)
--dry-runPrint the translation and exit without writing

Example

$ cat devbox.json
{
  "packages": ["ripgrep", "go@1.22"],
  "env": { "GOFLAGS": "-mod=vendor" },
  "shell": {
    "init_hook": ["echo 'entering the shell'"],
    "scripts": { "build": ["go build ./..."] }
  }
}

$ flk import devbox
$ flk show
$ flk activate

See also flk add and flk command.