lazyflakes

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

lazyflakes logo

lazyflakes

A lazygit-style terminal UI for nixpkgs: search packages from the stable and unstable channels side by side, then

  • drop into a shell with them (enter),
  • write a shell.nix or flake.nix (and .envrc) for the current project (w),
  • or install them into your NixOS, nix-darwin or home-manager configuration (a).

Install

lazyflakes needs Nix (it asks Nix for the packages). Pick one:

Try it without installing

nix run github:MaJDa-sh/lazyflakes

Install for your user

nix profile install github:MaJDa-sh/lazyflakes

In a NixOS, nix-darwin or home-manager flake

inputs.lazyflakes.url = "github:MaJDa-sh/lazyflakes";
inputs.lazyflakes.inputs.nixpkgs.follows = "nixpkgs";

# then, in a module:
environment.systemPackages = [ inputs.lazyflakes.packages.${pkgs.stdenv.hostPlatform.system}.default ];
# (or home.packages; overlays.default adds pkgs.lazyflakes instead)

Prebuilt binary (Linux and macOS, x86_64 and arm64): download the archive for your system from the releases page, unpack it and put lazyflakes somewhere on your PATH.

With Go: go install github.com/MaJDa-sh/lazyflakes@latest, or from a checkout ./install.sh (installs to ~/.local/bin, PREFIX=… to change).

The first start evaluates all of nixpkgs for both channels, which can take 1–3 minutes. The result is cached for a day, so later starts take under a second.

Keys

Where Keys
Everywhere 1 Packages · 2 Selected · 3 Installed (or tab to cycle) · q quit
[1] Packages / search · j/k move · space select · c default channel · enter shell · w write nix file · a install into system · o options · ctrl+r reload
[2] Selected j/k move · space/d unselect · c switch channel · enter shell · w · a · o
[3] Installed j/k move · d mark for removal · c change channel · u undo · enter review and apply · [/] other target
Write popup enter write · s/f shell.nix / flake.nix · e toggle .envrc · o options
Options space or 1-4: allow unfree, insecure, broken, unsupported
Install popup enter apply and rebuild · s save without rebuilding · d remove · c channel · tab next target

Packages lazyflakes installed get a hollow ○ in the package list and are listed in the [3] Installed panel. To remove one, press 3, move to it, press d (it turns red: "remove on apply"), then enter to review the changes and enter again to apply and rebuild.

Flags: -channel stable|unstable, -stable <flake ref>, -unstable <flake ref>, -format flake|shell, -envrc=false, -allow unfree,insecure, -config <path>. Most have a LAZYFLAKES_* environment variable, see lazyflakes -h.

The system installs also work without the TUI:

lazyflakes add ripgrep jq          # install into the default target and rebuild
lazyflakes add -channel unstable -allow unfree vscode
lazyflakes remove jq
lazyflakes list                    # what lazyflakes installed, and whether it is imported

(-target NAME picks another target, -no-rebuild only writes the module.)

Installing into your system configuration

Every configuration is laid out differently, so lazyflakes does not try to edit yours. Instead it owns one module, lazyflakes.nix, which it rewrites whenever you add or remove packages. You import that module once and the rest is automatic.

1. Run setup

lazyflakes setup

It detects NixOS (flake or configuration.nix), nix-darwin and home-manager, shows the config it proposes, writes it to ~/.config/lazyflakes/config.toml and creates an empty lazyflakes.nix (using sudo, doas or run0 if the directory is root-owned). Pressing a without a config offers to run it too.

Flakes are evaluated to find their nixosConfigurations, darwinConfigurations and homeConfigurations, so flake-parts and similar layouts are recognised. The configuration named after the machine is used; -host NAME picks another one and -flake DIR points setup at a flake outside the usual places (/etc/nixos, ~/nixos-config, ~/.dotfiles, …). With several hosts each gets its own module, e.g. lazyflakes-laptop.nix.

2. Import the module once

# /etc/nixos/configuration.nix, or a module of your flake, or home.nix
imports = [ ./lazyflakes.nix ];

then rebuild once. From now on select packages, press a, review the changes and press enter. The install popup (and lazyflakes list) asks Nix whether the module really is part of your configuration and warns if not.

What happens on apply

The TUI hands the terminal to a small script (so sudo can ask for your password) that

  1. writes lazyflakes.nix, with sudo (or the configured command) only when the file is not writable,
  2. git add --intent-to-adds it if it is new in a git repo (flakes only see tracked files),
  3. runs the target's rebuild command,
  4. and if the rebuild fails, restores the previous lazyflakes.nix, so a bad change never breaks your next rebuild.

config.toml

default = "system"
sudo = "sudo"                         # or "doas", "run0": writes root-owned files

[targets.system]
kind = "nixos"                        # nixos, nix-darwin or home-manager
file = "/etc/nixos/lazyflakes.nix"    # the module lazyflakes owns
rebuild = "sudo nixos-rebuild switch" # empty: only write the file
# flake = "/etc/nixos#laptop"         # flake output, lets lazyflakes check the import
# nixpkgs_config = false              # never write nixpkgs.config.* (see below)
# attribute = "environment.systemPackages"  # default for the kind

[targets.system.sets]
stable = "pkgs"
unstable = 'import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixpkgs-unstable.tar.gz") { inherit (pkgs) config; system = pkgs.stdenv.hostPlatform.system; }'

[targets.home]
kind = "home-manager"
file = "~/.config/home-manager/lazyflakes.nix"
rebuild = "home-manager switch"
sets = { stable = "pkgs" }

sets maps each channel to the package set it comes from inside the module: a module argument (pkgs, or anything passed via specialArgs) or any Nix expression. Packages from a channel without a set are refused with a hint; press c in the install popup to take them from another channel instead.

Flakes evaluate purely and cannot fetchTarball, so pass the other channel in from your flake:

inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
  specialArgs.pkgs-unstable = import nixpkgs-unstable {
    system = "x86_64-linux";
    config.allowUnfree = true;
  };
  modules = [ ./configuration.nix ./lazyflakes.nix ];
};

and set unstable = "pkgs-unstable" under the target's sets.

Options enabled with o (allow unfree, …) are written into the module as nixpkgs.config.* = lib.mkDefault …, so a value set in your own configuration still wins. Configurations that bring their own pkgs (nixpkgs.pkgs, readOnlyPkgs, home-manager's useGlobalPkgs) ignore or reject nixpkgs.config; set nixpkgs_config = false for them and allow unfree in your own configuration instead. Setup does this automatically for flake hosts that set nixpkgs.pkgs.

Development

go test ./...                                   # unit tests
LAZYFLAKES_NIX_EVAL=1 go test ./internal/managed  # evaluate generated modules with nix
LAZYFLAKES_E2E=1 go test -run E2E .              # build real NixOS and home-manager configs
LAZYFLAKES_E2E=1 LAZYFLAKES_VM=1 go test -run VirtualMachine .  # boot a NixOS VM (needs KVM)

The end-to-end tests drive the lazyflakes binary against temporary configurations and build them with nixos-rebuild build / nix build; they use the nixpkgs from NIX_PATH and never touch the running system.

The demo GIF is recorded with VHS in a throwaway home, so it never touches your system: nix-shell -p vhs --run "vhs assets/demo.tape".

Releasing

Releases are built by GoReleaser in GitHub Actions. To publish one:

git tag v0.1.0
git push origin v0.1.0

The workflow runs the tests, builds the binaries and creates the GitHub release with notes grouped from the conventional commits. Try it locally first with nix develop -c goreleaser release --snapshot --clean.

License

MIT. lazyflakes is a community project and is not affiliated with or endorsed by the NixOS Foundation.

Documentation

Overview

lazyflakes is a lazygit-style TUI for browsing nixpkgs (stable and unstable) and generating flake.nix / shell.nix files from the selected packages.

Directories

Path Synopsis
internal
config
Package config loads the user's description of where packages are installed system-wide: one or more targets, each a Nix module file that lazyflakes manages and the command that applies it.
Package config loads the user's description of where packages are installed system-wide: one or more targets, each a Nix module file that lazyflakes manages and the command that applies it.
generate
Package generate renders shell.nix and flake.nix files for a set of packages.
Package generate renders shell.nix and flake.nix files for a set of packages.
managed
Package managed renders, parses and applies the Nix module that lazyflakes owns inside a user's system configuration.
Package managed renders, parses and applies the Nix module that lazyflakes owns inside a user's system configuration.
nix
Package nix loads package metadata from a nixpkgs flake via `nix search`.
Package nix loads package metadata from a nixpkgs flake via `nix search`.
search
Package search ranks packages against a free-text query.
Package search ranks packages against a free-text query.
ui
Package ui implements the lazyflakes terminal interface with Bubble Tea.
Package ui implements the lazyflakes terminal interface with Bubble Tea.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL