Module Bushel_config

Bushel configuration management with XDG paths

Configuration is loaded from ~/.config/bushel/config.toml by default, with support for environment variable overrides via XDG_CONFIG_HOME.

Example config.toml

[data]
local_dir = "/path/to/bushel/data"

[images]
images_dir = "/path/to/images"
images_output_dir = "/path/to/images-web"
paper_thumbs = "papers"
contact_faces = "faces"
video_thumbs = "videos"

[papers]
pdfs_dir = "/path/to/paper-pdfs"

[peertube]
[[peertube.servers]]
name = "crank"
endpoint = "https://crank.recoil.org"

[[peertube.servers]]
name = "talks"
endpoint = "https://talks.example.com"

[zotero]
translation_server = "http://localhost:1969"

[sync]
remote = "ssh://server/path/to/bushel.git"
branch = "main"
auto_commit = true
commit_message = "sync"

[images_sync]
remote = "ssh://server/path/to/images.git"
branch = "main"
auto_commit = true
commit_message = "images sync"

Types

type peertube_server = {
  1. name : string;
  2. endpoint : string;
}

A PeerTube server configuration.

type t = {
  1. data_dir : string;
  2. images_dir : string;
  3. images_output_dir : string;
  4. paper_thumbs_subdir : string;
  5. contact_faces_subdir : string;
  6. video_thumbs_subdir : string;
  7. paper_pdfs_dir : string;
  8. peertube_servers : peertube_server list;
  9. zotero_translation_server : string;
  10. sync : Gitops.Sync.Config.t;
  11. images_sync : Gitops.Sync.Config.t;
}

Complete bushel configuration.

XDG Paths

val xdg_config_home : unit -> string

Return the XDG config home directory.

val config_dir : unit -> string

Return the bushel config directory (~/.config/bushel).

val config_file : unit -> string

Return the path to the config file (~/.config/bushel/config.toml).

Loading

val default : unit -> t

Return the default configuration.

val load : unit -> (t, string) result

Load configuration from the default config file. Returns default config if file doesn't exist.

val load_file : string -> (t, string) result

Load configuration from a specific file path.

val of_string : string -> (t, string) result

Parse configuration from a TOML string.

Path Helpers

val expand_path : string -> string

Expand ~ in paths to the home directory.

val paper_thumbs_dir : t -> string

Full path to paper thumbnails directory.

val contact_faces_dir : t -> string

Full path to contact faces directory.

val video_thumbs_dir : t -> string

Full path to video thumbnails directory.

API Keys

val read_api_key : string -> (string, string) result

Read an API key from a file.

Pretty Printing

val pp : t Fmt.t

Pretty-print the configuration.

Initialization

val default_config_toml : unit -> string

Generate a default config.toml content with comments.

val write_default_config : ?force:bool -> unit -> (string, string) result

Write a default config file to the config directory. Returns Ok path on success, or Error msg if the file exists and force is not set, or if writing fails.