|
| 1 | +# Development Guide |
| 2 | + |
| 3 | +This document outlines the development workflow for managing and extending these dotfiles. The goal is to maintain a clean, stable, and testable configuration by using a `develop` branch for integration and keeping `main` as a stable release branch. |
| 4 | + |
| 5 | +## Architectural Approach: Declarative Modular Monolith |
| 6 | + |
| 7 | +This project is built on the **declarative nature** of Nix and organized as a **modular monolith**. |
| 8 | + |
| 9 | +- **Declarative**: The core principle of Nix. We do not write scripts that command the system to *do* things (e.g., `apt install htop`). Instead, we write `.nix` files that **declare the desired final state** of the system (e.g., `packages = [ htop ];`). Nix's job is to figure out the steps to make the system match this declaration, ensuring reproducible and reliable environments. |
| 10 | + |
| 11 | +- **Monolith**: The entire user environment is defined as a single, cohesive configuration that is deployed atomically with a single `home-manager switch` command. This ensures the whole system is always in a consistent state. |
| 12 | + |
| 13 | +- **Modular**: Internally, this monolith is broken down into independent modules (e.g., `git.nix`, `zsh.nix`). Each module declaratively defines a specific tool or piece of functionality. This structure makes it easy to manage, update, and understand individual components without affecting the whole. |
| 14 | + |
| 15 | +## Branching and Release Workflow |
| 16 | + |
| 17 | +We use two primary branches to manage changes: |
| 18 | +- `develop`: The main development branch. All new features are integrated here. It should always be functional, but it's where active development happens. |
| 19 | +- `main`: The stable release branch. This branch only receives updates from `develop` when a set of features is complete and considered stable. |
| 20 | + |
| 21 | +### Feature Development (Day-to-Day Cycle) |
| 22 | + |
| 23 | +All new work, from adding a small tool to a big refactor, follows this cycle. |
| 24 | + |
| 25 | +#### 1. Create a New Branch from `develop` |
| 26 | + |
| 27 | +Before starting any work, create your feature branch from the latest version of the **`develop`** branch. |
| 28 | + |
| 29 | +```bash |
| 30 | +# Get the latest version of the develop branch |
| 31 | +git checkout develop |
| 32 | +git pull origin develop |
| 33 | + |
| 34 | +# Create your new feature branch |
| 35 | +git checkout -b feature/add-btop-config |
| 36 | +``` |
| 37 | + |
| 38 | +#### 2. Add New Configurations and Tests |
| 39 | + |
| 40 | +Make your changes to the `.nix` files, preferably by creating a new, self-contained module. |
| 41 | + |
| 42 | +**Crucially, for any new functionality, add a corresponding test** in the `nix_tests` directory. This ensures our CI pipeline can validate your changes automatically. (See the [TEST TEMPLATES](./nix_tests/TEST_TEMPLATES.md) for examples). |
| 43 | + |
| 44 | +#### 3. Commit and Push |
| 45 | + |
| 46 | +Commit your changes to your feature branch and push it to the remote repository. Use a descriptive commit message following the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard. |
| 47 | + |
| 48 | +```bash |
| 49 | +git add . |
| 50 | +git commit -m "feat: Add configuration for btop" |
| 51 | +git push -u origin feature/add-btop-config |
| 52 | +``` |
| 53 | + |
| 54 | +#### 4. Open a Pull Request to `develop` |
| 55 | + |
| 56 | +Go to your repository on GitHub and open a Pull Request (PR) from your feature branch to the **`develop`** branch. |
| 57 | + |
| 58 | +The CI pipeline will run on the PR. After it passes and you are satisfied with the changes, you can merge it into `develop`. |
| 59 | + |
| 60 | +### Releasing to `main` (Promoting to Stable) |
| 61 | + |
| 62 | +Periodically, when the `develop` branch contains a stable and complete set of features, you can create a new "release" on the `main` branch. |
| 63 | + |
| 64 | +1. **Merge `develop` into `main`**: |
| 65 | + ```bash |
| 66 | + # Go to the main branch and make sure it's up to date |
| 67 | + git checkout main |
| 68 | + git pull origin main |
| 69 | + |
| 70 | + # Merge all the changes from develop into main |
| 71 | + git merge develop --no-ff -m "chore(release): Merge develop into main" |
| 72 | + |
| 73 | + # Push the updated main branch |
| 74 | + git push origin main |
| 75 | + ``` |
| 76 | + *(`--no-ff` creates a merge commit, which is good for visualizing the history of releases).* |
| 77 | + |
| 78 | +2. **(Optional) Create a Version Tag**: |
| 79 | + After merging to `main`, it is good practice to create a tag to mark the new version. |
| 80 | + ```bash |
| 81 | + git tag -a v1.1.0 -m "Release v1.1.0" |
| 82 | + git push origin v1.1.0 |
| 83 | + ``` |
0 commit comments