Workflow's current, and immutably evolving, NixOS configuration files, home-manager, neovim, etc.
Used as daily driver since 2020.
- Download NixOS to
$ISO_PATH
- insert drive
lsblk
-> find out drive name (e.g./dev/sdb
)$DRIVE
- run (as sudo)
dd bs=4M if=$ISO_PATH of=$DRIVE conv=fdatasync status=progress && sync
Roughly this https://github.com/andywhite37/nixos/blob/master/DUAL_BOOT_WINDOWS_GUIDE.md
- Install all updates
- Create a windows recovery USB Drive (Search for "Create Recovery Drive") [Fair warning: This is slooooooooow]
- Shrink main Windows partition using built-in Disk Management tool
- Use Macrorit Partition Expert to extend EFI partition to 1024MB
- (optional) Delete Recovery Partition(s) 1 Install NixOS as below, re-using the existing EFI boot partition setup by Windows, and things should work with systemd-boot out of the box!
Roughly this https://github.com/andywhite37/nixos/blob/master/DUAL_BOOT_WINDOWS_GUIDE.md
- Install all updates from Windows
- Create a windows recovery USB Drive (Search for "Create Recovery Drive") [Fair warning: This is slooooooooow]
- Shrink Main Windows partition and throw NTFS on it
- Disable Bitlocker
- Go to BIOS, disable Secure Boot and maybe fast startup
- Install NixOS as below, re-using the existing EFI boot partition setup by Windows, and things should work with systemd-boot out of the box!
Roughly this https://qfpl.io/posts/installing-nixos/
- sudo -i
- lsblk -> find out disk name (e.g.
/dev/sda
)$DISK
export DISK=/dev/sda
gdisk $DISK
p
(print)d
(delete)n
(new)- number=1, begin=default, end=
+1G
, hex code=ef00
(not needed if dual boot) ($BOOT
from now on, or/dev/sda1
etc) - number=2, begin=default, end=default, hex code=
8e00
($MAIN
from now on)
- number=1, begin=default, end=
w
(write)
export BOOT=/dev/sda1
export MAIN=/dev/sda2
- encryption
cryptsetup luksFormat $MAIN
cryptsetup luksOpen $MAIN nixos-enc
pvcreate /dev/mapper/nixos-enc
vgcreate nixos-vg /dev/mapper/nixos-enc
lvcreate -L <swap size, e.g. 8G, usually pick 2xRAM for hibernation if space doesn't matter> -n swap nixos-vg
lvcreate -l 100%FREE -n root nixos-vg
- create fs
mkfs.vfat -n boot $BOOT
(not needed if dual boot)mkfs.ext4 -L nixos /dev/nixos-vg/root
mkswap -L swap /dev/nixos-vg/swap
swapon /dev/nixos-vg/swap
- mount
mount /dev/nixos-vg/root /mnt
mkdir /mnt/boot
mount $BOOT /mnt/boot
- generate config
nixos-generate-config --root /mnt
- add stuff to config
required:
boot.initrd.luks.devices = {
root = {
device = "$MAIN";
preLVM = true;
};
};
# If not dual-booting with GRUB
boot.loader.systemd-boot.enable = true;
networking.networkmanager.enable = true;
users.users.farlion = {
extraGroups = ["wheel" "video" "audio" "disk" "networkmanager"];
isNormalUser = true;
};
- nixos go brrrr
nixos-install
reboot
to have a DM after first boot:
services.xserver = {
enable = true;
displayManager = {
gdm = {
enable = true;
wayland = false;
};
};
desktopManager.plasma5.enable = true; # or xfce or whatever
# or
# windowManager.xmonad.enable = true;
# to be able to mount an external drive to get secrets etc. for cloning from gh
boot.supportedFilesystems = [ "ntfs" ];
};
- connect to internet from nmcli
- find out interface:
nmcli d
($IF
) - enable interface:
nmcli r wifi on
- search networks:
nmcli d wifi list
- connect:
nmcli d wifi connect $(B)SSID password $PASSWORD
- find out interface:
($NIXOS_CONFIG
is the location of this repo)
- change your name to
farlion
because it's hardcoded in the configurations passwd farlion
and thensu
git clone https://github.com/workflow/nixos-config.git $NIXOS_CONFIG
- From
$NIXOS_CONFIG/machines/*/system.nix
as a template, set required settings like thenetworking.hostname
and the correct networking interfaces to enable DHCP sudo nix-channel --add https://github.com/NixOS/nixos-hardware/archive/master.tar.gz nixos-hardware
-> still needed? 🤔sudo nix-channel --update
-> still needed? 🤔sudo mkdir -m 0755 -p /nix/var/nix/{profiles,gcroots}/per-user/farlion
(forhome-manager
) -> still needed? 🤔- Update flake.nix with new machine (preferably name = hostname)
nix shell nixpkgs#cachix -c cachix use workflow-nixos-config
sudo nixos-rebuild switch --flake $NIXOS_CONFIG#<machine name, empty if hostname> --override-input secrets nixpkgs
- Reboot
- On an existing syncthing device, mutually add the new device
- Push addition of new syncthing device + folder sharing settins on old device
- On new device, Accept new folders as "Receive only" (check the path is correct!) on new device and let it sync
- Push any local
$NIXOS_CONFIG
config changes to github - Remove local
$NIXOS_CONFIG
and symlink it to~/code/nixos-config
- Symlink
~/nixos-secrets
to~/code/nixos-secrets
- Change
root
passwd - Rerun
n
- Reboot
- Login to mega (
mega-cmd
for interactive mode) - Manually set up Duplicati backups (config under ~/.backup)
- Rerun
n
- Reboot
- Prepare the new disk according to the Partitioning Information up to the point just before mounting the swap/disks
- Update the hardware configuration (e.g.
nixos-config/machines/my-machine/hardware-scan.nix
and maybenixos-config/machines/my-machine/system.nix
) to point to the new partitions - Mount the new boot partition in-place:
sudo mount $NEWBOOT /boot
- Install the new configuration, including bootloader:
sudo nixos-rebuild boot --install-bootloader --flake .#my-machine
- Reboot into an installation disk
- Mount the old root parition at
/mnt/old
- Mount the new root parition at
/mnt/new
- Copy everything over, preserving creation times with
-N
for syncthing:
rsync -aAXvN --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /mnt/old/ /mnt/new
- Reboot into the new drive and enjoy =)
A lot of this was looted from https://github.com/alexpeits/nixos-config. Thank you!
CI build stolen from inspired by https://github.com/gvolpe/nix-config