Home Explore Blog Models CI



nixpkgs

nixos/modules/services/misc/anki-sync-server.md
c91700331c36b4935c0a0b9daafc6aa99364505a12efcda2000000030000083e
# Anki Sync Server {#module-services-anki-sync-server}

[Anki Sync Server](https://docs.ankiweb.net/sync-server.html) is the built-in
sync server, present in recent versions of Anki. Advanced users who cannot or
do not wish to use AnkiWeb can use this sync server instead of AnkiWeb.

This module is compatible only with Anki versions >=2.1.66, due to [recent
enhancements to the Nix anki
package](https://github.com/NixOS/nixpkgs/commit/05727304f8815825565c944d012f20a9a096838a).

## Basic Usage {#module-services-anki-sync-server-basic-usage}

By default, the module creates a
[`systemd`](https://www.freedesktop.org/wiki/Software/systemd/)
unit which runs the sync server with an isolated user using the systemd
`DynamicUser` option.

This can be done by enabling the `anki-sync-server` service:
```nix
{ ... }:

{
  services.anki-sync-server.enable = true;
}
```

It is necessary to set at least one username-password pair under
{option}`services.anki-sync-server.users`. For example

```nix
{
  services.anki-sync-server.users = [
    {
      username = "user";
      passwordFile = /etc/anki-sync-server/user;
    }
  ];
}
```

Here, `passwordFile` is the path to a file containing just the password in
plaintext. Make sure to set permissions to make this file unreadable to any
user besides root.

By default, synced data are stored in */var/lib/anki-sync-server/*ankiuser**.
You can change the directory by using `services.anki-sync-server.baseDirectory`

```nix
{ services.anki-sync-server.baseDirectory = "/home/anki/data"; }
```

By default, the server listen address {option}`services.anki-sync-server.host`
is set to localhost, listening on port
{option}`services.anki-sync-server.port`, and does not open the firewall. This
is suitable for purely local testing, or to be used behind a reverse proxy. If
you want to expose the sync server directly to other computers (not recommended
in most circumstances, because the sync server doesn't use HTTPS), then set the
following options:

```nix
{
  services.anki-sync-server.address = "0.0.0.0";
  services.anki-sync-server.openFirewall = true;
}
```

Chunks
380d6580 (1st chunk of `nixos/modules/services/misc/anki-sync-server.md`)
Title: Anki Sync Server Configuration and Usage
Summary
This chunk describes how to set up and use the Anki Sync Server as an alternative to AnkiWeb for advanced users, compatible with Anki versions 2.1.66 or newer. It details the basic usage, including enabling the `anki-sync-server` service, configuring username-password pairs using plaintext password files, and customizing the data storage directory. The chunk also covers network configuration, such as changing the listening address and opening the firewall, while cautioning against direct exposure without HTTPS due to security concerns.