Skip to content

Setting up a brand new nixos machine

· 2 min

NixOS

I recently took my old workstation out of storage, booted it and found it running Fedora 40 - so of course it was time to put NixOS on the machine and bring it into the fleet. I’ve probably been sleeping on the machine as a build/rendering server for my projects, and figured let’s do it.

While the setup was farily painless (after a `nix flake update`), I have written a quick guide for setting up a brand new machine (workstation - including secrets and files needed for getting a machine up and running) - as the secrets do need to manually be transferred over, as well as some directories.

Note: the machine’s name (logos) and my username (joshua) should be changed for your usecase

Boot your machine from a NixOS .iso#

Add git, nvim to nixos configuration as well as allow ssh into device, then nixos-rebuild switch and ssh into the machine from an already running nixOS instance#

Clone over nix configuration#

git clone https://github.com/joshuablais/nixos-config
cd nixos-config
# Copy over hardware config to nixos configuration repo:
cp /etc/nixos/hardware-configuration.nix hosts/logos/

Copy over ssh and gpg keys as well as age key#

# Move over age key
scp .config/age/keys.txt joshua@192.168.0.60:/home/joshua/.config/age
# Passwords
scp -r ~/.password-store/* joshua@192.168.0.60:/home/joshua/.password-store/
# Authinfo for emacs
scp .authinfo.gpg joshua@192.168.0.60:/home/joshua
# get ssh setup for access:
scp -r ~/.ssh/* joshua@192.168.0.60:/home/joshua/
cat id_ed25519.pub > authorized_keys
# GPG key
scp gpg-pub.asc gpg-secret.asc joshua@192.168.0.60:/home/joshua/
# Import gpg keys:
gpg --import ~/gpg-pub.asc
gpg --import ~/gpg-secret.asc
gpg --list-secret-keys
gpg --edit-key josh@joshblais.com
trust
5
y
q
# Copy over dictionary
scp -r +STORE joshua@192.168.0.60:/home/joshua

First build:#

Get radicale dirs:#

sudo touch /var/lib/radicale/users
sudo chown radicale:radicale /var/lib/radicale/users
sudo chmod 0640 /var/lib/radicale/users

Create directories needed:#

mkdir -p ~/Pictures/Wallpapers
git clone https://github.com/joshuablais/wallpapers Wallpapers

sudo nixos-rebuild switch --flake .#logos
mkdir -p ~/.config/kmonad

Setup doom emacs:#

git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.config/emacs
~/.config/emacs/bin/doom install
rm .emacs.d
doomsync

Notes:#

If you have a better, more reproducible way of setting up a brand new NixOS workstation, I am all ears - while this is about 20x less painful than setting up any legacy distro, I still want to automate the full thing!

As always, God bless, and until next time.

If you enjoyed this post, consider Supporting my work, Checking out my book, Working with me, or sending me an Email to tell me what you think.