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
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:
-
Do not update flake inputs. Avoid running
flk updateornix flake update. If you already did, restore a previous lockfile backup with: -
Pin
nix-profile-libto v0.1.0. In yourflake.nix:inputs = { nix-profile-lib.url = "github:AEduardo-dev/nix-profile-lib?ref=v0.1.0"; };Then update the lock entry:
(or
nix flake update --update-input nix-profile-lib)
Once you upgrade to flk v0.5.0+, this restriction is lifted.
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)
Hooks
If you would like to use hot reloading and switching features, you will need to add the following shell hook to your shell configuration file (~/.bashrc, ~/.zshrc, etc.):
Example for bash:
# flk shell hook
if ; then
fi
Support for other shells (zsh and fish) is also available via flk hook <shell>.
From Source
From Cargo (crates.io)
From Release Binaries
- Go to https://github.com/AEduardo-dev/flk/releases
- Download the archive for your OS/arch (Linux x86_64, macOS Intel, macOS ARM).
- Unpack and place
flkin your PATH.
Nix (with Cachix binaries)
This flake is prebuilt and published to Cachix.
- Install Cachix (once):
- Trust the cache:
or add the following substituters and trusted-public-keys to your nix.conf content:
substituters = https://flk-cache.cachix.org ...
trusted-public-keys = flk-cache.cachix.org-1:6xobbpP9iIK5sIH/75DQrsJYKN/61nTOChcH9MJnBR0= ...
- Use the flake:
- Run (no install):
nix run github:AEduardo-dev/flk#flk - Install to your profile:
nix profile install github:AEduardo-dev/flk#flk
Nix โ Using as a flake input
You can consume flk from another flake either directly or via the overlay.
Direct (no overlay):
{
description = "My NixOS config with flk";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flk.url = "github:AEduardo-dev/flk";
};
outputs = { self, nixpkgs, flk, ... }:
let
system = "x86_64-linux"; # set per host
pkgs = import nixpkgs { inherit system; };
in {
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
{
environment.systemPackages = [
flk.packages.${system}.flk
];
}
];
};
};
}
With overlay (exposes pkgs.flk):
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flk.url = "github:AEduardo-dev/flk";
outputs = { self, nixpkgs, flk, ... }:
let
system = "x86_64-linux"; # set per host
pkgs = import nixpkgs {
inherit system;
overlays = [ flk.overlay ];
};
in {
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
{ environment.systemPackages = [ pkgs.flk ]; }
];
};
};
}
Home Manager example (per-user install via flake):
{
inputs.flk.url = "github:AEduardo-dev/flk";
outputs = { self, flk, ... }: {
homeConfigurations.myhost = {
# ...
home.packages = [ flk.packages.${system}.flk ];
};
};
}
Architectures covered by the cache
- x86_64-linux
- x86_64-darwin
- aarch64-darwin
- aarch64-linux (built via qemu on CI; may be slower/occasional misses)
Other architectures will fall back to building from source.
๐ 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 and versions
# Add packages to your environment
# Or add pinned versions
3. Add Custom Commands
# Add inline commands
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.
7. Attach to your direnv (optional)
If you use direnv, you can set it up to automatically load your flk environment when you enter the project directory.
# Generates a .envrc file for direnv with use flake command
#or
# Add the direnv hook to an existing project
if you ever want to detach the direnv hook, you can run:
8. Switch / Refresh your environment
๐ 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.
Future implementations will include the option to activate specific profiles.
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.
Examples:
Or add a specific version:
flk remove <PACKAGE>
Remove a package from your flake.nix.
Examples:
Custom Commands
flk command add <NAME> <COMMAND> [OPTIONS]
Add a custom shell command to your development environment.
Examples:
# Inline command
# Multi-line command
Command naming rules:
- Must contain only letters, numbers, hyphens, and underscores
- Cannot start with a hyphen
- Examples:
test,dev-server,build_prod
flk command remove <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:
Direnv Integration
flk direnv init
Generate a .envrc file for direnv with use flake command.
flk direnv attach
Add the direnv hook to an existing project.
flk direnv detach
Remove the direnv hook from the project.
๐ก 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
๎ฟ .
โโโ ๎ 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
๐ค 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
- Special mention to @vic for creating nix-versions
๐ 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. While all core features are implemented and working, some advanced features are still in progress and will be subject to change.