flk global
A machine-wide environment for tools you want everywhere, like ripgrep, fd or bat, similar to Devbox’s global mode. It replaces nix profile install or a system package manager for those tools.
The global environment is an ordinary flk project stored outside any repository. Each flk global subcommand works like the project command of the same name, but on that directory.
Location
The global directory is resolved in this order:
FLK_GLOBAL_DIR$XDG_CONFIG_HOME/flk/global~/.config/flk/global
It is created with the generic template on first use. path, ref and shellenv never create it.
Subcommands
flk global add
flk global add ripgrep
flk global add fd --version 10.2.0 # pin a version
flk global add bat --profile cli-tools # target a specific global profile
flk global remove
flk global remove ripgrep
flk global list
flk global list
flk global list --profile cli-tools
flk global activate
Enters the global shell, with the same caching as flk activate. The shell opens in your current directory, not the global one.
flk global activate
flk global activate --profile cli-tools
Inside it, refresh and switch work on the global environment (activation exports FLK_ENV_DIR), even if the current directory is a project. So flk global add jq then refresh picks up jq, and switch cli-tools changes global profile.
From a project shell, refresh -g and switch -g <profile> move to the global environment; switch -l <profile> moves back. The new shell replaces the current one.
flk global update
Same as flk update, including the lock backup.
flk global update
flk global update --show
flk global path
Prints the global directory. It never creates it, unlike the other subcommands.
flk global path
# /home/you/.config/flk/global
nix develop "$(flk global path)#generic"
flk global ref
Prints the global flake reference (<dir>#<profile>) and nothing else. The hook uses it for refresh -g and switch -g. Fails if the global environment doesn’t exist yet.
flk global ref
# /home/you/.config/flk/global#generic
flk global ref --profile cli-tools
flk global profile
flk profile for the global environment.
flk global profile add cli-tools
flk global profile list
flk global profile set-default cli-tools
flk global profile remove cli-tools
flk global unfree
flk unfree for the global environment.
flk global unfree add slack # default global profile
flk global unfree add slack -p cli-tools # a specific global profile
flk global unfree add slack --all # every global profile
flk global unfree list
flk global unfree remove slack
flk global shellenv
Prints shell code that appends the global packages to PATH, like Devbox’s shellenv. Eval it in your rc file to have the tools in every shell, project shells included:
# .bashrc / .zshrc
eval "$(flk global shellenv zsh)" # or bash
# ~/.config/fish/config.fish
flk global shellenv fish | source
- Only the environment’s packages are exported. The stdenv toolchain that
nix developadds (gcc,binutils,make,patch,tar, …) is filtered out, so it can’t stand in for a missing systemccin every shell. - Paths are appended, so system tools and project packages win.
- Nothing is appended if
PATHalready has the entries, so nested shells and re-sourced rc files don’t grow it. - It reads the profile’s GC root through
nix print-dev-envand doesn’t evaluate the flake, so it’s fast and works offline. - If the environment isn’t built yet, or the packages can’t be told apart from the toolchain, it prints only a comment. Run
flk global activateonce to build it. - It reflects the environment when it ran. After
flk global addorremove, open a new shell.
Notes
- flk never edits your rc files. Use
shellenv, runflk global activatewhen needed, or add your own alias. - A project shell’s
FLK_FLAKE_REFis ignored when choosing the global profile. - Everything (
flake.nix,.flk/, backups, caches) lives in the global directory; nothing is written to the current directory.