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 activate

Enter the Nix development shell for your project.

flk activate
flk activate --profile backend

Options

  • -p, --profile <PROFILE>: Activate a specific profile instead of the default

Behavior

  • Runs nix develop .#<profile> --impure to enter the dev shell
  • Reuses a cached develop profile from .flk/.nix-profile-<profile> when your flake config is unchanged
  • Refreshes that cached profile when flake.nix, flake.lock, or the relevant .flk profile files change
  • Uses standard profile resolution when --profile is not specified
  • Custom commands and environment variables from the profile are available inside the shell
  • Exports FLK_FLAKE_REF/FLK_PROFILE into the shell so the hook’s refresh/switch commands know the active profile (flk global activate additionally exports FLK_ENV_DIR)
  • Exports FLK_ORIG_PATH (the pre-activation PATH): refresh/switch reset to it so removed packages don’t linger in the inherited PATH

Shell selection

The shell exec’d inside the dev environment is resolved in this order:

  1. FLK_SHELL environment variable (explicit override)
  2. $SHELL, unless it points into /nix/store — nix develop/nix-shell export SHELL as nixpkgs’ non-interactive bash, which breaks interactive terminals (missing completion, broken prompt)
  3. The login shell from /etc/passwd
  4. /bin/sh

The refresh/switch hook functions apply the same logic.

Notes

  • For automatic environment switching when navigating between projects, add the shell hook:
    eval "$(flk hook bash)"   # or zsh/fish
    
  • For automatic activation when entering a directory, use direnv integration

See Also

  • flk hook — for refresh and switch commands
  • flk direnv — for automatic directory-based activation