4 KiB
basics
Absolutely — using Nix on Debian can give you a powerful, AUR-like experience with access to thousands of packages, isolated environments, and even rollbacks. It’s a different mindset than apt, but super powerful once you get the hang of it.
🧰 What Is Nix?
Nix is a purely functional package manager:
- Installs packages without interfering with your system.
- Supports per-user installs — no sudo needed for most things.
- Enables isolated dev environments, rollbacks, and reproducibility.
🧱 Step-by-Step: Installing and Using Nix on Debian
🔹 1. Install Nix
Run this script (official installer):
curl -L https://nixos.org/nix/install | sh
✅ After installation, either restart your shell or run:
. ~/.nix-profile/etc/profile.d/nix.sh
🔹 2. Install a Package (like hello)
nix-env -iA nixpkgs.hello
This installs the
helloprogram into your user profile — no sudo needed.
You can run it immediately:
hello
🔹 3. Search for Packages
nix search nixpkgs firefox
Or use the web search: https://search.nixos.org/packages
🔹 4. Upgrade Installed Packages
nix-env --upgrade
🔹 5. Remove a Package
nix-env -e hello
🧪 Bonus: Reproducible Dev Environments (shell.nix)
Make a file named shell.nix:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = [
pkgs.git
pkgs.nodejs
pkgs.python3
];
}
Then run:
nix-shell
This drops you into an environment with only those tools installed — perfect for development!
🔐 Is It Safe?
Yes — it’s sandboxed, doesn't touch your global system files, and is trusted by many in the DevOps/Dev world.
⚠️ Things to Know
- It uses a huge store (
/nix/store) — so expect some disk usage. - It can be a learning curve, but well worth it if you want reproducibility or project-based environments.
- You can uninstall Nix any time with
nix-env --uninstallor delete/nix.
Want to try installing a specific package with Nix now, or explore using home-manager for managing your full dotfiles setup?
Installing packages
To install Brave using Nix, you have a couple of options depending on how you want to use it (system-wide, user profile, or temporary). Here's how to do it:
🦁 Option 1: Install Brave to Your User Profile (Permanent)
First, search for it:
nix search nixpkgs brave
You should see a result like:
brave # A privacy-focused web browser
Then install it:
nix-env -iA nixpkgs.brave
✅ This makes brave available permanently in your user environment.
⚡ Option 2: Use nix shell (Temporary)
If you just want to run Brave without installing:
nix shell nixpkgs#brave
This will drop you into a shell where brave is available. You can launch it:
brave
When you exit the shell, it's gone — no clutter!
🔥 Option 3: Use nix run (One-off Execution)
To run Brave directly:
nix run nixpkgs#brave
📦 Bonus: Use home-manager (for managing user packages declaratively)
If you're managing your dotfiles/config with Nix, you can declare Brave in your home.nix like this:
{
home.packages = with pkgs; [
brave
];
}
Then just run home-manager switch.
Would you like help setting up home-manager too? It's great if you're building a Nix-based setup.
for enabling expermimental feature which is required for search and install packages
sudo mkdir -p /etc/nix
sudo nano /etc/nix/nix.conf
then add following
experimental-features = nix-command flakes
to remove packages
if installed with nix-env
nix-env -e brave
and then
for removing unused packages
nix-collect-garbage
for older generations:
nix-collect-garbage -d