@hackage xdg-basedir-compliant1.2.0

XDG Basedir

XDG Basedir implementation

This is a compliant implementation of the XDG Base Directory Specification.

Compliance

  • $XDG_DATA_HOME
    • get path
    • read file
    • write file
  • $XDG_CONFIG_HOME
    • get path
    • read file
    • write file
  • $XDG_STATE_HOME
    • get path
    • read file
    • write file
  • $XDG_DATA_DIRS
    • get path list
    • read best file
    • merge files
  • $XDG_CONFIG_DIRS
    • get path list
    • read best file
    • merge files
  • $XDG_CACHE_HOME
    • get path
    • read file
    • write file
  • $XDG_RUNTIME_DIR
    • get path
    • read file
    • write file
  • treat relative paths as invalid

As this library deals purely with accessing files, I eventually chose not to implement the notion of warning the user when $XDG_RUNTIME_DIR isn't set and of providing a replacement directory. Any application where that behaviour would be relevant can use the exception raised by getRuntimeDir to detect this problem, should deal with warning the user in its own context, and can set $XDG_RUNTIME_DIR with a path that makes sense for that application.

Build

You can build the project with:

hpack
cabal build

If you have Nix installed, shell.nix provides an environment with all the needed dependencies. It is suitable for nix-direnv.