NixOS
To clean your Nix store:
Basic garbage collection:
nix-collect-garbage
Delete old generations and collect garbage:
nix-collect-garbage -d
Delete generations older than X days:
nix-collect-garbage --delete-older-than 30d
If using flakes/new CLI:
nix store gc
Optimize (deduplicate) the store:
nix-store --optimise
Run with sudo if you want to clean system profiles too.
Install NixOS
nix-shell -p git vim
mkdir code
cd code
git clone https://github.com/mikaelweiss/dotfiles
sudo rm /etc/nixos/configuration.nix
rm /home/mikaelweiss/code/dotfiles/nixos/hardware-configuration.nix
sudo mv /etc/nixos/hardware-configuration.nix /home/mikaelweiss/code/dotfiles/nixos/
sudo ln -s /home/mikaelweiss/code/dotfiles/nixos/configuration.nix /etc/nixos
sudo ln -s /home/mikaelweiss/code/dotfiles/nixos/hardware-configuration.nix /etc/nixos
sudo ln -s /home/mikaelweiss/code/dotfiles/nixos/flake.nix /etc/nixos
sudo ln -s /home/mikaelweiss/code/dotfiles/nixos/.zshrc /home/mikaelweiss
sudo ln -s /home/mikaelweiss/code/dotfiles/nixos/.p10k.zsh /home/mikaelweiss
sudo vim /etc/nixos/configuration.nix # Update hostname to match your hostname
sudo vim /etc/nixos/flake.nix # Update hostname to match your hostname
exit
sudo nixos-rebuild switch
Note
If you want to change the hostname, you'll need to enter the directory of your flake.nix and rebuild there instead of from the /etc/nixos directory or it won't work
cd code/dotfiles/nixos > sudo nixos-rebuild switch --flake .#charmander