These are the steps I use when bringing up a new host with this repo.
If you already have a working SSH key that is added to GitHub, skip this section.
Check whether a key already exists:
ls -l ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pubIf you want a fresh key, move the old one aside first instead of deleting it:
mv ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.old.$(date +%s) 2>/dev/null || true
mv ~/.ssh/id_ed25519.pub ~/.ssh/id_ed25519.pub.old.$(date +%s) 2>/dev/null || trueGenerate a new key:
ssh-keygen -t ed25519 -C "you@example.com"Start the agent and add the key:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519Print the public key and add it to GitHub:
cat ~/.ssh/id_ed25519.pubAdd it here:
https://github.com/settings/ssh/new
nix-shell -p git microgit clone git@github.com:TheTechRun/nixos-ttr.git ~/nixos-config
cd ~/nixos-config
git config --global user.email "you@example.com"
git config --global user.name "user"
git config --global init.defaultBranch masterIf you do not want to use the default usernames from this repo, run the rename script now before the first flake rebuild.
Example:
~/nixos-config/scripts/user-rename.sh ttr muffinThis updates the repo's user-related text and curated modules/users/ paths so your host imports and user modules stay consistent.
Pick the host first:
export HOST=desktopValid values here are:
desktoplaptopserverminimal
Then back up the current /etc/nixos files and copy the generated hardware config into this repo:
mkdir -p ~/nixos-config/hosts/$HOST/backups
sudo cp /etc/nixos/configuration.nix ~/nixos-config/hosts/$HOST/backups/configuration.nix.backup
sudo cp /etc/nixos/hardware-configuration.nix ~/nixos-config/hosts/$HOST/backups/hardware-configuration.nix.backup
sudo cp /etc/nixos/hardware-configuration.nix ~/nixos-config/hosts/$HOST/hardware-configuration.nixThis section exists because the first flake rebuild can fail when the machine is still on an older NixOS release. If the installed host is behind the release expected by this repo, update the host release first and then do the flake rebuild.
Check the current host version:
nixos-versionOr:
cat /etc/os-releaseYou can use the helper script:
~/nixos-config/scripts/channel-update.shOr do it manually:
Remove the existing channel:
sudo nix-channel --remove nixosAdd the correct channel:
sudo nix-channel --add https://nixos.org/channels/nixos-<target-version-here> nixosCheck it:
sudo nix-channel --listUpdate it:
sudo nix-channel --updateRebuild once from the current /etc/nixos config:
cd /etc/nixos
sudo nixos-rebuild switchOnly do the previous steps in the above section when the host is too old for the first flake rebuild to work cleanly.
Symlink the flake into /etc/nixos:
sudo ln -sf ~/nixos-config/flake.nix /etc/nixos/flake.nixUse the host selected earlier (be sure to be in the same shell that you did the $HOST export, or just do it again):
sudo nixos-rebuild switch --extra-experimental-features 'nix-command flakes' --flake ~/nixos-config#$HOSTSome Examples:
sudo nixos-rebuild switch --extra-experimental-features 'nix-command flakes' --flake ~/nixos-config#desktop
sudo nixos-rebuild switch --extra-experimental-features 'nix-command flakes' --flake ~/nixos-config#laptop
sudo nixos-rebuild switch --extra-experimental-features 'nix-command flakes' --flake ~/nixos-config#serverAfter the first successful flake rebuild, the normal command is:
sudo nixos-rebuild switch --flake ~/nixos-config#$HOSTOr use this script with auto HOST detection and git functionality:
~/nixos-config/scripts/flake-scripts/rebuild-flake.shThis setup currently builds a window-manager environment around Scroll, which is a Sway fork.
If you want a different window manager or a full desktop environment instead, change the relevant imports in your hosts/<host>/configuration.nix from:
~/nixos-config/modules/desktop-environment/