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.
- Search packages using
nix search --jsonand 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).
nix(withnix searchavailable)nixos-rebuildand/orhome-managerif you want automatic rebuilds
Run directly from the flake:
nix run github:timasoft/declair-rsInstall permanently to your user profile:
nix profile install github:timasoft/declair-rsAdd 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
];
}
];
};
};
}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 thewith pkgs; [...]block-l, --listβ list packages currently present in thewith pkgs; [...]block-d, --dry-runβ perform a dry-run (only print selected package without modifying files)--programβ useprograms.<package>.enable = true;instead of adding pkg towith pkgs; [...](if available)
Interactive add:
declair-rs
# then type a query like `neovim` and choose a resultNon-interactive (add exact name):
declair-rs --no-interactive -p neovimList packages in a config:
declair-rs --config /etc/nixos/configuration.nix --listRemove a package:
declair-rs -c ~/nixos -p somepkg -rDry-run to preview selection:
declair-rs -d firefoxAdd package as program (when available):
declair-rs -p firefoxOn 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 = trueOptions:
nix_pathβ path to your Nix configuration file or directory (tilde~is expanded)auto_rebuildβ whether to run a rebuild after modifying the filehome_managerβ usehome-manager switchinstead ofnixos-rebuildflakeβ append--flake .to rebuild commands
Use the provided dev shell (flake):
nix developIt includes Rust toolchain components: cargo, rustc, rustfmt, clippy, rust-analyzer, and fish shell by default.
Build and run with cargo:
cargo run --release- Add support for removing packages (
--remove). - Implement listing of currently configured packages (
--list). - Add
--dry-runoption 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