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 & Deleting NixOS generations#
- Listing NixOS generations
- Rebuild generations
nixos-rebuild 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>

