NixOS describes your computer in configuration files. This makes a setup reproducible, predictable and versioned: keep the files in Git, review changes, and reuse them elsewhere. Each rebuild also creates a bootable generation, so a broken change is easy to roll back.
Start with the system
The installer generates /etc/nixos/hardware-configuration.nix. Keep that hardware-specific file and put your choices in /etc/nixos/configuration.nix:
{ config, pkgs, ... }:
{
imports = [ ./hardware-configuration.nix ];
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "my-pc";
services.desktopManager.cosmic.enable = true;
services.displayManager.cosmic-greeter.enable = true;
environment.systemPackages = with pkgs; [
git
ripgrep
];
services.libinput.touchpad.naturalScrolling = true;
users.users.alex = {
isNormalUser = true;
extraGroups = [ "networkmanager" "wheel" ];
};
system.stateVersion = "25.11"; # Keep the value created by the installer.
}
Apply it with:
sudo nixos-rebuild switch
On the next boot, systemd-boot lets you select an older NixOS generation if needed. If the machine also has Ubuntu installed, its bootloader entry is separate: select Ubuntu from the firmware or boot menu. COSMIC, by contrast, is a desktop environment enabled by the NixOS configuration above.
Manage Firefox with Home Manager
Home Manager applies the same declarative idea to your user account. Once it is installed, a minimal ~/.config/home-manager/home.nix can contain:
{ config, pkgs, ... }:
{
home.username = "alex";
home.homeDirectory = "/home/alex";
programs.firefox = {
enable = true;
profiles.default.settings = {
"browser.newtabpage.activity-stream.feeds.section.topstories" = false;
"browser.newtabpage.activity-stream.showSponsored" = false;
"browser.newtabpage.activity-stream.showSponsoredTopSites" = false;
};
};
programs.home-manager.enable = true;
home.stateVersion = "25.11"; # Keep your original value when upgrading.
}
Apply it with:
Move to another PC
Commit configuration.nix and home.nix to Git, but generate a fresh hardware-configuration.nix on the new machine. Then copy or clone the shared files, adjust the hostname, username and any machine-specific options, and run:
sudo nixos-rebuild switch
home-manager switch
The new PC now has the same desktop, tools, browser preferences and system settings. If a rebuild causes trouble, reboot into the previous generation or run sudo nixos-rebuild switch --rollback.