The goal of this repository is to manage distinct systems using a single Git repository and Flake:
- MacBook Pro 14 (macOS): Hostname
mbp-14. Uses Home Manager (standalone) to manage user tools and dotfiles. - HP Z2 Mini G1a (NixOS): Hostname
z2-mini. Uses NixOS for system configuration and Home Manager (as a module) for user configuration.
Key Philosophy: "Write once, run everywhere" for user tools (Neovim, Zsh, Git, etc.), while keeping system-specific configurations (disk mounts, networking, macOS settings) separate.
This repository uses a modular structure to maximize code reuse:
.
├── .envrc # Direnv configuration (auto-loads dev shell)
├── .pre-commit-config.yaml # Code formatting and linting rules
├── flake.nix # Entry point for all systems
├── flake.lock
├── modules/
│ └── home/
│ ├── default.nix # Imports all common modules
│ ├── core.nix # Shells, Git, common packages
│ ├── neovim.nix # Neovim config
│ └── gui.nix # GUI tools (Ghostty, etc.)
├── hosts/
│ ├── mbp-14/ # macOS specific configs (MacBook Pro 14)
│ │ └── home.nix # macOS-specific home overrides
│ └── z2-mini/ # NixOS specific configs (HP Z2 Mini G1a)
│ ├── configuration.nix# System-level config
│ ├── hardware-configuration.nix
│ └── home.nix # NixOS-specific home overrides
The flake.nix produces two types of outputs:
nixosConfigurations: For thez2-minimachine.homeConfigurations: For thembp-14machine.
Concept:
- Shared Inputs: Both systems share
nixpkgsversions viaflake.lock. - NixOS (
z2-mini): Implements Home Manager as a system module for atomic updates. - macOS (
mbp-14): Uses Home Manager in standalone mode.
modules/home/core.nix: Contains the bulk of user configuration (Packages, Shells, Git, etc.).- Host Specifics:
home.usernameandhome.homeDirectoryare defined inhosts/<machine>/home.nixto allow portability.
You can run Home Manager using nix run without installing the home-manager CLI tool globally.
# From local source
$ nix run home-manager/master -- switch --flake .#wjkoh@mbp-14
# Directly from GitHub (useful for bootstrapping)
$ nix run home-manager/master -- switch --flake github:wjkoh/nix-config#wjkoh@mbp-14# From local source
# nixos-rebuild switch --flake .#z2-mini
# Directly from GitHub
# nixos-rebuild switch --flake github:wjkoh/nix-config#z2-mini- Single Source of Truth: Change configuration once, propagate to all machines.
- Shared Lockfile: Ensures identical tool versions across macOS and Linux.
- Atomic Updates: On NixOS, system and user configs update synchronously.
After applying the configuration, some manual steps are required:
- macOS (
mbp-14): Install Tailscale manually via the Mac App Store or as a standalone app. - NixOS (
z2-mini): Tailscale is managed as a system service. Runsudo tailscale upto authenticate.
On both systems, you must authenticate manually to use gcloud and application default credentials:
$ gcloud auth login
$ gcloud auth application-default login