|
| 1 | +# Aurora-Common Style Guide |
| 2 | + |
| 3 | +This document defines the coding and configuration standards for the aurora-common repository. |
| 4 | + |
| 5 | +## Repository Overview |
| 6 | + |
| 7 | +Aurora-common is a minimal OCI layer containing shared configuration files for Aurora and Aurora-DX variants. It builds on top of projectbluefin/common and contains no compiled code—only configuration files, shell scripts, and Just recipes. |
| 8 | + |
| 9 | +## File Organization |
| 10 | + |
| 11 | +### Directory Structure Standards |
| 12 | + |
| 13 | +**Always maintain the two-tier structure:** |
| 14 | +- `system_files/shared/` - Configuration shared between Aurora and Aurora-DX |
| 15 | +- `system_files/dx/` - Aurora-DX specific configurations (developer experience tools) |
| 16 | + |
| 17 | +**Placement rules:** |
| 18 | +- DX/developer-specific files → `system_files/dx/` |
| 19 | +- Reusable system configurations → `system_files/shared/` |
| 20 | +- When in doubt, prefer `shared/` unless it requires DX-specific functionality |
| 21 | + |
| 22 | +**Preserve target system paths:** |
| 23 | +Files must mirror their final destination paths: |
| 24 | +``` |
| 25 | +system_files/shared/usr/share/ublue-os/just/example.just |
| 26 | +system_files/dx/etc/profile.d/dx-env.sh |
| 27 | +``` |
| 28 | + |
| 29 | +## Shell Scripts (.sh) |
| 30 | + |
| 31 | +### Shebang |
| 32 | +Use `#!/usr/bin/bash` or `#!/usr/bin/env bash` consistently. |
| 33 | + |
| 34 | +### Style |
| 35 | +- Use lowercase for local variables: `local_var="value"` |
| 36 | +- Use UPPERCASE for environment variables: `SETUP_CHECKER_FILE="${HOME}/.local/share/ublue/setup_versioning.json"` |
| 37 | +- Always quote variable expansions: `"${VARIABLE}"` |
| 38 | +- Use `[[ ]]` for conditionals, not `[ ]` |
| 39 | + |
| 40 | +### Example |
| 41 | +```bash |
| 42 | +#!/usr/bin/bash |
| 43 | + |
| 44 | +TARGET_VERSION=1 |
| 45 | +CONFIG_FILE="${HOME}/.config/myapp.conf" |
| 46 | + |
| 47 | +if [[ -f "${CONFIG_FILE}" ]]; then |
| 48 | + echo "Configuration found" |
| 49 | +fi |
| 50 | +``` |
| 51 | + |
| 52 | +### Error Handling |
| 53 | +Include basic error checking for critical operations: |
| 54 | +```bash |
| 55 | +if [[ ! -e "${SETUP_CHECKER_FILE}" ]]; then |
| 56 | + mkdir -p "$(dirname "${SETUP_CHECKER_FILE}")" |
| 57 | + echo "{}" > "${SETUP_CHECKER_FILE}" |
| 58 | +fi |
| 59 | +``` |
| 60 | + |
| 61 | +## Just Recipes (.just) |
| 62 | + |
| 63 | +### File Header |
| 64 | +Start Just files with: |
| 65 | +```just |
| 66 | +# vim: set ft=make : |
| 67 | +``` |
| 68 | + |
| 69 | +### Recipe Naming |
| 70 | +- Use lowercase with hyphens: `toggle-tpm2`, `install-flatpaks` |
| 71 | +- Be descriptive: prefer `configure-nvidia` over `nvidia` |
| 72 | + |
| 73 | +### Recipe Groups |
| 74 | +Organize recipes with group annotations: |
| 75 | +```just |
| 76 | +[group('System')] |
| 77 | +toggle-tpm2: |
| 78 | + @/usr/bin/luks-tpm2-autounlock |
| 79 | +``` |
| 80 | + |
| 81 | +Common groups: `System`, `Apps`, `Update`, `Developer` |
| 82 | + |
| 83 | +### Recipe Documentation |
| 84 | +Add a brief comment above each recipe: |
| 85 | +```just |
| 86 | +# Factory reset this device (experimental) |
| 87 | +[group('System')] |
| 88 | +powerwash: |
| 89 | + #!/usr/bin/bash |
| 90 | + # ... implementation |
| 91 | +``` |
| 92 | + |
| 93 | +### Inline Scripts |
| 94 | +For multi-line recipes, use bash shebang: |
| 95 | +```just |
| 96 | +example-recipe: |
| 97 | + #!/usr/bin/bash |
| 98 | + echo "Step 1" |
| 99 | + echo "Step 2" |
| 100 | +``` |
| 101 | + |
| 102 | +### Settings |
| 103 | +Standard settings for entry-point Just files: |
| 104 | +```just |
| 105 | +set allow-duplicate-recipes := true |
| 106 | +set ignore-comments := true |
| 107 | +``` |
| 108 | + |
| 109 | +## JSON Configuration Files |
| 110 | + |
| 111 | +### Formatting |
| 112 | +- Use **tabs** for indentation (matching existing files) |
| 113 | +- Keep JSON minimal and readable |
| 114 | +- One property per line |
| 115 | + |
| 116 | +### Example |
| 117 | +```json |
| 118 | +{ |
| 119 | + "logo-directory": "/usr/share/ublue-os/aurora-logos/symbols", |
| 120 | + "shuffle-logo": true |
| 121 | +} |
| 122 | +``` |
| 123 | + |
| 124 | +### Validation |
| 125 | +All JSON files must be valid. Check with: |
| 126 | +```bash |
| 127 | +jq . < file.json |
| 128 | +``` |
| 129 | + |
| 130 | +## YAML Configuration Files |
| 131 | + |
| 132 | +### Formatting |
| 133 | +- Use **2 spaces** for indentation |
| 134 | +- Use kebab-case for keys: `yaml-blocklist-paths` |
| 135 | +- Keep files focused on a single configuration purpose |
| 136 | + |
| 137 | +### Example |
| 138 | +```yaml |
| 139 | +yaml-blocklist-paths: |
| 140 | + - /run/host/etc/bazaar/blocklist.yaml |
| 141 | + |
| 142 | +curated-config-paths: |
| 143 | + - /run/host/etc/bazaar/curated.yaml |
| 144 | +``` |
| 145 | +
|
| 146 | +## Containerfile |
| 147 | +
|
| 148 | +### Style |
| 149 | +- Use explicit tags for base images: `FROM docker.io/library/alpine:latest` |
| 150 | +- Use uppercase for Dockerfile instructions: `COPY`, `RUN`, `FROM` |
| 151 | +- Group related `RUN` commands with `&&` for layer efficiency |
| 152 | +- Add line continuations for readability with `\` |
| 153 | + |
| 154 | +### Multi-stage Pattern |
| 155 | +```dockerfile |
| 156 | +FROM docker.io/library/alpine:latest AS build |
| 157 | +RUN apk add just curl |
| 158 | +
|
| 159 | +# Processing steps... |
| 160 | +RUN install -d /out/shared/usr/share && \ |
| 161 | + just --completions bash > /out/shared/usr/share/bash-completion/completions/ujust |
| 162 | +
|
| 163 | +FROM scratch AS ctx |
| 164 | +COPY /system_files/shared /system_files/shared |
| 165 | +COPY /system_files/dx /system_files/dx |
| 166 | +COPY --from=build /out/shared /system_files/shared |
| 167 | +``` |
| 168 | + |
| 169 | +### Comments |
| 170 | +Add comments for non-obvious operations: |
| 171 | +```dockerfile |
| 172 | +# artwork repo points to ~/.local/share for metadata |
| 173 | +RUN sed -i 's|~/\.local/share|/usr/share|' /out/shared/usr/share/backgrounds/aurora/*.xml |
| 174 | +``` |
| 175 | + |
| 176 | +## Homebrew Brewfiles |
| 177 | + |
| 178 | +### Naming Convention |
| 179 | +- Use lowercase with hyphens: `system-flatpaks.Brewfile` |
| 180 | +- Be descriptive: `full-desktop.Brewfile`, `ai-tools.Brewfile` |
| 181 | + |
| 182 | +### Format |
| 183 | +One application per line, grouped by type with comments: |
| 184 | +```ruby |
| 185 | +# Core Applications |
| 186 | +cask "firefox" |
| 187 | +cask "thunderbird" |
| 188 | +
|
| 189 | +# Development Tools |
| 190 | +cask "visual-studio-code" |
| 191 | +``` |
| 192 | + |
| 193 | +### Location |
| 194 | +Place Brewfiles in `system_files/shared/usr/share/ublue-os/homebrew/` |
| 195 | + |
| 196 | +## Git Commit Messages |
| 197 | + |
| 198 | +### Format |
| 199 | +Follow [Conventional Commits](https://www.conventionalcommits.org/): |
| 200 | +``` |
| 201 | +<type>(<scope>): <description> |
| 202 | +
|
| 203 | +[optional body] |
| 204 | +
|
| 205 | +[optional footer(s)] |
| 206 | +``` |
| 207 | + |
| 208 | +### Types |
| 209 | +- `feat:` - New feature or configuration |
| 210 | +- `fix:` - Bug fix |
| 211 | +- `docs:` - Documentation changes |
| 212 | +- `chore:` - Maintenance (dependencies, cleanup) |
| 213 | +- `refactor:` - Code restructuring |
| 214 | +- `ci:` - CI/CD changes |
| 215 | + |
| 216 | +### Scope |
| 217 | +Use meaningful scopes: |
| 218 | +- `just` - Just recipe changes |
| 219 | +- `flatpak` - Flatpak configurations |
| 220 | +- `firefox` - Firefox settings |
| 221 | +- `gnome` - GNOME/desktop settings |
| 222 | +- `setup` - Setup hook scripts |
| 223 | +- `brew` - Homebrew Brewfile changes |
| 224 | +- `dx` - Aurora-DX specific changes |
| 225 | + |
| 226 | +### Examples |
| 227 | +``` |
| 228 | +feat(flatpak): add VSCode Wayland support override |
| 229 | + |
| 230 | +fix(just): correct path to system-flatpaks Brewfile |
| 231 | + |
| 232 | +docs(readme): update directory structure documentation |
| 233 | + |
| 234 | +chore(deps): update aurora-wallpapers to latest |
| 235 | + |
| 236 | +feat(dx): add development environment configuration |
| 237 | +``` |
| 238 | +
|
| 239 | +### AI Attribution |
| 240 | +AI-assisted commits must include attribution: |
| 241 | +``` |
| 242 | +feat(just): add new system management recipe |
| 243 | + |
| 244 | +Assisted-by: Claude 3.5 Sonnet via GitHub Copilot |
| 245 | +``` |
| 246 | +
|
| 247 | +## Comments and Documentation |
| 248 | +
|
| 249 | +### When to Comment |
| 250 | +- Configuration files: Explain non-obvious settings |
| 251 | +- Shell scripts: Document complex logic or version-based behavior |
| 252 | +- Just recipes: Brief description of what the recipe does |
| 253 | +- Containerfile: Clarify transformations or path changes |
| 254 | +
|
| 255 | +### When NOT to Comment |
| 256 | +- Self-explanatory code |
| 257 | +- Simple variable assignments |
| 258 | +- Standard patterns |
| 259 | +
|
| 260 | +### Example - Good Comments |
| 261 | +```bash |
| 262 | +# Meant to be used at the start of any setup service script |
| 263 | +# Will version your script accordingly on $SETUP_CHECKER_FILE |
| 264 | +function version-script() { |
| 265 | + # ... implementation |
| 266 | +} |
| 267 | +``` |
| 268 | + |
| 269 | +## File Permissions |
| 270 | + |
| 271 | +### Executable Scripts |
| 272 | +Scripts intended to be executed must be executable: |
| 273 | +```bash |
| 274 | +chmod +x system_files/shared/usr/bin/ublue-image-info.sh |
| 275 | +``` |
| 276 | + |
| 277 | +### Configuration Files |
| 278 | +Non-executable files (JSON, YAML, text) should be 644: |
| 279 | +```bash |
| 280 | +chmod 644 system_files/shared/etc/ublue-os/fastfetch.json |
| 281 | +``` |
| 282 | + |
| 283 | +## Testing and Validation |
| 284 | + |
| 285 | +### Local Build Testing |
| 286 | +Always test builds locally before pushing: |
| 287 | +```bash |
| 288 | +just build |
| 289 | +``` |
| 290 | + |
| 291 | +### Syntax Validation |
| 292 | +- **Just files**: `just check` |
| 293 | +- **JSON files**: `find system_files -name "*.json" -exec jq . {} \;` |
| 294 | +- **Shell scripts**: `bash -n script.sh` |
| 295 | + |
| 296 | +### Structure Inspection |
| 297 | +Verify the built image structure: |
| 298 | +```bash |
| 299 | +just tree |
| 300 | +``` |
| 301 | + |
| 302 | +## Pull Request Guidelines |
| 303 | + |
| 304 | +### PR Title |
| 305 | +Use conventional commit format: |
| 306 | +``` |
| 307 | +feat(flatpak): add system flatpak overrides for Bazaar |
| 308 | +``` |
| 309 | + |
| 310 | +### PR Description |
| 311 | +Include: |
| 312 | +1. What changed |
| 313 | +2. Why it changed |
| 314 | +3. Testing performed (local build, validation) |
| 315 | + |
| 316 | +### Changes |
| 317 | +- Keep PRs focused on a single logical change |
| 318 | +- Maintain existing file structure |
| 319 | +- Don't mix refactoring with feature changes |
| 320 | + |
| 321 | +## Naming Conventions |
| 322 | + |
| 323 | +### Files |
| 324 | +- **Just recipes**: lowercase with hyphens (`system.just`, `toggle-tpm2`) |
| 325 | +- **Shell scripts**: lowercase with hyphens (`libsetup.sh`, `ublue-image-info.sh`) |
| 326 | +- **Config files**: lowercase with hyphens or dots (`fastfetch.json`, `mimeapps.list`) |
| 327 | +- **Brewfiles**: descriptive with hyphens (`system-flatpaks.Brewfile`, `full-desktop.Brewfile`) |
| 328 | + |
| 329 | +### Variables (Shell) |
| 330 | +- Local: `lowercase_with_underscores` |
| 331 | +- Environment: `UPPERCASE_WITH_UNDERSCORES` |
| 332 | +- Consistent naming: `TARGET_VERSION`, `SETUP_CHECKER_FILE` |
| 333 | + |
| 334 | +### Functions (Shell) |
| 335 | +- Use lowercase with hyphens: `version-script` |
| 336 | +- Be descriptive: `check-version`, `install-flatpaks` |
| 337 | + |
| 338 | +## What NOT to Do |
| 339 | + |
| 340 | +❌ **Don't add complex build dependencies** - This repo is intentionally minimal |
| 341 | +❌ **Don't compile code** - This is a configuration-only layer |
| 342 | +❌ **Don't modify the scratch→ctx build pattern** - It's essential for the OCI layer |
| 343 | +❌ **Don't add linters/formatters** - Keep tooling minimal (Just, jq, bash only) |
| 344 | +❌ **Don't break existing directory structure** - Maintain `shared/` vs `dx/` separation |
| 345 | +❌ **Don't add unnecessary comments** - Comment only when clarification is needed |
| 346 | + |
| 347 | +## Editor Configuration |
| 348 | + |
| 349 | +### Vim Modelines |
| 350 | +Include for Just files: |
| 351 | +```just |
| 352 | +# vim: set ft=make : |
| 353 | +``` |
| 354 | + |
| 355 | +### Recommended Settings |
| 356 | +- **Tabs for JSON**: 1 tab = indentation unit |
| 357 | +- **Spaces for YAML**: 2 spaces per level |
| 358 | +- **Shell scripts**: 2 or 4 space indentation (be consistent within file) |
| 359 | +- **Just recipes**: 4 space indentation |
| 360 | + |
| 361 | +## Consistency Principles |
| 362 | + |
| 363 | +1. **Follow existing patterns** - Look at similar files in the repo |
| 364 | +2. **Mirror destination paths** - Maintain the target filesystem structure |
| 365 | +3. **Keep it simple** - This is intentionally a minimal repository |
| 366 | +4. **Validate before committing** - Run local builds and syntax checks |
| 367 | +5. **Preserve the two-tier structure** - `shared/` vs `dx/` is fundamental |
| 368 | + |
| 369 | +## Questions? |
| 370 | + |
| 371 | +When unsure about where a file belongs or how to structure it: |
| 372 | +1. Check similar existing files in the repository |
| 373 | +2. Refer to `AGENTS.md` for detailed repository context |
| 374 | +3. Default to simplicity and existing patterns |
| 375 | +4. Ask in pull request reviews |
0 commit comments