configs, probably doesn't have secrets committed
  • Nix 58%
  • Lua 31.9%
  • Vim Script 5.1%
  • Shell 4.7%
  • Python 0.3%
Find a file
2026-08-17 18:57:26 -05:00
dev add kolourpaint 2026-07-26 17:17:49 -05:00
home-manager add kolourpaint 2026-07-26 17:17:49 -05:00
hosts add relay cloud vm host 2026-08-17 18:57:26 -05:00
modules update nixpkgs, packages 2026-07-05 19:56:06 -05:00
overlays cleanup and overlay notes 2026-06-20 16:11:32 -05:00
pkgs cleanup and overlay notes 2026-06-20 16:11:32 -05:00
scripts add clang install script 2025-09-20 18:16:41 -05:00
flake.lock add relay cloud vm host 2026-08-17 18:57:26 -05:00
flake.nix add relay cloud vm host 2026-08-17 18:57:26 -05:00
gc_log.md update nixpkgs, packages 2026-07-05 19:56:06 -05:00
README.md update nixpkgs, packages 2026-07-05 19:56:06 -05:00
switch.sh regenerate laptop hardware-configuration.nix, comments 2026-06-20 16:11:32 -05:00

NixOS Config

Usage

  • jj or git add any new files
  • nh
nh os switch .
nh home switch .

Setup

# 1. Install nix, enable flakes
export NIX_CONFIG="experimental-features = nix-command flakes"

# 2. Generate host config `/etc/nixos/{configuration.nix, hardware-configuration.nix}`
sudo nixos-generate-config
cp ~/etc/nixos/hardware-configuration ./hosts/<HOST>/hardware-configuration

# 3. Switch to config
nix-shell -p home-manager
HOST=<HOSTNAME> USER=<USERNAME> ./switch.sh

Organization

  • .#xiej@WORKING-DESKTOP
  • .#xiej@WORKING-LAPTOP

Notes

nix commands

nix flake check
nix flake update

# generate /etc/nixos/{configuration.nix, hardware-configuration.nix}
sudo nixos-generate-config

# apply system configuration
# {switch, boot, test}
sudo nixos-rebuild switch --flake .#{hostname}
# apply home configuration
home-manager switch --flake .#username@hostname

# old configurations
home-manager generations
# switch to old generation
/nix/store/{hash}-home-manager-generation/activate

# launch shell with output of flake
nix-shell -p {package}
nix shell nixpkgs#{package}
# create shell with buildInputs and env variables
nix develop nixpkgs#{package}
# create shell with output of .#devShells.<system>.default or packages.<system>.default
nix develop
# use flake > .envrc => loads devShells.default
# run program
nix run nixpkgs#{package}

# collect garbage
sudo nix-collect-garbage --delete-older-than 30d
# optimize nix store
sudo nix-store --optimise
# /boot/kernels full of old generations: collect garbage then nh os switch .

nh commands

nh os switch . -H <HOSTNAME>
nh home switch .

nh os switch --update .
nh home switch --update .

nh search <pkg>
nh clean

error booting grub /etf/Microsoft/... not found
  • make sure fast boot disabled, windows isn't in hibernate

Custom Components

Packages

Add a derivation inside pkgs under pkgs/{package name}/default.nix, and call it with pkgs.callPackage in pkgs/default.nix.

Nixpkgs Reference Manual

Overlays

See overlays/default.nix. Use overlays to patch across the entire nixpkgs, e.g. set compile options for a library, but requires compiling everything depending on it.

Nix Overlays

Overrides

Prefer overrides when possible for making a change to a single package.

Nix Overriding

Modules

Custom modules with options/configurations go under modules/nixos or modules/home-manager. Add to modules/nixos/default.nix or modules/home-manager/default.nix.

NixOS Modules

WSL

NixOS-WSL

Documentation

  1. Enable WSL

    wsl --install --no-distribution
    
  2. Download nixos-wsl.tar.gz.

  3. Import

    wsl --import NixOS --version 2 $env:USERPROFILE\NixOS\ nixos-wsl.tar.gz
    
  4. Run

    wsl -d NixOS
    

distrobox

distrobox create -n ubuntu -i ubuntu:latest -H ~/ubuntu
distrobox create -n ubuntu -i ubuntu:latest -H ~/ubuntu --additional-packages "systemd libpam-systemd pipewire-audio-client-libraries"
distrobox enter ubuntu

nvim subtree

Submodules don't work with flakes, using subtree for nvim-config.

git subtree pull --prefix home-manager/nvim-config https://github.com/xiej2520/nvim_config main --squash
git subtree push --prefix home-manager/nvim-config https://github.com/xiej2520/nvim_config main
git push https://github.com/xiej2520/nvim_config `git subtree split --prefix=home-manager/nvim_config main`:forcepush --force

References