Something went wrong. Try again.
XDG Base Directory specification: pure resolution + Eio backend
Something went wrong. Try again.
Files
- OCaml 79%
- Raku 18%
- C 3%
- Shell <1%
README.md
# nox-xdg
The XDG Base Directory specification for OCaml: where an application keeps its
configuration, data, cache, state and runtime files.
A command-line tool that writes `~/.myapp` clutters the home directory and
ignores the variables users set to move those files. The
[XDG Base Directory Specification][spec] says where each kind of file belongs
on Unix (`$XDG_CONFIG_HOME`, falling back to `~/.config`, and so on), and
Windows has an equivalent set of [known folders][knownfolders]. The `nox-xdg`
library computes these paths from an environment lookup function and touches
no file system, so a test can pass it a fixed environment. `Xdg.App` adds the
per-application view: the application name appended to each base, overrides
from the command line and from variables such as `MYAPP_CONFIG_DIR`, and the
source each path was resolved from.
The `nox-xdg.eio` library (module `Xdg_eio`) resolves the same directories as
Eio paths and creates them on access. It checks that the runtime directory is
owned by the user with mode 0700, provides a Cmdliner term with a
`--NAME-dir` flag per directory and a `--show-paths` flag, and has a helper to
open a URL in the user's browser.
`nox-xdg` is a fork of [dune's internal `xdg` library][upstream], which dune
does not promise to keep stable across releases. The C stub's symbol is
renamed from `dune_xdg__get_known_folder_path` to
`nox_xdg__get_known_folder_path`, so a binary can link both libraries.
Both libraries are named `xdg` and both expose a module `Xdg`, so depend on
this one by its public name, `(libraries nox-xdg)`. `(libraries xdg)`
resolves to dune's library, whose constructor is `Xdg.create` where this
one's is `Xdg.v`, and naming both in one stanza clashes on the module name.
[spec]: https://specifications.freedesktop.org/basedir-spec/latest/
[knownfolders]: https://learn.microsoft.com/en-us/windows/win32/shell/known-folders
[upstream]: https://github.com/ocaml/dune/tree/main/otherlibs/xdg
## Installation
<!-- $MDX skip -->
```sh
$ opam install nox-xdg
```
If op…