nixpkgs/nixos/modules/services/misc/anki-sync-server.md
Robert Irelan 8fe9c18ed3 nixos/anki-sync-server: init
Provide a NixOS module for the [built-in Anki Sync
Server](https://docs.ankiweb.net/sync-server.html) included in recent
versions of Anki. This supersedes the `ankisyncd` module, but we should
keep that for now because `ankisyncd` supports older versions of Anki
clients than this module.
2023-11-30 17:25:17 +01:00

2.3 KiB

Anki Sync Server

Anki Sync Server 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.

Basic Usage

By default, the module creates a 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:

{ ... }:

{
  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

{
  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, 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:

{
  services.anki-sync-server.host = "0.0.0.0";
  services.anki-sync-server.openFirewall = true;
}

Alternatives

The ankisyncd NixOS module provides similar functionality, but using a third-party implementation, anki-sync-server-rs. According to that project's README, it is "no longer maintained", and not recommended for Anki 2.1.64+.