{"id":16965068,"url":"https://github.com/propensive/imperial","last_synced_at":"2025-04-05T15:46:08.554Z","repository":{"id":39483379,"uuid":"475168936","full_name":"propensive/imperial","owner":"propensive","description":"Access UNIX's standard directory structure from Scala","archived":false,"fork":false,"pushed_at":"2025-02-10T12:34:29.000Z","size":2069,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T20:49:18.840Z","etag":null,"topics":["posix","scala","unix","xdg","xdg-basedir"],"latest_commit_sha":null,"homepage":"https://propensive.com/imperial/","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/propensive.png","metadata":{"files":{"readme":".github/readme.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-28T20:29:57.000Z","updated_at":"2025-02-10T12:34:37.000Z","dependencies_parsed_at":"2023-11-16T09:25:55.872Z","dependency_job_id":"9d265c9d-bc93-4c0f-a3f0-d21605d3380a","html_url":"https://github.com/propensive/imperial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fimperial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fimperial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fimperial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fimperial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/propensive","download_url":"https://codeload.github.com/propensive/imperial/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247361598,"owners_count":20926642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["posix","scala","unix","xdg","xdg-basedir"],"created_at":"2024-10-13T23:44:56.176Z","updated_at":"2025-04-05T15:46:08.534Z","avatar_url":"https://github.com/propensive.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg alt=\"GitHub Workflow\" src=\"https://img.shields.io/github/actions/workflow/status/propensive/imperial/main.yml?style=for-the-badge\" height=\"24\"\u003e](https://github.com/propensive/imperial/actions)\n[\u003cimg src=\"https://img.shields.io/discord/633198088311537684?color=8899f7\u0026label=DISCORD\u0026style=for-the-badge\" height=\"24\"\u003e](https://discord.com/invite/MBUrkTgMnA)\n\u003cimg src=\"/doc/images/github.png\" valign=\"middle\"\u003e\n\n# Imperial\n\n__Access the operating system's standard directory structure__\n\n_Imperial_ provides access to the standard directory structure in UNIX and Linux, as defined by the\n[systemd](https://www.freedesktop.org/software/systemd/man/file-hierarchy.html) and [XDG Base\nDirectory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) specifications.\n\n## Features\n\n- Typesafe representation of standard UNIX directories\n- Supports any directory representation through typeclasses\n- Resolves environment variables to correctly use user-specified directory locations\n- Supports alternative sources of environment variables\n\n\n## Availability\n\n\n\n\n\n\n\n## Getting Started\n\n### Standard directory layout\n\n_Imperial_ provides a structure of nested objects inside the `Root` and `Home` objects which mirror the standard directory layout on\nmodern UNIX systems, as described in the\n(XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html). This allows standard\ndirectories to be referenced in code without the risk of typos.\n\nAdditionally, certain environment variables may be set which change the standard location, particularly within a user's home\ndirectory. Imperial will take these into account, according to the specification.\n\n### Accessing Directories\n\nObjects have the same names as their corresponding UNIX directory, but by convention begin with a capital letter. Any `.` prefixes in\na directory's name are removed since, of course, `.` is used in place of `/` to access a nested object. So `/var/lib` would be\nrepresented by the object, `Root.Var.Lib` and `$HOME/.local/bin` would be `Home.Local.Bin`.\n\nConversely, `Home.Config` would normally resolve to `$HOME/.config`, but if the user has the `XDG_CONFIG_HOME` environment\nvariable set to something else, it would simply resolve to `$XDG_CONFIG_HOME`.\n\nThe type of each of these objects is `BaseLayout`, which provides a `BaseLayout#apply()` method for constructing an instance of\na directory type (such as `java.io.File` or `galilei.Directory`) representing the directory. Imperial is designed to be\ncompatible with different file and directory representations, but it works automatically with\n[Galilei](https://github.com/propensive/galilei).\n\nFor example, it would be possible to access a `myapp` configuration directory with,\n```scala\nimport galilei.*\nval dir: Directory = Home.Config() / t\"myapp\"\n```\n\n### Source of Environment Variables\n\nBy default, Imperial will take its environment variables directly from the JVM, since they are globally accessible. But this\nis not always the correct source, for example in a long-running server which may receive multiple command-line requests from\ndifferent shells over its lifetime, each with a potentially different set of environment variables.\n\nTo cater for this scenario, it's possible to provide an alternative `EnvVarProvider` instance. This is a\nsingle-abstract-method trait which takes a `Text` value and returns an `Option[Text]` of the value (returning `None` if the\nenvironment variable is unset).\n\nFor example, if the `envvars` is a `Map` of values, a new EnvVarProvider may be specified in-scope with,\n```scala\ngiven EnvVarProvider = envvars.get(_)\n```\n\n\n\n\n\n## Status\n\nImperial is classified as __fledgling__. For reference, Soundness projects are\ncategorized into one of the following five stability levels:\n\n- _embryonic_: for experimental or demonstrative purposes only, without any guarantees of longevity\n- _fledgling_: of proven utility, seeking contributions, but liable to significant redesigns\n- _maturescent_: major design decisions broady settled, seeking probatory adoption and refinement\n- _dependable_: production-ready, subject to controlled ongoing maintenance and enhancement; tagged as version `1.0.0` or later\n- _adamantine_: proven, reliable and production-ready, with no further breaking changes ever anticipated\n\nProjects at any stability level, even _embryonic_ projects, can still be used,\nas long as caution is taken to avoid a mismatch between the project's stability\nlevel and the required stability and maintainability of your own project.\n\nImperial is designed to be _small_. Its entire source code currently consists\nof 154 lines of code.\n\n## Building\n\nImperial will ultimately be built by Fury, when it is published. In the\nmeantime, two possibilities are offered, however they are acknowledged to be\nfragile, inadequately tested, and unsuitable for anything more than\nexperimentation. They are provided only for the necessity of providing _some_\nanswer to the question, \"how can I try Imperial?\".\n\n1. *Copy the sources into your own project*\n   \n   Read the `fury` file in the repository root to understand Imperial's build\n   structure, dependencies and source location; the file format should be short\n   and quite intuitive. Copy the sources into a source directory in your own\n   project, then repeat (recursively) for each of the dependencies.\n\n   The sources are compiled against the latest nightly release of Scala 3.\n   There should be no problem to compile the project together with all of its\n   dependencies in a single compilation.\n\n2. *Build with [Wrath](https://github.com/propensive/wrath/)*\n\n   Wrath is a bootstrapping script for building Imperial and other projects in\n   the absence of a fully-featured build tool. It is designed to read the `fury`\n   file in the project directory, and produce a collection of JAR files which can\n   be added to a classpath, by compiling the project and all of its dependencies,\n   including the Scala compiler itself.\n   \n   Download the latest version of\n   [`wrath`](https://github.com/propensive/wrath/releases/latest), make it\n   executable, and add it to your path, for example by copying it to\n   `/usr/local/bin/`.\n\n   Clone this repository inside an empty directory, so that the build can\n   safely make clones of repositories it depends on as _peers_ of `imperial`.\n   Run `wrath -F` in the repository root. This will download and compile the\n   latest version of Scala, as well as all of Imperial's dependencies.\n\n   If the build was successful, the compiled JAR files can be found in the\n   `.wrath/dist` directory.\n\n## Contributing\n\nContributors to Imperial are welcome and encouraged. New contributors may like\nto look for issues marked\n[beginner](https://github.com/propensive/imperial/labels/beginner).\n\nWe suggest that all contributors read the [Contributing\nGuide](/contributing.md) to make the process of contributing to Imperial\neasier.\n\nPlease __do not__ contact project maintainers privately with questions unless\nthere is a good reason to keep them private. While it can be tempting to\nrepsond to such questions, private answers cannot be shared with a wider\naudience, and it can result in duplication of effort.\n\n## Author\n\nImperial was designed and developed by Jon Pretty, and commercial support and\ntraining on all aspects of Scala 3 is available from [Propensive\nO\u0026Uuml;](https://propensive.com/).\n\n\n\n## Name\n\nThis project is particular to Linux operating systems, whos mascot is a penguin. While __Imperial__ defines the layout of the\noperating system's own (little) empire, \"Emperor\" is also a species of penguin.\n\nIn general, Soundness project names are always chosen with some rationale,\nhowever it is usually frivolous. Each name is chosen for more for its\n_uniqueness_ and _intrigue_ than its concision or catchiness, and there is no\nbias towards names with positive or \"nice\" meanings—since many of the libraries\nperform some quite unpleasant tasks.\n\nNames should be English words, though many are obscure or archaic, and it\nshould be noted how willingly English adopts foreign words. Names are generally\nof Greek or Latin origin, and have often arrived in English via a romance\nlanguage.\n\n## Logo\n\nThe logo shows the colors of an emperor (suggesting _imperial_) penguin.\n\n## License\n\nImperial is copyright \u0026copy; 2025 Jon Pretty \u0026 Propensive O\u0026Uuml;, and\nis made available under the [Apache 2.0 License](/license.md).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Fimperial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpropensive%2Fimperial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Fimperial/lists"}