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#
- Search for the package name on https://search.nixos.org/packages.
- Add the desired package(s) in
configuration.nix:
environment.systemPackages = with pkgs; [
obs-studio # contoh meng-install obs-studio
];
Then, after adding the package name(s), run this command on the terminal:
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:
home.packages = with pkgs; [
obs-studio
];
Then, after adding the package name(s), run this command on the terminal:
home-manager switch
- Alternatively, install a package as a temporary one:
nix-shell -p obs-studio
- To remove package(s), simply remove it from the config files and run this command on the terminal:
# 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
home-manager switch # for home.nix
3. Listing & Upgrading Packages1#
- Listing Nix channels
sudo nix-channel --list
- Adding/Changing channels
sudo nix-channel --add {name}
For instance, I would like to add “NixOS” 25.11 channel:
sudo nix-channel --add https://nixos.org/channels/nixos-25.11 nixos
A similar command goes with “home-manager” 25.11 channel:
sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-25.11.tar.gz home-manager
- Removing channels
sudo nix-channel --remove {channel-alias}
For instance, I would like to remove “nixos” channel:
sudo nix-channel --remove nixos
A similar command goes with “home-manager” channel:
sudo nix-channel --remove home-manager
- Updating channels
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.
- Upgrading Nix packages
sudo nixos-rebuild --upgrade
4. Listing & Deleting NixOS generations#
- Listing NixOS generations
- Rebuild generations
nixos-rebuild list-generations
atau
sudo nix-env -p /nix/var/nix/profiles/system --list-generations
- Env generations
nix-env --list-generations
- Home manager generations
home-manager generations
- Deleting NixOS generations
- Deleting rebuild generations
sudo nix-env -p /nix/var/nix/profiles/system --delete-generations <number>
- Deleting env generations
nix-env --delete-generations <number>
- Deleting home manager generations
home-manager remove-generations <number>

