Skip to content

A TUI app to find and add packages to your NixOS config, written in blazingly fast Rust! πŸš€πŸ¦€

Notifications You must be signed in to change notification settings

timasoft/declair-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

declair-rs

declair-rs is a Rust command-line utility that helps you quickly search, add, and manage packages in your NixOS or Home Manager configuration. It can also optionally trigger an automatic rebuild (nixos-rebuild or home-manager switch) after modifying your config.


Features

  • Search packages using nix search --json and pick a result interactively.
  • Insert package into a with pkgs; [ ... ] block (single-line or multi-line).
  • Remove packages from that block (via --remove).
  • List packages currently present in a config file (--list).
  • Create a simple TOML config on first run (~/.config/declair/config.toml).
  • Dry-run mode to preview selected package without making changes (--dry-run).
  • Support for adding packages as programs.<name>.enable = true; when available (--program).

Requirements

  • nix (with nix search available)
  • nixos-rebuild and/or home-manager if you want automatic rebuilds

Install

Run directly from the flake:

nix run github:timasoft/declair-rs

Install permanently to your user profile:

nix profile install github:timasoft/declair-rs

Add as an input to your flake (example):

{
  inputs.declair-rs.url = "github:timasoft/declair-rs";

  outputs = { self, nixpkgs, declair-rs, ... }: {
    nixosConfigurations.my-host = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        ./configuration.nix
        {
          environment.systemPackages = [
            declair-rs.packages.x86_64-linux.default
          ];
        }
      ];
    };
  };
}

Usage

declair-rs [OPTIONS]

Common options:

  • -c, --config <FILE> β€” path to config file or directory (overrides stored config)
  • -p, --package <NAME> β€” package name or search query
  • -f, fzf β€” use fzf for package selection (needs fzf installed)
  • --no-interactive β€” run without prompts (fails if required info is missing)
  • --no-rebuild β€” skip automatic rebuild even if enabled in config
  • -r, --remove β€” remove package from the with pkgs; [...] block
  • -l, --list β€” list packages currently present in the with pkgs; [...] block
  • -d, --dry-run β€” perform a dry-run (only print selected package without modifying files)
  • --program β€” use programs.<package>.enable = true; instead of adding pkg to with pkgs; [...] (if available)

Example

Interactive add:

declair-rs
# then type a query like `neovim` and choose a result

Non-interactive (add exact name):

declair-rs --no-interactive -p neovim

List packages in a config:

declair-rs --config /etc/nixos/configuration.nix --list

Remove a package:

declair-rs -c ~/nixos -p somepkg -r

Dry-run to preview selection:

declair-rs -d firefox

Add package as program (when available):

declair-rs -p firefox

Configuration

On first run, the tool writes a small TOML config under the platform config dir (typically ~/.config/declair/config.toml).

Example config.toml:

nix_path = "~/nixos"
auto_rebuild = true
home_manager = false
flake = true

Options:

  • nix_path β€” path to your Nix configuration file or directory (tilde ~ is expanded)
  • auto_rebuild β€” whether to run a rebuild after modifying the file
  • home_manager β€” use home-manager switch instead of nixos-rebuild
  • flake β€” append --flake . to rebuild commands

Development

Use the provided dev shell (flake):

nix develop

It includes Rust toolchain components: cargo, rustc, rustfmt, clippy, rust-analyzer, and fish shell by default.

Build and run with cargo:

cargo run --release

TODO

  • Add support for removing packages (--remove).
  • Implement listing of currently configured packages (--list).
  • Add --dry-run option to preview changes without writing.
  • Support programs.<name>.enable = true; style package declarations.
  • Support multiple configuration files in a single profile.
  • Add autocomplete for package names.
  • Add GIF demo to the README

About

A TUI app to find and add packages to your NixOS config, written in blazingly fast Rust! πŸš€πŸ¦€

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •