1# Anki Sync Server {#module-services-anki-sync-server} 2 3[Anki Sync Server](https://docs.ankiweb.net/sync-server.html) is the built-in 4sync server, present in recent versions of Anki. Advanced users who cannot or 5do not wish to use AnkiWeb can use this sync server instead of AnkiWeb. 6 7This module is compatible only with Anki versions >=2.1.66, due to [recent 8enhancements to the Nix anki 9package](https://github.com/NixOS/nixpkgs/commit/05727304f8815825565c944d012f20a9a096838a). 10 11## Basic Usage {#module-services-anki-sync-server-basic-usage} 12 13By default, the module creates a 14[`systemd`](https://www.freedesktop.org/wiki/Software/systemd/) 15unit which runs the sync server with an isolated user using the systemd 16`DynamicUser` option. 17 18This can be done by enabling the `anki-sync-server` service: 19```nix 20{ ... }: 21 22{ 23 services.anki-sync-server.enable = true; 24} 25``` 26 27It is necessary to set at least one username-password pair under 28{option}`services.anki-sync-server.users`. For example 29 30```nix 31{ 32 services.anki-sync-server.users = [ 33 { 34 username = "user"; 35 passwordFile = /etc/anki-sync-server/user; 36 } 37 ]; 38} 39``` 40 41Here, `passwordFile` is the path to a file containing just the password in 42plaintext. Make sure to set permissions to make this file unreadable to any 43user besides root. 44 45By default, synced data are stored in */var/lib/anki-sync-server/*ankiuser**. 46You can change the directory by using `services.anki-sync-server.baseDirectory` 47 48```nix 49{ 50 services.anki-sync-server.baseDirectory = "/home/anki/data"; 51} 52``` 53 54By default, the server listen address {option}`services.anki-sync-server.host` 55is set to localhost, listening on port 56{option}`services.anki-sync-server.port`, and does not open the firewall. This 57is suitable for purely local testing, or to be used behind a reverse proxy. If 58you want to expose the sync server directly to other computers (not recommended 59in most circumstances, because the sync server doesn't use HTTPS), then set the 60following options: 61 62```nix 63{ 64 services.anki-sync-server.address = "0.0.0.0"; 65 services.anki-sync-server.openFirewall = true; 66} 67```