Skip to content

Latest commit

ย 

History

History
393 lines (314 loc) ยท 17.5 KB

README.md

File metadata and controls

393 lines (314 loc) ยท 17.5 KB

Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge

NixOS & Home Manager Configurations

GitHub stars GitHub repo size NixOS License

This repository contains a Nix Flake for configuring my computers and/or home environment. It is not intended to be a drop in configuration for your computer, but you are welcome to use it as a reference or starting point for your own configuration. If you are looking for a more generic NixOS configuration, I recommend nix-starter-configs. ๐Ÿ‘๏ธ These computers are managed by this Nix flake โ„๏ธ

Hostname Board CPU RAM Primary GPU Role OS State
woody ROG-STRIX-B650E-WIFI AMD Ryzen 9 7900X 64GB AMD Radeon RX 7800 XT ๐Ÿ–ฅ๏ธ โ„๏ธ โœ…
frametop Framework-13in-12thGen Intel i7-1260P 64GB Intel Iris XE Graphics ๐Ÿ’ป๏ธ โ„๏ธ โœ…
steamdeck SteamDeck-OLED Zen 2 4c/8t 16GB 8 RDNA 2 CUs ๐ŸŽฎ๏ธ ๐Ÿง โœ…
vm1 QEMU - - VirGL ๐Ÿ„ โ„๏ธ โœ…
mv2 QEMU - - VirGL ๐Ÿ„ โ„๏ธ โœ…
nuc1 [NUC6i7KYK] [Intel Core i7-6770HQ] 64GB Intel Iris Pro Graphics 580 โ˜๏ธ โ„๏ธ ๐Ÿšง
nuc2 [NUC5i7RYH] [Intel Core i7-5557U] 32GB Intel Iris Graphics 6100 โ˜๏ธ โ„๏ธ ๐ŸงŸ

Key

  • ๐ŸŽญ๏ธ : Dual boot
  • ๐Ÿ–ฅ๏ธ : Desktop
  • ๐Ÿ’ป๏ธ : Laptop
  • ๐ŸŽฎ๏ธ : Games Machine
  • ๐Ÿ„ : Virtual Machine
  • โ˜๏ธ : Server

Structure

  • .github: GitHub CI/CD workflows Nix โ„๏ธ supercharged โšก๏ธ by Determinate Systems
  • home: My Home-manager configuration, acessible via home-manager --flake
    • features:
    • global:
    • $HOST_NAME.nix: Each hm configuration can toggle. Sane defaults for shell and desktop
  • hosts: NixOS Configurations, accessible via nixos-rebuild --flake.
    • common: Shared configurations consumed by the machine-specific ones.
      • global: Configurations that are globally applied to all my machines.
      • optional: Opt-in configurations my machines can use.
    • $HOST_NAME: Includes discrete hardware configurations that leverage the NixOS Hardware modules.
  • modules: A few modules
  • overlay: Patches and version overrides for some packages. Accessible via
  • pkgs: My custom packages. Also accessible via nix build. You can compose these into your own configuration by using my flake's overlay, or consume them through NUR.
  • templates: A couple project templates for different languages. Accessible via nix init.
  • flake.nix: Entrypoint for hosts and home configurations. Also exposes a devshell for boostrapping (nix develop or nix-shell).
  • [Makefile]: Commands for managing nix

Installing ๐Ÿ’พ

  • Boot off a .iso image created by this flake using build-iso-desktop or build-iso-console (see below)
  • Put the .iso image on a USB drive
  • Boot the target computer from the USB drive
  • Two installation options are available: 1 Use the graphical Calamares installer to install an ad-hoc system 2 Run install-system <hostname> <username> from a terminal
    • The install script uses Disko or disks.sh to automatically partition and format the disks, then uses my flake via nixos-install to complete a full-system installation
    • This flake is copied to the target user's home directory as ~/Zero/nix-config
    • The nixos-enter command is used to automatically chroot into the new system and apply the Home Manager configuration.
  • Reboot ๐Ÿฅพ

All you need is nix (any version). Run:

nix-shell

If you already have nix 2.4+, git, and have already enabled flakes and nix-command, you can also use the non-legacy command:

nix develop

nixos-rebuild --flake . To build system configurations

home-manager --flake . To build user configurations

nix build (or shell or run) To build and use packages

sops To manage secrets

Applying Changes โœจ

I clone this repo to ~/nix-config. NixOS and Home Manager changes are applied separately because I have some non-NixOS hosts.

gh repo clone ryanwclark1/nix-config ~/nix-config
  • โ„๏ธ NixOS: A build-host and switch-host aliases are provided that build the NixOS configuration and switch to it respectively.
  • ๐Ÿ ๏ธ Home Manager: A build-home and switch-home aliases are provided that build the Home Manager configuration and switch to it respectively.
  • ๐ŸŒ๏ธ All: There are also build-all and switch-all aliases that build and switch to both the NixOS and Home Manager configurations.

ISO ๐Ÿ“€

The build-iso script is included that creates .iso images from this flake. The following modes are available:

  • build-iso console (terminal environment): Includes install-system for automated installation.
  • build-iso desktop (desktop environment): Includes install-system and Calamares installation.

Live images will be left in ~/$HOME/nix-config/result/iso/ and are also injected into ~/Quickemu/nixos-console and ~/Quickemu/nixos-desktop respectively. The console .iso image is also periodically built and published via [GitHub Actions and are available in this project's Releases](https://github.com/ryanwclark1/nix-config/releases).

What's in the box? ๐ŸŽ

Nix is configured with flake support and the unified CLI enabled.

Structure

Here is the directory structure I'm using.

.
โ”œโ”€โ”€ home
โ”‚   โ”œโ”€โ”€ features
โ”‚   โ”‚   โ”œโ”€โ”€ alacritty
โ”‚   โ”‚   โ”œโ”€โ”€ cli
โ”‚   โ”‚   โ”œโ”€โ”€ compression
โ”‚   โ”‚   โ”œโ”€โ”€ desktop
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ common
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ gnome
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ hyprland
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ config
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ hyprland
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ fastfetch
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ pipewire
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ rofi
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ swaync
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ fonts
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ media
โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ wallpapers
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ scripts
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ plasma
โ”‚   โ”‚   โ”œโ”€โ”€ development
โ”‚   โ”‚   โ”œโ”€โ”€ eza
โ”‚   โ”‚   โ”œโ”€โ”€ filesearch
โ”‚   โ”‚   โ”œโ”€โ”€ fzf
โ”‚   โ”‚   โ”œโ”€โ”€ games
โ”‚   โ”‚   โ”œโ”€โ”€ git
โ”‚   โ”‚   โ”œโ”€โ”€ gpu
โ”‚   โ”‚   โ”œโ”€โ”€ helix
โ”‚   โ”‚   โ”œโ”€โ”€ insomnia
โ”‚   โ”‚   โ”œโ”€โ”€ kitty
โ”‚   โ”‚   โ”œโ”€โ”€ kubernetes
โ”‚   โ”‚   โ”œโ”€โ”€ lazygit
โ”‚   โ”‚   โ”œโ”€โ”€ lf
โ”‚   โ”‚   โ”œโ”€โ”€ media
โ”‚   โ”‚   โ”œโ”€โ”€ networking-utils
โ”‚   โ”‚   โ”œโ”€โ”€ nvim
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ plugin
โ”‚   โ”‚   โ”œโ”€โ”€ osint
โ”‚   โ”‚   โ”œโ”€โ”€ pistol
โ”‚   โ”‚   โ”œโ”€โ”€ productivity
โ”‚   โ”‚   โ”œโ”€โ”€ qutebrowser
โ”‚   โ”‚   โ”œโ”€โ”€ shell
โ”‚   โ”‚   โ”œโ”€โ”€ starship
โ”‚   โ”‚   โ”œโ”€โ”€ sys-stats
โ”‚   โ”‚   โ”œโ”€โ”€ vscode
โ”‚   โ”‚   โ”œโ”€โ”€ wezterm
โ”‚   โ”‚   โ”œโ”€โ”€ zellij
โ”‚   โ”‚   โ””โ”€โ”€ zoxide
โ”‚   โ””โ”€โ”€ global
โ”œโ”€โ”€ hosts
โ”‚   โ”œโ”€โ”€ common
โ”‚   โ”‚   โ”œโ”€โ”€ global
โ”‚   โ”‚   โ”œโ”€โ”€ optional
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ displaymanager
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ gnome
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ hyprland
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ pantheon
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ plasma
โ”‚   โ”‚   โ”œโ”€โ”€ users
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ administrator
โ”‚   โ”‚   โ””โ”€โ”€ wallpaper
โ”‚   โ”œโ”€โ”€ frametop
โ”‚   โ”‚   โ””โ”€โ”€ services
โ”‚   โ””โ”€โ”€ woody
โ”‚       โ””โ”€โ”€ services
โ”œโ”€โ”€ lib
โ”œโ”€โ”€ modules
โ”‚   โ”œโ”€โ”€ home-manager
โ”‚   โ””โ”€โ”€ nixos
โ”œโ”€โ”€ overlays
โ”œโ”€โ”€ pkgs
โ”‚   โ”œโ”€โ”€ aichat
โ”‚   โ”œโ”€โ”€ gitkraken
โ”‚   โ”œโ”€โ”€ multiviewer
โ”‚   โ”œโ”€โ”€ nix-inspect
โ”‚   โ”œโ”€โ”€ shellcolord
โ”‚   โ””โ”€โ”€ wallpapers
โ””โ”€โ”€ templates
โ”‚   โ”œโ”€โ”€ c
โ”‚   โ”‚   โ””โ”€โ”€ src
โ”‚   โ”œโ”€โ”€ haskell
โ”‚   โ”‚   โ”œโ”€โ”€ app
โ”‚   โ”‚   โ””โ”€โ”€ src
โ”‚   โ”œโ”€โ”€ node
โ”‚   โ”‚   โ””โ”€โ”€ src
โ”‚   โ””โ”€โ”€ rust
โ”‚       โ””โ”€โ”€ src
โ”œโ”€โ”€ secrets.yaml
โ””โ”€โ”€ flake.nix

The NixOS and Home Manager configurations are in the hosts and home directories respectively The pkgs directory contains my custom packages with package overlays in the overlays directory. The secrets.yaml contains secrets managed by sops-nix. The default.nix files in the root of each directory are the entry points.

The Shell ๐Ÿš

The Desktop ๐Ÿ–ฅ๏ธ

The font configuration is common with both desktops using Work Sans and Fira Code. The usual creature comforts you'd expect to find in a Linux Desktop are integrated such as Pipewire, Bluetooth, Avahi, CUPS, SANE and NetworkManager.

Desktop System Configuration Theme

Alt

Post-install Checklist

Things I currently need to do manually after installation.

Secrets

  • Provision ~/.config/sops/age/keys.txt. Optionally handled by install-system.
  • Add ssh-to-age -i /etc/ssh/ssh_host_ed25519_key.pub to .sops.yaml.
  • Run sops updatekeys secrets/secrets.yaml
  • Run gpg-restore
  • LastPass - authenticate
  • Authy - activate
  • 1Password - authenticate

Services

  • Atuin - atuin login -u <user>
  • Brave - enroll sync
  • Chatterino - authenticate
  • Discord - authenticate
  • GitKraken - authenticate with GitHub
  • Grammarly - authenticate
  • IRCCloud - authenticate
  • Maelstral - maestral_qt
  • Matrix - authenticate
  • Syncthing - Connect API and introduce host
  • Tailscale - sudo tailscale up
  • Telegram - authenticate
  • Keybase - keybase login
  • VSCode - authenticate with GitHub enable sync
  • Wavebox - authenticate Google and restore profile
  • ZeroTier - enable host sudo zerotier-cli info
  • Run fonts.sh to install commercial fonts

Windows Boot Manager on multi-disk systems

One of my desktop (woody) is a multi-disk system with Windows 11 Pro installed on a separate disk from NixOS. The Windows EFI partition is not automatically detected by systemd-boot. The following steps are required to copy the Windows Boot Manager to the NixOS EFI partition.

Find Windows EFI Partition

lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT

Mount Windows EFI Partition

sudo mkdir /mnt/win-efi
sudo mount /dev/nvme1n1p1 /mnt/win-efi

Copy Contents of Windows EFI to NixOS EFI

sudo rsync -av /mnt/win-efi/EFI/Microsoft/ /boot/EFI/Microsoft/

Clean up

sudo umount /mnt/win-efi
sudo rm -rf /mnt/win-efi

Reboot and systemd-boot should now offer the option to boot NixOS and Windows.

TODO ๐Ÿ—’๏ธ

Things I should do or improve:

Shell

  • fzf
  • tmate or tmux
  • git-graph and/or git-igitt integration

Servers

Inspirations ๐Ÿง‘โ€๐Ÿซ

The Disko implementation and automated installation are chasing the ideas outlined in these blog posts: