1
Fork 0
mirror of https://github.com/khuedoan/nixos-setup.git synced 2026-06-03 20:49:42 +00:00
Automated NixOS configuration
Find a file
2026-05-03 21:42:19 +07:00
.github/workflows ci: remove custom token 2026-04-25 15:07:01 +07:00
base style: format all Nix code 2026-05-01 09:37:41 +07:00
hosts refactor(codeserver): use OpenCode web instead of VS Code 2026-05-03 21:42:19 +07:00
modules style(gtk): use default dark theme 2026-05-01 15:50:56 +07:00
scripts ci: fix conflicted existing files 2026-04-25 14:37:46 +07:00
.gitignore chore: ignore test VM image 2023-07-19 02:04:06 +07:00
flake.lock chore: upgrade packages 2026-05-03 21:26:56 +07:00
flake.nix refactor: move unstable channel from nixpkgs to nixos 2026-05-02 08:18:16 +07:00
LICENSE.md docs: add license 2024-10-06 00:03:42 +07:00
Makefile build: add format target 2026-05-01 09:37:18 +07:00
README.md docs: testing and acknowledgements 2026-04-25 14:08:53 +07:00

Nix Setup

Monorepo for my Nix-based machine setup across NixOS and macOS (for when I don't have a Linux machine).

Overview

Repository layout:

  • flake.nix: entrypoint
  • hosts/: one per machine, each host sets hostname, username, and imports the modules it needs.
  • base/: shared baseline
  • modules/ composable modules that hosts can mix and match:
    • cli: shared command-line tools and development packages
    • gui: graphical apps and desktop settings for non-headless machines
    • dotfiles: bootstraps my dotfiles repository separately from the base system (moved out of base in case you don't want it)
    • personal: personal-machine configuration
    • work: work-specific packages and configuration
  • Modules follow this pattern:
    • default.nix: entrypoint (Nix convention)
    • darwin.nix: Darwin override
    • linux.nix: Linux override

Customize the configuration

Fork this repo, then:

  • Add a new host to hosts/${HOSTNAME}.nix (or update an existing one) to match your machine and it to flake.nix
  • Customize the host's composable modules
  • Set your username and hostname
  • Replace the SSH public keys and dotfiles repository URLs (if you don't want to use my dotfiles)
  • Replace any host-specific hardware settings
  • Follow installation and usage instruction below
  • Customize the rest of the repo for your needs and clean up things that you don't use

Installation

Review the base, hosts, and modules directories and adjust the configuration to match your machines before installing.

NixOS

Boot into the NixOS live ISO, then install the tools needed for the initial bootstrap:

nix-shell -p git gnumake neovim disko

Clone the repository and run the installer:

git clone https://github.com/khuedoan/nix-setup
cd nix-setup
make install host=HOSTNAME disk=/dev/DISK

Replace HOSTNAME with the host module you want to install and /dev/DISK with the target disk device.

macOS

Before the first run:

  • Update the hostname and primaryUser.username values in hosts/
  • Go to Settings > Privacy & Security > Full Disk Access and allow Terminal

Clone the repository and apply the configuration:

git clone https://github.com/khuedoan/nix-setup
cd nix-setup
make switch host=HOSTNAME

Replace HOSTNAME with the matching entry in flake.nix. The rebuild script installs Nix and Homebrew automatically on a fresh macOS system if they are not already present.

Then reboot.

Usage

Diff the new configuration against the current system profile:

make diff

Apply changes on an installed machine:

make switch

Update packages:

make update

Build a specific host without switching:

make build host=HOSTNAME

Clean up Nix store:

make clean

Testing

GitHub Actions builds all NixOS and Darwin hosts, then applies the test hosts.

You can also test this locally in VMs:

NixOS:

  1. make test

macOS:

  1. Install UTM
  2. Download macOS IPSW recovery file
  3. Create a macOS VM in UTM using the downloaded IPSW file
  4. Run xcode-select --install in the new VM
  5. (Optional) Clone the VM to a new one for easy rollback (UTM doesn't support snapshot yet)
  6. Follow the above steps

Acknowledgements