diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 01920f50..854793ed 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -36,7 +36,16 @@ export default defineConfig({ sidebar: [ { text: "Installation", - link: "/setup/installation", + items: [ + { + text: "Normal", + link: "/setup/installation", + }, + { + text: "Nix", + link: "/setup/nix", + }, + ], }, { text: "CLI", diff --git a/docs/setup/nix.md b/docs/setup/nix.md new file mode 100644 index 00000000..41916ae0 --- /dev/null +++ b/docs/setup/nix.md @@ -0,0 +1,86 @@ +# Nix Module + +This project is packaged as a [Nix Flake](https://nixos.wiki/wiki/Flakes), which can be used to build and run the project in a reproducible environment. + +## Installation + +### Flake-based NixOS installs + +Add the following to your `inputs` in your `flake.nix`: + +```nix +inputs = { + # ... + versia-server = { + url = "github:versia-pub/server"; + inputs.nixpkgs.follows = "nixpkgs"; + }; +}; +``` + +Then, add this to your `nixosConfigurations`: + +```nix +nixosConfigurations = { + # ... + my-server = { + system = "x86_64-linux"; # arm64-linux is also supported + modules = [ + # ... + versia-server.nixosModules.default + ]; + }; +}; +``` + +You are now ready to use the NixOS module. + +## Usage + +This module exposes the following configuration option: + +```nix +services.versia-server = { + enable = true; + dataDir = "/var/lib/versia-server"; + + user = "versia-server"; + group = "versia-server"; + + nodes = { + api = { + main = {}; + backup = { + configOverrides.http.port = 2734; + }; + }; + worker = { + one = {}; + two = {}; + three = { + configOverrides.postgres.port = 5433; + }; + }: + }; + + config = { + # ... + http = { + # ... + bind = "0.0.0.0"; + port = 8080; + base_url = "https://versia.example"; + }; + # ... + }; +}; +``` + +### Configuration Options + +- `enable`: Whether to enable the service. Default: `true`. +- `dataDir`: The directory where the data will be stored. Default: `/var/lib/versia-server`. +- `user`: The user under which the service will run. Default: `versia-server`. +- `group`: The group under which the service will run. Default: `versia-server`. +- `nodes`: A set of nodes to run. Each node can have its own configuration overrides, which will be merged with the default configuration. You must have at least one of each type (`api` and `worker`). +- `config`: Contents of the config file, which is serialized to TOML. Check the Versia Server documentation for information on its contents. diff --git a/flake.nix b/flake.nix index cb75f339..5b26432b 100644 --- a/flake.nix +++ b/flake.nix @@ -57,8 +57,9 @@ }; }) // { - nixosModules = { + nixosModules = rec { versia-server = import ./nix/module.nix; + default = versia-server; }; }; } diff --git a/nix/module.nix b/nix/module.nix index 3877fdf1..178c943c 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -78,7 +78,7 @@ in { freeformType = configFormat.type; options = {}; }; - description = "Contents of the config file. Check the Versia Server documentation for information on its contents."; + description = "Contents of the config file, which is serialized to TOML. Check the Versia Server documentation for information on its contents."; }; }; };