Video failed to load

My NixOS Personal Note

304 words
2 minutes
My NixOS Personal Note

1. NixOS main config files#

1. NixOS config:
/etc/nixos/configuration.nix -> nix default system config.

2. Nix Home Manager config:
~/.config/home-manager/home.nix -> nix home manager config.

2. Adding & Removing Packages#

  1. Search for the package name on https://search.nixos.org/packages.
  2. Add the desired package(s) in
  • configuration.nix:
Terminal window
environment.systemPackages = with pkgs; [
obs-studio # contoh meng-install obs-studio
];

Then, after adding the package name(s), run this command on the terminal:

Terminal window
sudo nixos-rebuild switch # directly switch to a new profile
sudo nixos-rebuild boot # apply the alteration on the boot menu
sudo nixos-rebuild test # try the change without saving it on the boot menu
  • home.nix:
Terminal window
home.packages = with pkgs; [
obs-studio
];

Then, after adding the package name(s), run this command on the terminal:

Terminal window
home-manager switch
  1. Alternatively, install a package as a temporary one:
Terminal window
nix-shell -p obs-studio
  1. To remove package(s), simply remove it from the config files and run this command on the terminal:
Terminal window
# for configuration.nix
sudo nixos-rebuild switch # directly switch to a new profile
sudo nixos-rebuild boot # apply the alteration on the boot menu
sudo nixos-rebuild test # try the change without saving it on the boot menu

or

Terminal window
home-manager switch # for home.nix

3. Listing & Upgrading Packages1#

  1. Listing Nix channels
Terminal window
sudo nix-channel --list
  1. Adding/Changing channels
Terminal window
sudo nix-channel --add {name}

For instance, I would like to add “NixOS” 25.11 channel:

Terminal window
sudo nix-channel --add https://nixos.org/channels/nixos-25.11 nixos

A similar command goes with “home-manager” 25.11 channel:

Terminal window
sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-25.11.tar.gz home-manager
  1. Removing channels
Terminal window
sudo nix-channel --remove {channel-alias}

For instance, I would like to remove “nixos” channel:

Terminal window
sudo nix-channel --remove nixos

A similar command goes with “home-manager” channel:

Terminal window
sudo nix-channel --remove home-manager
  1. Updating channels
Terminal window
sudo nix-channel --update

Notes: Using the previous command won’t cause a rebuild itself; if you want to update channels and rebuild, use the following command to do both in one step.

  1. Upgrading Nix packages
Terminal window
sudo nixos-rebuild --upgrade

4. Listing & Deleting NixOS generations#

  1. Listing NixOS generations
  • Rebuild generations
Terminal window
nixos-rebuild list-generations

atau

Terminal window
sudo nix-env -p /nix/var/nix/profiles/system --list-generations
  • Env generations
Terminal window
nix-env --list-generations
  • Home manager generations
Terminal window
home-manager generations
  1. Deleting NixOS generations
  • Deleting rebuild generations
Terminal window
sudo nix-env -p /nix/var/nix/profiles/system --delete-generations <number>
  • Deleting env generations
Terminal window
nix-env --delete-generations <number>
  • Deleting home manager generations
Terminal window
home-manager remove-generations <number>

Footnotes#

  1. https://nixos.wiki/wiki/Nix_channels

Support & Share

If this article helped you, please share or support!

Sponsor
My NixOS Personal Note
https://shangdi.github.io/posts/tech/nixos/
Author
Wildan
Published at
2025-12-10

Comments

Profile Image of the Author
Wildan
Welcome! Wildan-desu.
Announcemenet
Welcome to my blog! Enjoy exploring ~
Categories
Tags
Latest Moments
Site Statistics
Posts
111
Categories
90
Tags
316
Total Words
576,048
Running Days
0 days
Last Activity
0 days ago
Site Info
Build Platform
GitHub Actions
Blog Version
Firefly v6.15.10
License
CC BY-NC-SA 4.0