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.json | flk equivalent |
|---|---|
packages | the profile’s packages list |
packages with @version | packages + a pin in .flk/pins.nix |
env | the profile’s envVars |
shell.scripts | the profile’s commands (see flk command) |
shell.init_hook | appended 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 withflk 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
| Flag | Description |
|---|---|
-f, --file <PATH> | Manifest to read (defaults to ./devbox.json) |
-p, --profile <NAME> | Target profile (defaults to the project default) |
--dry-run | Print 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.