Skip to content

feat(config): add appropriate default directories for non-Linux platforms - #900

Merged
foxcpp merged 1 commit into
foxcpp:masterfrom
AdamMagued:feat/non-linux-default-directories
Nov 15, 2026
Merged

foxcpp merged 1 commit into
foxcpp:masterfrom
AdamMagued:feat/non-linux-default-directories

Conversation

@AdamMagued

Copy link
Copy Markdown
Contributor

This change introduces platform-specific directory defaults for Windows and Darwin/BSD systems, addressing #290.

Summary of changes

  • directories_windows.go: Define Windows directory defaults with %ProgramData%\\maddy for config, %ProgramData%\\maddy\\data for state, %ProgramData%\\maddy\\run for runtime, and %ProgramFiles%\\maddy for libexec; fallback to C:\\ roots if environment variables are absent, and preserve build-time -ldflags -X overrides
  • directories_bsd.go: Configure BSD and Darwin defaults targeting /var/run/maddy for runtime directory (as /run is unavailable on macOS and BSD systems) and /usr/local/lib/maddy for libexec
  • directories.go: Restrict Linux/Unix fallback defaults with updated build tags excluding Windows and BSD/Darwin targets
  • signal_nonposix.go: Update handleSignals signature to return bool so non-posix builds compile cleanly within the reload loop
  • directories_test.go: Add test asserting non-empty directory variables and matching paths per platform
  • directories_windows_test.go: Add unit tests for Windows environment path resolution, fallbacks, and linker overrides

Fixes #290

Assisted-by: Gemini CLI Agent (gemini-2.5-pro)

lmk if you need any adjustments

Comment thread directories_bsd.go Resolved
Comment thread directories_windows.go Resolved
@foxcpp foxcpp moved this from First Feedback Needed to Changes Needed in Maddy Mail Server PR Review Nov 11, 2026
…orms

Introduce platform-specific directory defaults for Windows and Darwin/BSD:
- Windows: default configuration in %ProgramData%\maddy, state in %ProgramData%\maddy\data, runtime in %ProgramData%\maddy\run, and libexec in %ProgramFiles%\maddy with C:\ fallback helpers
- Darwin / BSD: default runtime directory to /var/run/maddy (since /run does not exist) and libexec to /usr/lib/maddy
- Fix handleSignals signature in signal_nonposix.go to allow non-posix compilation in reload loop
- Add unit tests verifying default directory constants and Windows path helper logic

Fixes foxcpp#290
Assisted-by: Gemini CLI Agent (gemini-2.5-pro)

Signed-off-by: AdamMagued <adamismailmageud@gmail.com>
@AdamMagued
AdamMagued force-pushed the feat/non-linux-default-directories branch from f83d355 to e3f93c9 Compare November 12, 2026 22:09
@AdamMagued

Copy link
Copy Markdown
Contributor Author
  • directories_bsd.go: Set DefaultLibexecDirectory to /usr/lib/maddy
  • directories_windows.go: Define programData() and programFiles() helpers and assign ConfigDirectory, DefaultStateDirectory, DefaultRuntimeDirectory, and DefaultLibexecDirectory directly
  • directories_windows_test.go: Add tests covering default fallbacks and environment variable resolution for programData() and programFiles()
  • directories_test.go: Update expected BSD libexec path to /usr/lib/maddy

lmk if you need any adjustments

@github-project-automation github-project-automation Bot moved this from Changes Needed to Approved in Maddy Mail Server PR Review Nov 15, 2026
@foxcpp
foxcpp merged commit 911c722 into foxcpp:master Nov 15, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Merged in Maddy Mail Server PR Review Nov 15, 2026
@foxcpp

foxcpp commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Add appropriate state_dir/runtime_dir values for non-Linux platforms

2 participants