Skip to content

weitanism/nixos-config

Repository files navigation

NixOS Config

This repo has been migrated to ~weitanism/nixos-config.

My personal NixOS flake repo.

Directory Structure

This project is structured as follows:

  • flake.nix: flake file
  • machine: configuration for desktops
  • server: configuration for servers
  • user: configuration for users(home-manager)
  • lib: common utility nix function
  • pkgs: custom packages
  • overlay: overlays

Keybindings

My custom keybinds:

  • Alt-o: app launcher
  • Alt-Shift-q: kill current window/app
  • Alt-h/j/k/l: focus left/lower/upper/right window
  • Alt-Shift-h/j/k/l: move focused window to left/lower/upper/right
  • Alt-[1-9]: switch to workspace [1-9]
  • Alt-p: power menu(lock, poweroff, hibernate, etc.)
  • Alt-Enter: open new terminal
  • Alt-Shift-Enter: open new emacsclient
  • Alt-u: emoji selector

Note: complete list of keybind can be found at user/weitan/i3/config.

Installation Guide

Install to a new machine

  1. Partition, format and mount the disk(copied from NixOS official document):
    # Partition the disk.
    # NOTE: replace /dev/sda with /dev/nvme0n1 if using a SSD.
    parted /dev/sda -- mklabel gpt
    parted /dev/sda -- mkpart primary 512MB -8GB
    parted /dev/sda -- mkpart primary linux-swap -8GB 100%
    parted /dev/sda -- mkpart ESP fat32 1MB 512MB
    parted /dev/sda -- set 3 esp on
    
    # Formatting the disk.
    # NOTE: replace /dev/sdaX with /dev/nvme0n1pX if using a SSD.
    mkfs.ext4 -L nixos /dev/sda1
    mkswap -L swap /dev/sda2
    swapon /dev/sda2
    mkfs.fat -F 32 -n boot /dev/sda3
    mount /dev/disk/by-label/nixos /mnt
    mkdir -p /mnt/boot
    mount /dev/disk/by-label/boot /mnt/boot
        
  2. Run nixos-generate-config --root /mnt to generate hardware configuration
  3. Create config folder for new machine
    # First, drop to a shell with `git` available
    nix-shell -p git
    
    # Clone the repo
    git clone https://github.com/weitanism/nixos-config.git /tmp/nixos
    pushd /tmp/nixos
    # Create machine config directory from template
    cp -a machine/template machine/<your-machine-name>
    # Copy hardware specific config files created in step 2
    cp -a /mnt/etc/nixos/{configuration.nix,hardware-configuration.nix} machine/<your-machine-name>/
    git add machine/<your-machine-name>/
    popd
        
  4. Add a system config entry to nixosConfigurations in flake.nix, example:
    # A system named "framework" with "x86_64" CPU and default username
    # "weitan"(will load user home-manager config defined in
    # `user/weitan/home.nix`).
    (mkSystem {
      hostname = "framework";
      username = "weitan";
      system = "x86_64-linux";
    })
        
  5. Build your system
    nixos-install --flake /tmp/nixos#<your-machine-name>
        
  6. Replace default configuration directory
    rm -r /mnt/etc/nixos
    mv /tmp/nixos /mnt/etc/nixos
        
  7. Reboot

Software Configurations

Software enabled on my laptop for daily work:

  • window manager: i3
  • status bar: polybar
  • editor: Emacs with evil-mode
  • app launcher: rofi

Self-hosted services:

Screenshot

./screenshot.png

Hardware Configurations

  • Framework
    • CPU: 12th Gen Intel i7-1260P (16) @ 4.700GHz
    • Memory: 64GiB
    • Storage: 1TiB SSD
  • ThinkPad X1 Nano Gen 1
    • CPU: 11th Gen Intel i7-1160F7 (8) @ 4.4000GHz
    • Memory: 16GiB
    • Storage: 1TiB SSD
  • VPS(DigitalOcean) for self-hosted services
    • Type: Basic
    • CPU: 1vCPU
    • Memory: 512MB
    • Storage: 0.5TiB SSD