Skip to content
Proyectos

Acerca de

~ 🍭 ~

Herramientas de desarrollo

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
0
in 7 days
0
in 15 days
+1
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

~ 🍭 ~

built with nix

A personal workstation setup for Unix machines, built with a Nix flake.

This repository is the single source of truth for most of my system configuration. It covers operating system settings, packages, shell, editor, terminal, automation, mail, and daily development tools. The main target is macOS on Apple Silicon, with nix-darwin and Home Manager. There is also an experimental NixOS host.

It is a personal setup first, but I keep the structure reusable:

  • Hosts are made from small feature modules.
  • App configs are in config/.
  • One nix run command bootstraps a new machine.

screenshot

Font is Pragmata Pro, theme is my own fork of vim-colors-plain, Terminal is Rex.

[!NOTE]

Pragmata Pro is a commercial font. This repository does not include it. By default, the flake expects the PragmataPro.zip and PragmataPro-Variable.zip archives in the Nix store. To skip them for one run, pass --without-pragmatapro to bootstrap. See Font prerequisite.

What this repo manages

The repository has two main parts: reusable Nix modules in nix/, and application configuration in config/. It manages these areas:

Area What is configured here
System management Nix, flake-parts, Home Manager, nix-darwin, host definitions, overlays, and small custom packages
Shell and terminal Zsh, tmux, Rex, Kitty, the mx session launcher, direnv, zoxide, eza, fzf, bat, ripgrep, and Yazi
Editor and coding tools Neovim, formatters, language servers, and Node/Bun/Python/Go/Rust tools
Source control Git, Jujutsu, gh, tig, and delta
macOS automation Hammerspoon, Karabiner-Elements, SketchyBar, system defaults, and window management
Mail and communication aerc, isync/mbsync, msmtp, and pass
Browser Violentmonkey userscripts and Stylus userstyles, served on localhost
Notes and media zk, markdown-oxide, qmd, Neovim notes workflow, mpv, and yt-dlp
AI / agent tooling Claude, Pi, Codex, sb, the zh agent shell history, and related llm-agents tools and config

Codex

  • The Codex defaults are a symlink from config/codex/config.toml to /etc/codex/config.toml.
  • Hooks and themes stay in ~/.config/codex. Codex can write per-user settings to ~/.config/codex/config.toml.
  • Nix makes hooks.json with the absolute paths of the repository info hook and the resume hook. After you edit the hook template, rebuild.

Pi

  • Pi's configuration covers native tools, display settings, and model setup.
  • Each Pi extension is in its own directory, with an index.ts entrypoint.
  • The /simplify command runs four cleanup reviewers in parallel over the codebase. It sends their findings to the current agent, which applies the fixes.

Agent skills

  • Agent skills that Claude, Pi, and Codex share are in config/agents/skills.
  • Skills for one harness only are in config/<harness>/skills.

Supported targets

The flake has these targets:

System Status Hosts
aarch64-darwin Primary target, actively used on Apple Silicon macOS rocket, alcantara
x86_64-linux Experimental NixOS host nixos

If you do not give a host to bootstrap, the scripts use $(hostname -s).

Repository layout

These are the top-level directories:

Path Purpose
config/ Application configs for Neovim, tmux, git, Rex, Kitty, Yazi, aerc, Hammerspoon, Karabiner, Claude, Pi, and more
nix/ Flake composition, reusable modules, host definitions, overlays, custom packages, and encrypted or private files
scripts/ Bootstrap, doctor, and test-bootstrap scripts, packaged as flake apps. See scripts.
tests/ Offline checks that nix flake check runs, and live E2E tests. See tests.
templates/ Small flake templates to start new projects

These are the important parts of nix/:

Path Purpose
nix/parts/flake/ Flake-parts imports, the feature list that every host enables, and the host builders
nix/parts/hosts/ Host definitions, one for each machine
nix/parts/modules/base/ Identity, user, and Home Manager options that every host shares
nix/parts/modules/shared/ Reusable features such as shell, git, vim, mail, yazi, ai, node, and python
nix/parts/modules/darwin/ macOS-only modules such as defaults, Hammerspoon, Karabiner, and SketchyBar
nix/parts/outputs/ Flake outputs such as apps, packages, checks, templates, overlays, formatter, and dev shells. See outputs.
nix/pkgs/ Small custom packages and overrides that the configuration uses
nix/secrets/ age-encrypted or private inputs that the setup uses

How hosts and features connect:

  • Every host enables one shared feature list: commonFeatures in nix/parts/flake/lib.nix. Examples are shell, git, vim, mail, and ai.
  • Darwin hosts also get defaults.
  • The flake adds the matching system and Home Manager modules for each feature.
  • A host file supplies only its own settings, through mk-host.nix.

Installation

1. Install Nix

I use the Nix installer from the NixOS project:

[!WARNING]

Before you install, read the quirks section.

curl --proto '=https' --tlsv1.2 -sSfL https://artifacts.nixos.org/nix-installer | sh -s -- install

2. Font prerequisite

This setup installs Pragmata Pro through a custom Nix package that uses requireFile. If you own the font, add the two archives (static and variable) to the Nix store before the first rebuild:

nix-store --add-fixed sha256 /path/to/PragmataPro.zip
nix-store --add-fixed sha256 /path/to/PragmataPro-Variable.zip

To bootstrap before you add the archives, skip the font for that run:

nix --experimental-features 'nix-command flakes' run 'github:ahmedelgabri/dotfiles' -- alcantara --without-pragmatapro

How the flag works:

  • Pragmata Pro stays enabled by default.
  • The flag selects the <host>-without-pragmatapro configuration. It does not edit the checkout or save a preference.
  • A later bootstrap or rebuild with the normal host adds the font again, and needs the archives.
  • The other fonts stay installed.

3. Bootstrap a machine

Run the repository directly from GitHub:

nix --experimental-features 'nix-command flakes' run 'github:ahmedelgabri/dotfiles' -- <host>

[!IMPORTANT]

The value after -- is the host name for the bootstrap app. It is not a flake reference like .#rocket.

The host is the flake attribute (for example, rocket). It does not depend on the hostname of the machine, because MDM can rename a managed machine at any time. If you do not give a host, bootstrap uses $(hostname -s). Thus, on a managed machine, always give the host.

Examples:

# macOS hosts
nix --experimental-features 'nix-command flakes' run 'github:ahmedelgabri/dotfiles' -- rocket
nix --experimental-features 'nix-command flakes' run 'github:ahmedelgabri/dotfiles' -- alcantara

# NixOS host
nix --experimental-features 'nix-command flakes' run 'github:ahmedelgabri/dotfiles' -- nixos

The bootstrap app does these steps:

  1. It uses ~/.dotfiles if that directory has a flake.nix. If not, it uses the flake source that started it.
  2. It applies the selected host configuration.
  3. On the first run, it clones the repository into ~/.dotfiles for later rebuilds. On later runs, it uses the local clone as it is.
  4. It runs doctor to show the setup that is still necessary.

Each platform has some more steps:

Platform Behavior
macOS (aarch64-darwin) Installs the Xcode Command Line Tools if they are missing, and Rosetta if necessary. Moves the /etc/nix/nix.conf of the Nix installer to nix.conf.before-nix-darwin, because nix-darwin does not overwrite it. Then switches the system with nix-darwin.
Linux (x86_64-linux) Needs nixos-rebuild to be available. Then switches the system with nixos-rebuild.

Checking what is left

You set up SSH keys, GPG keys, and the pass store by hand after bootstrap. To see what is still missing, run nix run ~/.dotfiles#doctor. For the list of checks, see scripts.

4. Rebuild after the first install

After the first install, rebuild from the local clone in ~/.dotfiles.

macOS

cd ~/.dotfiles
nixup # runs `nix flake update` and updates the pi extension type pins
nixsw # runs `darwin-rebuild switch --flake .#<host>`

The same rebuild as a manual command:

darwin-rebuild switch --flake ~/.dotfiles#<host>

NixOS

cd ~/.dotfiles
nixup # optional: runs `nix flake update`
sudo nixos-rebuild switch --flake .#nixos

Homebrew on macOS

I use Homebrew mainly for GUI apps.

  • Nix and Home Manager support for GUI apps on macOS is awkward, especially the symlinks into Applications/.
  • The configuration declares Homebrew too. nix-homebrew installs and controls it, not a manual install.
  • Homebrew also supplies some macOS-only dependencies that are awkward to get through Nix alone. An example is Tart, which the sb sandbox helper uses.

Tap trust:

  • Each macOS host trusts its configured homebrew.taps through nix-homebrew.trust.taps. Homebrew's trust checks stay enabled.
  • The AI module declares openai/tools for Tart on both hosts. Only rocket adds the JetBrains and Docker taps.
  • When you remove a tap from the configuration, Homebrew still trusts it. To revoke the trust, run brew untrust <tap>.

Machine-local configuration

Some values do not belong in Git. This repository keeps them outside the tracked tree, and loads them from a location for each host.

Home Manager sets a config directory for each host under ${XDG_DATA_HOME}. My shell exports that path as $HOST_CONFIGS. Usually, it is:

$HOST_CONFIGS = ~/.local/share/<host>

You can make these files there:

Path Purpose Example
$HOST_CONFIGS/zshrc Machine-local shell setup. Keep tokens in the keychain (secret set <name>), and export them as lookups, never as literal values. export GITHUB_TOKEN="$(secret get github-token)"
$HOST_CONFIGS/gitconfig Local Git settings that you must not commit, especially the GPG signing details [user] signingkey =
$HOST_CONFIGS/hammerspoon/<host>.lua Machine-specific Hammerspoon additions, loaded with the config in config/.hammerspoon/. <host> is the logical host name from ~/.local/share/host-name, not the machine hostname. Host-specific Lua config
$HOST_CONFIGS/tmux.conf Machine-local tmux settings, sourced at the end of the repository tmux.conf Host-specific key bindings
$HOST_CONFIGS/nvimrc.lua Machine-local Neovim overrides, sourced at the end of the repository init.lua Host-specific options
$HOST_CONFIGS/snippets Machine-local snippets in VS Code format, loaded by LuaSnip Private snippets
$HOST_CONFIGS/mx/sessions/<name>.lua Host-local mx session definitions. They have priority over ~/.config/mx/sessions/. See nix/pkgs/mx/README.md. Private session

For GitHub to show commits as Verified, these three emails must be the same: the email on the commit, the email on GitHub, and the email of the public key.

Also do these steps:

  • Make SSH keys.
  • Import or make your GPG keys.
  • If you sign commits, upload the public GPG key to GitHub.

Secrets and private data

This repository includes agenix, but I do not use it as the source of truth for important secrets.

The general rule:

  • I make or import truly sensitive credentials on each machine, and keep them in pass.
  • I use agenix only for lower-risk private files that must stay out of the public repository.

Email setup

Mail is one of the more opinionated parts of this setup.

The stack:

Component Role
isync / mbsync Synchronizes mail
aerc Mail client
msmtp Sends outgoing mail
pass Stores credentials

The mail module has service defaults for:

Service
fastmail.com
gmail.com
cirrux.me

Each account has one of two modes:

Mode Behavior
local Mail syncs to local Maildir folders
remote aerc connects directly to the remote service

Account options:

Option Effect
aliases Other addresses that are yours. They can use fnmatch wildcards, such as *@example.com for a catch-all domain. aerc replies from the alias that got the mail, and leaves the aliases out of reply-all.
color Default blue. aerc shows unread mail sent to the email domain of the account in this color, through a generated styleset for each account.

Gmail archive: on a synced Gmail account, A deletes the message from the local INBOX. It does not move the message to an Archive folder. mbsync sends this to Gmail as the removal of the INBOX label, which is how Gmail archives. The message stays in All Mail.

Immediate sync:

  • When at least one account is local, aerc hooks run mailsync-now after moves, flag changes, sends, and on quit. Thus changes get to the server before the next timer run.
  • Hosts with only remote accounts have no sync job, so they get no such hooks.

When local accounts are enabled, synchronization runs automatically every 2 minutes:

Platform Scheduler
macOS launchd
NixOS systemd --user timer

Authentication

Each account needs authentication for IMAP and SMTP. Some services also need more credentials for JMAP or CardDAV.

The module reads passwords from pass. For an account named Foo, it expects entries under the account name in lowercase:

Entry Used for
service/email/foo/password IMAP/SMTP password
service/email/foo/source Fastmail/JMAP source access
service/email/foo/outgoing Fastmail/JMAP outgoing access
service/email/foo/contacts Fastmail/CardDAV access

If two-factor authentication is enabled, use an app-specific password where necessary.

Flake templates

This repository also exports some project templates from templates/.

To use a template:

nix flake init --template 'github:ahmedelgabri/dotfiles#<template name>'

To make the project in a new directory:

nix flake init --template 'github:ahmedelgabri/dotfiles#<template name>' ./my-project

You can use -t as a short form of --template.

Available templates:

Template Description
default Empty flake template
node Simple Node / JS / TS template using pnpm
deno Simple Deno template
bun Simple Bun template
python Simple Python project template
python-script Simple one-off Python script template using uv script mode
go Simple Go template
rust Simple Rust template

Color system

The plain-dark and plain-light terminal themes are the source of truth for colors.

  • Kitty follows the OS appearance.
  • Terminal applications use named ANSI slots. They do not embed their own truecolor or xterm-256 palettes.
  • Thus bat, delta, Jujutsu, LS_COLORS/eza, fzf, Yazi, aerc, tig, tmux, and the Zsh prompt stay in sync automatically.
  • The custom Neovim plain theme uses the same accents. It adds the structural shades that an editor needs.

bat and delta show syntax through a custom plain.tmTheme, with bat's ANSI color encoding. The theme follows the same restraint as the Neovim theme: gray italic comments, blue strings and constants, and the default foreground for everything else. Each Home Manager activation rebuilds the bat cache, so a rebuild gets theme changes. For an immediate refresh, run bat cache --build.

File listing colors come from one file, config/zsh.d/ls_colors. user-shell.nix splits it when it builds:

  • Lines with the eza: prefix become EZA_COLORS. These are eza-only UI keys, plus reset, which turns off the built-in filetype styles of eza.
  • The other lines become LS_COLORS.

Thus eza, ls, fd, and zsh completions show files in the same colors. The file header explains the SGR syntax and the groups. To add a color for a new extension, edit one line.

The palettes:

  • The dark palette is a restrained Tomorrow Night derivative.
  • The light palette uses the matching Tomorrow family hues. Its green, yellow, and cyan are darker, so colored text stays readable on #fafafa.
  • ANSI bright black is the shared muted color.
  • Red, green, and yellow keep their error, success, and warning meanings everywhere.

How light/dark switching works

The macOS appearance is the only switch:

  • Kitty resolves its *-theme.auto.conf symlinks.
  • Neovim reads AppleInterfaceStyle on startup and on FocusGained. It sets background, which loads plain.lua again.
  • tmux 3.8 finds the mode of the terminal and changes the palette of its theme* colours (see config/tmux).

No other tool listens for appearance changes. All other tools only send ANSI indices. When the terminal palette changes, the terminal draws all text again, also the output that is already on screen.

Slot conventions

  • Slot 0 (black) is subtle structure: tmux pane borders and ⦁ separators, and the aerc scrollbar and selection strips. Its dark value is #303030, intentionally lighter than near-black, because near-black is invisible on the #111111 background. Use this slot to control how visible the chrome is.
  • Slot 8 (bright black) is dim text: status line text, comments, and secondary information.
  • Red, green, and yellow keep their error, success, and warning meanings everywhere. Blue marks constants, strings, and links. Everything that is not a signal uses the default foreground.
  • Delta (the [delta] section) shows added and removed lines like Neovim diff windows:
    • The full line is green or red, on slot 16 or 17. These slots hold the DiffAdd and DiffDelete backgrounds of Neovim.
    • Deleted lines are struck through.
    • A line style with its own foreground turns off delta's syntax highlighting on that line. Thus only context lines use plain.tmTheme. Neovim diff windows also do not syntax-highlight changed lines.
    • Word-level emphasis is off, as in Neovim and Jujutsu.

Sync points

Some files have their own copy of the palette, because they cannot refer to each other. When you change one, change all of them:

What Where
Full palettes (slots 0-15, plus the diff-tint slots 16-18 that hold the DiffAdd/Delete/Change backgrounds of Neovim) config/kitty/themes/plain-dark.conf and plain-light.conf. Also terminal_palettes in plain.lua, with slots 0-15 only, because :terminal cannot remap higher slots.
Editor accents The themes table in plain.lua has the same accent hexes as the terminal. It also has editor-only structural shades and diff and conflict backgrounds.
Syntax restraint rules The treesitter groups in plain.lua and the scopes in plain.tmTheme give the same rules for Neovim and for bat/delta. Activation rebuilds the bat cache automatically. For an immediate refresh, run bat cache --build.
Comment markers (TODO/FIXME/…) mini.hipatterns extmarks, configured in plugin/mini.lua, paint the markers. The MiniHipatterns* groups style them, and link to @comment.* in plain.lua. Style markers through those groups, not through treesitter only.
SketchyBar colors palette_hex in segments.sh copies the dark accent hexes. The bar has no light mode.

Working on this repo

The flake has some outputs that help when you edit this repository:

Command What it does
nix develop Opens the default development shell, including Python, Ruff, and ty
nix fmt Formats the Nix code with nixfmt-rs
nix develop .#go Opens the Go dev shell
nix develop .#rust Opens the Rust dev shell, with jj, git, and zsh for the zh tests
nix build .#<host> Builds the system of a darwin host, but does not switch to it
nix run .#lint Runs every repository check that CI runs: formatting, dead-code, type, shell, spelling, workflow, test, Go, Rust, and host evaluation checks, plus the zizmor online audits
nix run .#test-bootstrap Bootstraps a host in a disposable macOS VM. See scripts.
nix run .#sb Runs the sb sandbox VM helper (macOS)

All Python files, including the interactive startup script, use the strict Ruff and ty settings in pyproject.toml. For the local commands and the documented rule exceptions, see Python checks and tests.

Explorar proyectos relacionados

Cargando…