flk π
A modern CLI tool for managing Nix flake development environments with the simplicity of Devbox
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.
β¨ Features
- π― 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
π¦ Installation
Prerequisites
- 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)
From Source
From Cargo (Coming Soon)
With Nix
π Quick Start
1. Initialize Your Project
# Auto-detect project type and create flake.nix
# Or specify a template
Supported auto-detection:
Cargo.tomlβ Rust templatepackage.jsonβ Node.js templatepyproject.tomlorrequirements.txtβ Python templatego.modβ Go template
2. Add Packages
# Search for packages
# Get detailed package info
# Add packages to your environment
3. Add Custom Commands
# Add inline commands
# Source commands from a file
4. Manage Environment Variables
# Add environment variables
# List all environment variables
# Remove an environment variable
5. Enter Your Development Environment
Your custom commands and environment variables will be automatically available!
6. Generate completions
# Generates the completion file and prints it
# Install the generated completions to the detected shell
Follow the instructions after the command to make the completions available for you.
π Command Reference
Project Management
flk init [OPTIONS]
Initialize a new flake.nix in the current directory.
Options:
-t, --template <TYPE>- Project type:rust,python,node,go, orgeneric-f, --force- Overwrite existingflake.nix
Examples:
flk activate
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.
flk show
Display the contents and configuration of your flake.nix in a human-readable format.
flk list
List all packages in your development environment.
Package Management
flk search <QUERY> [OPTIONS]
Search for packages in nixpkgs.
Options:
-l, --limit <NUMBER>- Limit number of results (default: 10)
Examples:
flk deep-search <PACKAGE> [OPTIONS]
Get detailed information about a specific package.
Options:
-v, --versions- Show version pinning information
Examples:
flk add <PACKAGE>
Add a package to your flake.nix.
Examples:
Note: Version pinning is planned for a future release (see issue #5).
flk remove <PACKAGE>
Remove a package from your flake.nix.
Examples:
Custom Commands
flk add-command <NAME> <COMMAND> [OPTIONS]
Add a custom shell command to your development environment.
Options:
-f, --file <PATH>- Source commands from a file
Examples:
# Inline command
# Multi-line command
# Source from file
Command naming rules:
- Must contain only letters, numbers, hyphens, and underscores
- Cannot start with a hyphen
- Examples:
test,dev-server,build_prod
flk remove-command <NAME>
Remove a custom command from your dev shell.
Examples:
Environment Variables
flk env add <NAME> <VALUE>
Add an environment variable to your dev shell.
Examples:
Variable naming rules:
- Must start with a letter or underscore
- Can only contain letters, numbers, and underscores
- Examples:
MY_VAR,_private,API_KEY_2
flk env remove <NAME>
Remove an environment variable from your dev shell.
Examples:
flk env list
List all environment variables in your dev shell.
Lock File Management
flk lock show
Display detailed information about your flake.lock file.
flk lock history
Show backup history of your lock file.
flk lock restore <BACKUP>
Restore a previous version of your lock file.
Examples:
Updates
flk update [OPTIONS]
Update all flake inputs to their latest versions.
Options:
--show- Preview updates without applying them
Examples:
Note: A backup of your flake.lock is automatically created before updating.
Exports
flk export --format <FORMAT> [OPTIONS]
Export the current flake configuration to different formats. Options:
--format <FORMAT>- Export format:docker,podman,json
Examples:
π‘ Usage Examples
Python Data Science Environment
Rust Web Development
Node.js Full-Stack Project
Go Microservice
π οΈ Development
Prerequisites
- Rust 1.83+
- Nix with flakes enabled
Building
Running Tests
# Run all tests
# Run unit tests only
# Run integration tests only
# Run with output
# Run a specific test
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.
Installing Locally
ποΈ Project Structure
flk/
βββ src/
β βββ main.rs # CLI entry point
β βββ commands/ # Command implementations
β β βββ activate.rs # Activate dev shell
β β βββ add.rs # Add packages
β β βββ add_command.rs # Add custom commands
β β βββ completions.rs # Shell completions
β β βββ env.rs # Environment variable management
β β βββ export.rs # Export flake config
β β βββ init.rs # Initialize flake
β β βββ list.rs # List packages
β β βββ lock.rs # Lock file management
β β βββ mod.rs
β β βββ remove.rs # Remove packages
β β βββ remove_command.rs # Remove custom commands
β β βββ search.rs # Search packages
β β βββ show.rs # Display flake config
β β βββ update.rs # Update flake inputs
β βββ flake/ # Flake parsing and generation
β β βββ generator.rs # Generate flake.nix
β β βββ interface.rs # Data structures
β β βββ mod.rs
β β βββ parser.rs # Parse flake.nix
β βββ nix/ # Nix command wrappers
β β βββ mod.rs
β βββ utils/ # Utility functions
β βββ backup.rs # Backup management
β βββ mod.rs
β βββ visual.rs # Visual enhancements
βββ templates/ # Flake templates
β βββ flake.nix # Root flake template
β βββ default.nix # Helper module
β βββ overlays.nix # Overlays configuration
β βββ pins.nix # Pin configuration
β βββ profiles/ # Profile templates
β βββ base.nix # Generic template
β βββ default.nix # Importer module
β βββ rust.nix # Rust template
β βββ python.nix # Python template
β βββ node.nix # Node.js template
β βββ go.nix # Go template
βββ tests/ # Test files
βββ integration_tests.rs # CLI integration tests
βββ unit_tests.rs # Module unit tests
πΊοΈ Roadmap
π€ Contributing
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.
How to Contribute
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
π Bug Reports
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.)
π Related Projects
- 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
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- The Nix community for creating an amazing ecosystem
- Jetify for the Devbox inspiration and showing what's possible
- All contributors and users of flk
π Support
- π§ 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 (v0.3.0). While all core features are implemented and working, some advanced features like version pinning are still in progress. See the roadmap for details.