Skip to content
vic

AEduardo-dev/flk

Flakes development environments management tool

AEduardo-dev/flk.json
{
"createdAt": "2025-10-24T09:55:00Z",
"defaultBranch": "main",
"description": "Flakes development environments management tool",
"fullName": "AEduardo-dev/flk",
"homepage": null,
"language": "Rust",
"name": "flk",
"pushedAt": "2026-01-19T15:39:58Z",
"stargazersCount": 6,
"topics": [],
"updatedAt": "2026-01-18T16:15:47Z",
"url": "https://github.com/AEduardo-dev/flk"
}

A modern CLI tool for managing Nix flake development environments with the simplicity of Devbox

Crates.io License: MIT Rust

flk makes managing Nix flakes feel like using a package manager. No more manually editing flake.nix files—just use simple commands to add packages, create custom shell commands, and manage your development environment with ease.

  • 🎯 Smart Initialization - Auto-detects your project type (Rust, Python, Node.js, Go) and creates the right template
  • 🔍 Package Search - Search nixpkgs directly from your terminal
  • 📦 Easy Package Management - Add and remove packages with simple commands
  • Custom Shell Commands - Define reusable commands for your development workflow
  • 🌍 Environment Variables - Manage environment variables through the CLI
  • 🔒 Lock File Management - View, backup, and restore your flake.lock with ease
  • 🎨 Language Templates - Pre-configured templates for popular languages and frameworks

Upgrading to v0.5.0 (switch/refresh changes)

Section titled “Upgrading to v0.5.0 (switch/refresh changes)”

WARNING (pre v0.5.0 users): If you are using flk < v0.5.0 and you run flk update / nix flake update, your devshell switch / refresh behavior may break because the nix-profile-lib input may update to a newer version with different activation semantics.

If you intend to stay on flk < v0.5.0, use one of these options:

  1. Do not update flake inputs. Avoid running flk update or nix flake update. If you already did, restore a previous lockfile backup with:

    Terminal window
    flk lock restore <BACKUP>
  2. Pin nix-profile-lib to v0.1.0. In your flake.nix:

    inputs = {
    nix-profile-lib.url = "github:AEduardo-dev/nix-profile-lib?ref=v0.1.0";
    };

    Then update the lock entry:

    Terminal window
    nix flake lock --update-input nix-profile-lib

    (or nix flake update --update-input nix-profile-lib)

Once you upgrade to flk v0.5.0+, this restriction is lifted.

  • Nix with flakes enabled
    • We recommend the Lix package manager for easy Nix installation: Lix since it comes with flakes enabled by default.
    • Or using the Determinate System installer: Determinate, as it provides a user-friendly way to install (and uninstall) Nix.
  • Rust 1.83+ (if building from source)
Terminal window
git clone https://github.com/AEduardo-dev/flk.git
cd flk
cargo build --release
sudo cp target/release/flk /usr/local/bin/
Terminal window
cargo install flk
Terminal window
# Auto-detect project type and create flake.nix
flk init
# Or specify a template
flk init --template rust
flk init --template python
flk init --template node
flk init --template go

Supported auto-detection:

  • Cargo.toml → Rust template
  • package.json → Node.js template
  • pyproject.toml or requirements.txt → Python template
  • go.mod → Go template
Terminal window
# Search for packages
flk search ripgrep
# Get detailed package info and versions
flk deep-search ripgrep
# Add packages to your environment
flk add ripgrep
flk add git
flk add neovim
# Or add pinned versions
flk add ripgrep --version '15.1.0'
flk add git --version '2.42.0'
Terminal window
# Add inline commands
flk command add test "cargo test --all"
flk command add dev "npm run dev"
Terminal window
# Add environment variables
flk env add DATABASE_URL "postgresql://localhost/mydb"
flk env add API_KEY "your-api-key"
# List all environment variables
flk env list
# Remove an environment variable
flk env remove API_KEY
Terminal window
flk activate

Your custom commands and environment variables will be automatically available!

Terminal window
# Generates the completion file and prints it
flk completions
# Install the generated completions to the detected shell
flk completions --install

Follow the instructions after the command to make the completions available for you.

If you use direnv, you can set it up to automatically load your flk environment when you enter the project directory.

Terminal window
# Generates a .envrc file for direnv with use flake command
flk direnv init
#or
# Add the direnv hook to an existing project
flk direnv attach

if you ever want to detach the direnv hook, you can run:

Terminal window
flk direnv detach
Terminal window
switch <profile_name> # Switch to a different profile_name
refresh # Refresh the current profile (useful after modifying the environment)

Initialize a new flake.nix in the current directory.

Options:

  • -t, --template <TYPE> - Project type: rust, python, node, go, or generic
  • -f, --force - Overwrite existing flake.nix

Examples:

Terminal window
flk init # Auto-detect project type
flk init --template rust # Use Rust template
flk init --force # Overwrite existing flake.nix

Activate the nix shell for the current shell session. This command sets up the necessary environment for your project based on the flake.nix configuration. It also installs some convenience features, such as a shell hook to refresh.

Future implementations will include the option to activate specific profiles.

Display the contents and configuration of your flake.nix in a human-readable format.

Terminal window
flk show

List all packages in your development environment.

Terminal window
flk list

Search for packages in nixpkgs.

Options:

  • -l, --limit <NUMBER> - Limit number of results (default: 10)

Examples:

Terminal window
flk search ripgrep
flk search python --limit 20

Get detailed information about a specific package.

Examples:

Terminal window
flk deep-search ripgrep
flk deep-search python311
```
#### `flk add <PACKAGE>`
Add a package to your `flake.nix`.
**Examples:**
```bash
flk add ripgrep
flk add git
flk add nodejs

Or add a specific version:

Terminal window
flk add ripgrep --version '15.1.0'
flk add git --version '2.42.0'

Remove a package from your flake.nix.

Examples:

Terminal window
flk remove ripgrep

flk command add <NAME> <COMMAND> [OPTIONS]

Section titled “flk command add <NAME> <COMMAND> [OPTIONS]”

Add a custom shell command to your development environment.

Examples:

Terminal window
# Inline command
flk command add test "cargo test --all"
flk command add dev "npm run dev -- --watch"
# Multi-line command
flk command add deploy "cargo build --release && scp target/release/app server:/opt/"

Command naming rules:

  • Must contain only letters, numbers, hyphens, and underscores
  • Cannot start with a hyphen
  • Examples: test, dev-server, build_prod

Remove a custom command from your dev shell.

Examples:

Terminal window
flk command remove test

Add an environment variable to your dev shell.

Examples:

Terminal window
flk env add DATABASE_URL "postgresql://localhost:5432/mydb"
flk env add NODE_ENV "development"
flk env add API_KEY "sk-..."

Variable naming rules:

  • Must start with a letter or underscore
  • Can only contain letters, numbers, and underscores
  • Examples: MY_VAR, _private, API_KEY_2

Remove an environment variable from your dev shell.

Examples:

Terminal window
flk env remove DATABASE_URL

List all environment variables in your dev shell.

Terminal window
flk env list

Display detailed information about your flake.lock file.

Terminal window
flk lock show

Show backup history of your lock file.

Terminal window
flk lock history

Restore a previous version of your lock file.

Examples:

Terminal window
flk lock restore latest # Restore most recent backup
flk lock restore 2025-01-27_14-30-00 # Restore specific backup

Update all flake inputs to their latest versions.

Options:

  • --show - Preview updates without applying them

Examples:

Terminal window
flk update # Update all inputs
flk update --show # Preview available updates

Note: A backup of your flake.lock is automatically created before updating.

Export the current flake configuration to different formats. Options:

  • --format <FORMAT> - Export format: docker, podman, json

Examples:

Terminal window
flk export --format docker # Export as Dockerfile
flk export --format podman # Export as Podmanfile
flk export --format json # Export as JSON

Generate a .envrc file for direnv with use flake command.

Terminal window
flk direnv init

Add the direnv hook to an existing project.

Terminal window
flk direnv attach

Remove the direnv hook from the project.

Terminal window
flk direnv detach
Terminal window
flk init --template python
flk add python312Packages.numpy
flk add python312Packages.pandas
flk add python312Packages.matplotlib
flk add jupyter
flk command add notebook "jupyter notebook --port=8888"
flk env add JUPYTER_CONFIG_DIR "./.jupyter"
flk activate
notebook # Your custom command is ready!
Terminal window
flk init --template rust
flk add postgresql
flk add redis
flk command add dev "cargo watch -x run"
flk command add migrate "sqlx migrate run"
flk env add DATABASE_URL "postgresql://localhost/myapp"
flk activate
dev # Start development server with auto-reload
migrate # Run database migrations
Terminal window
flk init --template node
flk add postgresql
flk add docker-compose
flk command add dev "npm run dev"
flk command add db "docker-compose up -d postgres"
flk env add NODE_ENV "development"
flk activate
db # Start database
dev # Start development server
Terminal window
flk init --template go
flk add protobuf
flk add grpcurl
flk command add build "go build -o bin/service ./cmd/service"
flk command add proto "protoc --go_out=. --go-grpc_out=. api/*.proto"
flk env add GO_ENV "development"
flk activate
proto # Generate protobuf code
build # Build the service
  • Rust 1.83+
  • Nix with flakes enabled
Terminal window
git clone https://github.com/AEduardo-dev/flk.git
cd flk
cargo build
Terminal window
# Run all tests
cargo test
# Run unit tests only
cargo test --test unit_tests
# Run integration tests only
cargo test --test integration_tests
# Run with output
cargo test -- --nocapture
# Run a specific test
cargo test test_name

The test suite includes comprehensive unit tests for the parser, generator, and interface modules, as well as integration tests covering the complete CLI workflow including the dendritic . flk/profiles/ architecture.

Terminal window
cargo install --path .
 .
├──  Cargo.lock
├──  Cargo.toml
├──  CHANGELOG.md
├──  cliff.toml
├──  CODE_OF_CONDUCT.md
├──  CONTRIBUTING.md
├──  dist-workspace.toml
├──  flake.lock
├──  flake.nix
├──  LICENSE
├── 󰂺 README.md
├──  release-plz.toml
├── 󰣞 src
│ ├──  commands
│ │ ├──  activate.rs
│ │ ├──  add.rs
│ │ ├──  command.rs
│ │ ├──  completions.rs
│ │ ├──  direnv.rs
│ │ ├──  env.rs
│ │ ├──  export.rs
│ │ ├──  init.rs
│ │ ├──  list.rs
│ │ ├──  lock.rs
│ │ ├──  mod.rs
│ │ ├──  remove.rs
│ │ ├──  search.rs
│ │ ├──  show.rs
│ │ └──  update.rs
│ ├──  flake
│ │ ├──  generator.rs
│ │ ├──  interfaces
│ │ │ ├──  mod.rs
│ │ │ ├──  overlays.rs
│ │ │ ├──  profiles.rs
│ │ │ ├──  shellhooks.rs
│ │ │ └──  utils.rs
│ │ ├──  mod.rs
│ │ ├──  nix_render.rs
│ │ └──  parsers
│ │ ├──  commands.rs
│ │ ├──  env.rs
│ │ ├──  flake.rs
│ │ ├──  mod.rs
│ │ ├──  overlays.rs
│ │ ├──  packages.rs
│ │ └──  utils.rs
│ ├──  lib.rs
│ ├──  main.rs
│ ├──  nix
│ │ └──  mod.rs
│ └──  utils
│ ├──  backup.rs
│ ├──  mod.rs
│ └──  visual.rs
├──  templates
│ ├──  default.nix
│ ├──  flake.nix
│ ├──  overlays.nix
│ ├──  pins.nix
│ └──  profiles
│ ├──  base.nix
│ ├──  default.nix
│ ├──  go.nix
│ ├──  node.nix
│ ├──  python.nix
│ └──  rust.nix
├──  tests
│ ├──  flake_tests.nix
│ ├──  integration_tests.rs
│ ├──  pins_tests.nix
│ ├──  profile_tests.nix
│ └──  unit_tests.rs
└──  wix
└──  main.wxs

Roadmap

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

If you find a bug, please open an issue with:

  • A clear description of the problem
  • Steps to reproduce
  • Expected vs actual behavior
  • Your environment (OS, Nix version, etc.)
  • Devbox - Instant, portable dev environments (inspiration for flk)
  • devenv - Fast, declarative developer environments
  • Flox - Developer environments you can take with you
  • direnv - Shell extension for loading environments

This project is licensed under the MIT License - see the [LICENSE]!(LICENSE) file for details.

  • The Nix community for creating an amazing ecosystem
  • Jetify for the Devbox inspiration and showing what’s possible
  • All contributors and users of flk
  • Special mention to @vic for creating nix-versions
  • 📧 Open an issue for bug reports or feature requests
  • 💬 Start a discussion for questions or ideas
  • ⭐ Star the repository if you find it useful!

Made with ❤️ by AEduardo-dev

Note: This project is under active development. While all core features are implemented and working, some advanced features are still in progress and will be subject to change.