any2nix-api 0.1.4

JSON-based server that can be used as an API for translating from different formats to Nix.
Documentation

any2nix-api

JSON-based Nix Converter API

What is any2nix-api?

any2nix-api is the API offering of any2nix, a Rust library for converting strings in various file formats to Nix. It can be run standalone or embedded into another axum application.

Screenshot showcasing the Swagger UI of the API, enabled with the "utoipa-swagger-ui" feature.

Supported formats

any2nix-api supports converting from the following formats into Nix expressions:

Quick look

curl \
-d '{"input": "[package]\nname = \"any2nix\""}' \
-X POST \
-H "Content-Type: application/json" \
http://localhost:3000/v1/toml
# Output:
#
# {"nix":"{\n  package = {\n    name = \"any2nix\";\n  };\n}"}

Interactive OpenAPI documentation is available at /docs when the utoipa-swagger-ui feature is enabled.

Installation

Install with Cargo

cargo install any2nix-cli

Install on macOS

macOS builds of any2nix-api are available at the releases tab.

Install on Linux

Look for your favorite package manager in the list of supported repositories:

Repository status

Additionally, Linux builds are available at the releases tab.

Install on Windows

Windows builds of any2nix-api are available at the releases tab.

Run using Docker

A docker image is available for any2nix-api.

docker run --rm -it -p 3000:3000 ghcr.io/gbr-ufs/any2nix-api:latest

After running this, the API will be available at http://localhost:3000.

Crate features

All format parsers are enabled by default. You can disable default features and enable only the formats or integrations you need:

Feature Description Default
ini Support for converting INI strings Yes
json Support for converting JSON strings Yes
toml Support for converting TOML strings Yes
yaml Support for converting YAML strings Yes
trace Support for tracing No
utoipa Support for OpenAPI No
utoipa-swagger-ui User interface for the API at the /docs endpoint No

License

All code is licensed GPL 3.0 or later. The distribution workflow is based on cargo-dist and is thus licensed MIT or Apache 2.0.

Anything that is not code is CC-BY-4.0.

This software family is REUSE compliant.