Skip to content

dbeley/nixos-config

Repository files navigation

nixos-config

NixOS Unstable

cf-qv1 (wallpaper hk-plant)

p14sg6 (wallpaper taiwan-bus)

t470s

Type Program
Shell: fish
DM: tty1
WM: niri / sway / gnome
Bar: noctalia / waybar
Editor: helix / doom-emacs / neovim / kakoune
Terminal: kitty / ghostty
Launcher: tofi
Browser: zen / firefox / qutebrowser / ungoogled-chromium
Theme: stylix

Notable Features

Hosts

  • p14sg6: Lenovo ThinkPad P14s Gen 6 (AMD Ryzen AI 7 350, 32GB RAM, niri, impermanence)
  • cf-qv1: Panasonic Let's Note CF-QV1 (Intel Core i5-1145G7, 16GB RAM, niri, impermanence)
  • sg13: Silverstone SG13 (AMD Ryzen 9 5950X, RTX 3070, 32GB RAM, gnome)
  • x1yoga: Lenovo ThinkPad X1 Yoga Gen 5 (Intel Core i5-10210U, 8GB RAM, gnome, impermanence)
  • latitude: Dell Latitude 7420 (Intel Core i7-1165G7, 16GB RAM, niri)
  • p14s (deprecated): Lenovo ThinkPad P14s Gen 4 (AMD Ryzen 7 7840U, 16GB RAM, niri, impermanence)
  • vaio (deprecated): Sony Vaio Pro PK13 (Intel Core i5-1035G1, 16GB RAM, niri)
  • x13 (deprecated): Lenovo ThinkPad X13 Gen 1 (AMD Ryzen 5 4650U, 16GB RAM, niri, impermanence)
  • cf-rz6 (deprecated): Panasonic Let's Note CF-RZ6 (Intel Core i5-7Y57, 8GB RAM, niri, impermanence)
  • x61s (deprecated): Lenovo Thinkpad X61s (Intel Core 2 Duo L7500, 3GB RAM, sway)

Proxmox Kimsufi VMs (Dedicated Server)

  • nixos-kimsufi-01: qbittorrent
  • nixos-kimsufi-02: zeroclaw
  • nixos-kimsufi-03: unused

Proxmox Era VMs (Home Server)

  • nixos-era-01: opencode server
  • nixos-era-02: nixflix
  • nixos-era-03: adguard-home
  • nixos-era-04: nextcloud

Common Usage

Rebuilding the System

Rebuild the system

sudo nixos-rebuild switch --flake .#{host}
sudo nixos-rebuild switch --flake .#{host} --target-host root@<ip address> # for a remote host

Delete unused packages

sudo nix-collect-garbage -d # for system packages
nix-collect-garbage -d # for home-manager packages

Optimise store

nix-store --optimise -v

just

On first installation you may need to load the dependencies in your shell for the just recipes to work

nix-shell -p just nh

For the recipes to work properly, create a .env file and fill it with the needed environment variables:

HOST=x13
just switch
just clean
# to check all available recipes
just

Maintenance Tools

Additional just recipes are available for maintenance tasks:

just clean         # Clean old nix generations
just optimize      # Optimize nix store
just flake-linter  # Run flake linter to check for potential duplicate flake inputs
just nix-olde      # Generate outdated packages report with the help of nix-olde (YYYY-MM-DD_nix-olde-report.txt)

Manual Install

On a new install, you should first copy /etc/nixos/hardware-configuration.nix over hosts/{host}/hardware-configuration.nix.

Then add a new definition of the host in hosts/default.nix with the wanted profiles.

Installation without impermanence/disko can be done normally from the NixOS Live ISO, then just clone this repo and just switch (cf. above).

Installing with Custom ISO

From this repo, you can generate a universal installer ISO that includes all the available host configurations:

just build-iso-image

# Flash the ISO to a USB drive (replace /dev/sdX with your USB device and ISO_NAME to your newly built ISO image)
sudo dd if=result/iso/<ISO_NAME>.iso of=/dev/sdX bs=4M status=progress conv=fsync

Boot from the ISO, then:

For hosts with impermanence/disko:

# Install with automatic partitioning for any host
# Note: The --disk main parameter should match your disko.mainDisk setting
sudo nix run 'github:nix-community/disko/latest#disko-install' -- --flake /etc/iso-config#HOSTNAME --disk main /dev/DEVICE

If you don't have enough storage space (by default it takes RAM for the /nix/store), you can either disable some profiles for the host you're building in /etc/iso-config/hosts/default.nix or try one of the following:

# Option 1: Increase the size of tmpfs (allows /nix/store to use more RAM)
sudo mount -o remount,size=75% /nix/.rw-store

# Option 2: Create a swapfile on the target disk to avoid using only RAM
# (requires the target to be mounted at /mnt, e.g. after disko partitioning)
sudo mkswap -U clear --size 8G --file /mnt/swapfile
sudo swapon /mnt/swapfile

If it's still not enough, disable most profiles on the host to have a minimal install, rebuild the iso + flash on the USB stick and try again.

Don't forget to apply the post-installation steps described in the next section (password file).

For standard hosts (without disko):

The custom ISO only works for disko-enabled hosts. For standard hosts, use the official NixOS ISO and follow the manual installation process above.

Impermanence/disko

When using the impermanence/disko module, the installation changes quite a bit and can even be done from a separate host by plugging the destination storage device.

Installation can be done from any computer running nix, using a live ISO running from a USB key is not recommended as it will most likely run out of space during the install. The target disk can be any mounted disk (except the one the system is currently running on!) and will then have to be installed on the host computer after the installation is complete.

# On a new host don't forget to generate the hardware-configuration.nix file and copy it on hosts/{host}/hardware-configuration.nix
# You can do that from a live ISO and then copy it to your build host
nixos-generate-config --no-filesystems

# disko + impermanence install on an existing host called "x1yoga"
# Note: /dev/sda must match the host's disko.mainDisk setting
sudo nix run 'github:nix-community/disko/latest#disko-install' -- --flake .#x1yoga --disk main /dev/sda --show-trace
# Using just
just first-install-disko x1yoga /dev/sda

# Post-installation - mount the newly installed system on /mnt/root
lsblk # identify luks encrypted partition
sudo cryptsetup open /dev/sda2 luks-1
sudo mount -o subvol=root /dev/mapper/luks-1 /mnt/root
sudo mount -o subvol=persistent /dev/mapper/luks-1 /mnt/root/persistent  
sudo mount -o subvol=nix /dev/mapper/luks-1 /mnt/root/nix
sudo mount /dev/sda1 /mnt/root/boot

# Create password file - MANDATORY as password are not mutable in the impermanence/disko module
mkpasswd > temp_passwd_file
sudo mv temp_passwd_file /mnt/root/persistent/passwd_$USER
sudo chown root:root /mnt/root/persistent/passwd_$USER

# Optional: chroot into the new system to apply other changes
sudo nixos-enter --root /mnt

Proxmox VM Images

Dedicated just recipes exist in order to facilite installation and deployment of remote images.

  • Create a VM in Proxmox
  • Boot the NixOS minimal ISO
  • Set up SSH connection by either setting a password to nixos or root user or adding your ssh key into the VM
just install-proxmox-vm HOSTNAME IP
# You might need to delete entries in ~/.ssh/known_hosts to properly connect in ssh
# Connect manually on the VM to change the user password
just switch-proxmox-vm HOSTNAME IP

Post-install

For doom-emacs:

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

Releases

No releases published

Packages

 
 
 

Contributors