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.
β¨ 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
- Rust 1.70+ (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!
π 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 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.
π‘ Usage Examples
Python Data Science Environment
Rust Web Development
Node.js Full-Stack Project
Go Microservice
π οΈ Development
Prerequisites
- Rust 1.70+
- Nix with flakes enabled
Building
Running Tests
# Run all tests
# Run integration tests
# Run with output
Installing Locally
ποΈ Project Structure
flk/
βββ src/
β βββ main.rs # CLI entry point
β βββ commands/ # Command implementations
β β βββ init.rs # Initialize flake
β β βββ add.rs # Add packages
β β βββ remove.rs # Remove packages
β β βββ search.rs # Search packages
β β βββ add_command.rs # Add custom commands
β β βββ remove_command.rs
β β βββ env.rs # Environment variable management
β β βββ lock.rs # Lock file management
β β βββ update.rs # Update flake inputs
β β βββ show.rs # Display flake config
β β βββ list.rs # List packages
β βββ flake/ # Flake parsing and generation
β β βββ parser.rs # Parse flake.nix
β β βββ generator.rs # Generate flake.nix
β β βββ interface.rs # Data structures
β βββ nix/ # Nix command wrappers
β β βββ mod.rs
β βββ utils/ # Utility functions
β βββ backup.rs # Backup management
βββ templates/ # Flake templates
β βββ default_flake.nix
β βββ rust_flake.nix
β βββ python_flake.nix
β βββ node_flake.nix
β βββ go_flake.nix
βββ tests/ # Test files
βββ integration_tests.rs
βββ unit_tests.rs
πΊοΈ Roadmap
- Project scaffolding and CLI structure
- Implement
initcommand with auto-detection - Implement
searchanddeep-searchcommands - Implement
addandremovecommands - Implement
add-commandandremove-command - Implement
envsubcommands - Implement
lockfile management - Implement
update,show, andlistcommands - Documentation and examples
- Package version pinning (#5)
- CI/CD and releases
- Publish to crates.io
- Interactive TUI mode
- Flake templates marketplace
- Plugin system
π€ 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.1.0). While all core features are implemented and working, some advanced features like version pinning are still in progress. See the roadmap for details.