Skip to content

sayavc/Niux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Niux

English | Русский

Declarative NixOS/home-manager CLI package manager written in Rust.

Release License Language

Note

"1000+ lines of Rust code that could be effectively replaced by a single shell script."An awesome-nix maintainer

Why Niux?

Managing home-manager and NixOS packages manually requires opening configuration files, adding entries to package lists, and executing rebuild commands.

Niux automates this workflow by providing a lightweight CLI to install, remove, and manage packages via short, intuitive commands — similar to traditional package managers like apt or pacman — while strictly preserving Nix's declarative nature.

  • Manage packages with a single command (e.g., niux -Hi firefox)
  • Automate configuration rebuilds immediately after modifications
  • Update flakes, clean system generations, and manage environment states
  • Leverage native Rust performance for safe, fast, and resource-efficient execution

In short: Niux brings the convenience of traditional package managers to NixOS and home-manager while staying fully declarative.

Features

  • Fast and lightweight command-line interface
  • Manage home and system packages declaratively
  • Built with Rust for performance and reliability
  • Simple and intuitive command syntax
  • Supports both standalone and module home-manager
  • Supports NixOS with and without flakes
  • Hooks which allow to automate actions
  • Autocompletion like Pacman and apt
  • Built-in generation diffing powered by nvd integration

How it works

Niux manages your packages by editing your nix config files directly. If markers are incorrect, Niux will tell you

To get started use default markers or add custom:

home.packages = [
  # niux-home
  firefox
  vim
  # niux-home-end
];

Also, you can omit the start marker:

home.packages = [
  firefox
  vim
#end
];

In that case home.packages = [ will be used as start marker

When you run niux -Hi firefox, it inserts the package after the start marker. When you run niux -Hr firefox, it removes it — but only between the markers, so the rest of your config is never touched.

Markers are configurable via your config

Installation

With flakes (standalone home-manager)

Add to your flake.nix inputs:

inputs.niux = {
    url = "github:sayavc/niux";
    inputs.nixpkgs.follows = "nixpkgs";
};

Pass niux to home-manager via extraSpecialArgs:

outputs = inputs@{ nixpkgs, home-manager, niux, ... }: {
homeConfigurations.youruser = home-manager.lib.homeManagerConfiguration {
    pkgs = nixpkgs.legacyPackages.x86_64-linux;
    extraSpecialArgs = { inputs = { inherit niux; }; };
    modules = [ ./home/home.nix ];
   };
};

Then add to your home.nix:

{ inputs, pkgs, ... }: {
    home.packages = [
        inputs.niux.packages.${pkgs.system}.default
    ];
}

Run home-manager switch to apply.

With flakes (module home-manager)

Add to your flake.nix inputs:

inputs.niux = {
    url = "github:sayavc/niux";
    inputs.nixpkgs.follows = "nixpkgs";
};

Pass niux to home-manager:

outputs = inputs@{ self, nixpkgs, home-manager, niux, ... }: {
  nixosConfigurations.yourhostname = nixpkgs.lib.nixosSystem {
    system = "x86_64-linux";
    modules = [
      ./configuration.nix
      home-manager.nixosModules.home-manager
      {
        home-manager.useGlobalPkgs = true;
        home-manager.useUserPackages = true;
        home-manager.extraSpecialArgs = { inputs = { inherit niux; }; };
        home-manager.users.yourusername = import ./home.nix;
      }
    ];
  };
};

Add to home.nix:

# home.nix
{ inputs, pkgs, ... }: {
  home.packages = [
    inputs.niux.packages.${pkgs.system}.default
  ];
}

Note: Non-flake installation docs coming soon, Contributions welcome!

Configuration

First, generate the default config:

niux --gen-config

Or at a custom path:

niux --config /my/path/niux.kdl
niux --gen-config 

and for hooks:

niux --hook-config /my/path/niux.kdl 
niux --gen-config

To display the path:

niux --show-path

Note: use --gen-config after --config and --hook-config

Usage

Quick Start

niux -Hi firefox        # Install firefox for home
niux -Si vim            # Install vim for system
niux -Hia firefox       # Install firefox for home and rebuild system

niux -Hr firefox        # Remove firefox from home

niux -He                # Edit packages mode

niux -Hl                # List home packages
niux -l firefox         # Search everywhere

niux -U                 # Update all flakes
niux -USHa              # Update + rebuild everything

niux -HSa               # Rebuild both configs

Installation & Removal

niux -Hi firefox            # Install firefox for home
niux -Hia firefox           # Install and rebuild home
niux -Si vim                # Install vim for system
niux -Sia vim               # Install and rebuild system
niux -Hi firefox vim        # Install multiple packages for home
niux -Si firefox vim        # Install multiple packages for system

niux -Hr firefox            # Remove firefox from home
niux -Hra firefox           # Remove and rebuild home
niux -Sr vim                # Remove vim from system
niux -Sra vim               # Remove and rebuild system
niux -Hr firefox vim        # Remove multiple from home
niux -Sr firefox vim        # Remove multiple from system

niux -He                    # Edit home packages
niux -Se                    # Edit system packages
niux -Sea                   # Edit system packages and rebuild config
niux -Hea                   # Edit home packages and rebuild config 

Listing & Search

niux -l                     # List all packages
niux -Hl                    # List home packages
niux -Sl                    # List system packages
niux -l firefox             # Search everywhere
niux -Hl firefox            # Search in home
niux -Sl firefox            # Search in system
niux -l firefox vim         # Search multiple
niux --search firefox       # Search from nixpkgs 

Updates

niux -U                     # Update all flakes
niux -U nixpkgs             # Update specific flake input
niux -HUa                   # Update + rebuild home
niux -SUa                   # Update + rebuild system
niux -USHa                  # Update + rebuild everything
niux -HUa nixpkgs           # Update nixpkgs + rebuild home
niux -SUa nixpkgs           # Update nixpkgs + rebuild system

Build & Apply

niux -Ha                    # Rebuild home config
niux -Sa                    # Rebuild system config
niux -HSa                   # Rebuild both configs

Cleanup

niux --clear                # Run nix-collect-garbage

Hooks

Example:

actions {
    action "post-rebuild"
    run "zsh /etc/niux_post_rebuild.zsh"
}

available actions: install, remove, edit, rebuild, update, list, clear, search

Commands Reference

Flag Description
-H - Home Target home packages
-S - System Target system packages
-i - install Install packages
-r - remove Remove packages
-e - edit Edit mode
-a - apply(rebuild) Apply and rebuild configuration
-l - list List or search packages
-U - Update Update flakes
--gen-config Generate default configuration
--config Use custom config path
--hook-config Use custom hook config path
--show-path Get config paths
--clear Run garbage collection
--search Search packages from nixpkgs

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

Author

Created by sayavc

About

A simple CLI tool for managing NixOS packages

Topics

Resources

License

Stars

58 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors