Anki: Difference between revisions
Added how to self host anki-sync-server, both behind a reverse proxy and plain, to the wiki. Feel free to make any critiques and edits necessary as this is my first time contributing to the wiki. The reason that the example client setup urls is like that is because in the clients it needs to be in that "http" or "https" setup. |
add syntax highlighting |
||
| Line 6: | Line 6: | ||
<code>anki</code> is recommended over <code>anki-bin</code>, due to <code>anki-bin</code> being out of date (at the time of writing). Using old versions of <code>anki-bin</code> may lead to decks being incompatible with newer versions. | <code>anki</code> is recommended over <code>anki-bin</code>, due to <code>anki-bin</code> being out of date (at the time of writing). Using old versions of <code>anki-bin</code> may lead to decks being incompatible with newer versions. | ||
; | ;NixOS | ||
{{File|name=/etc/nixos/configuration.nix|lang=nix|3= | |||
environment.systemPackages = [ | |||
pkgs.anki | |||
];}} | |||
;nix-shell | ;nix-shell | ||
< | <syntaxhighlight lang="console"> | ||
$ nix-shell -p anki | |||
</syntaxhighlight> | |||
== Installing Addons == | == Installing Addons == | ||
Additional addons can be installed using the following syntax: | Additional addons can be installed using the following syntax: | ||
; | ;NixOS | ||
{{File|name=/etc/nixos/configuration.nix|lang=nix|3= | |||
environment.systemPackages = [ | |||
(pkgs.anki.withAddons [ | |||
pkgs.ankiAddons.passfail2 | |||
]) | |||
];}} | |||
Note that as of writing, <code>anki-bin</code> does not support installing addons in this way. | Note that as of writing, <code>anki-bin</code> does not support installing addons in this way. | ||
| Line 29: | Line 35: | ||
Addons can be configured using <code>.withConfig</code>: | Addons can be configured using <code>.withConfig</code>: | ||
; | ;NixOS | ||
{{File|name=/etc/nixos/configuration.nix|lang=nix|3= | |||
environment.systemPackages = [ | |||
(pkgs.anki.withAddons [ | |||
(pkgs.ankiAddons.passfail2.withConfig { | |||
config = { | |||
again_button_name = "Incorrect"; | |||
good_button_name = "Correct"; | |||
}; | |||
}) | |||
]) | |||
];}} | |||
[[Category:Applications]] | [[Category:Applications]] | ||
| Line 48: | Line 56: | ||
The most simplest setup for it you can have is like below: | The most simplest setup for it you can have is like below: | ||
;NixOS | ;NixOS | ||
<syntaxhighlight lang=nix> | |||
services.anki-sync-server = { | |||
enable = true; | enable = true; | ||
address = "0.0.0.0"; | address = "0.0.0.0"; | ||
| Line 58: | Line 67: | ||
} | } | ||
]; | ]; | ||
}; | |||
</syntaxhighlight> | |||
You would then access the self hosted instance by changing it on the anki app you're using, but make sure to write as <code>http://ReplaceLocalIPHere:27701/</code> it is necessary to have the <code>/</code> at the end on the clients. After doing that, attempt to sync and when asked for log in details do, in this case <code>bob</code> as the email address and <code>password</code> as the password and it will work. | You would then access the self hosted instance by changing it on the anki app you're using, but make sure to write as <code>http://ReplaceLocalIPHere:27701/</code> it is necessary to have the <code>/</code> at the end on the clients. After doing that, attempt to sync and when asked for log in details do, in this case <code>bob</code> as the email address and <code>password</code> as the password and it will work. | ||
| Line 68: | Line 78: | ||
A complete setup for that using caddy as the reverse proxy would be: | A complete setup for that using caddy as the reverse proxy would be: | ||
;NixOS | ;NixOS | ||
<syntaxhighlight lang=nix> | |||
services.anki-sync-server = { | |||
enable = true; | enable = true; | ||
address = "127.0.0.1"; | address = "127.0.0.1"; | ||
users = [ | users = [ | ||
{ | { | ||
username = "bob"; | |||
password = "password"; | |||
} | } | ||
]; | ]; | ||
}; | |||
services.caddy.virtualHosts."anki.custom.domain".extraConfig = '' | |||
reverse_proxy ${config.services.anki-sync-server.address}:${builtins.toString config.services.anki-sync-server.port} | |||
''; | |||
</syntaxhighlight> | |||
Then to access that on your anki clients, you change the sync server to <code>https://anki.custom.domain/</code> that end <code>/</code> is important in order to get the clients working properly. Then you would log in with the "email address" as <code>bob</code> and the password as <code>password</code> | Then to access that on your anki clients, you change the sync server to <code>https://anki.custom.domain/</code> that end <code>/</code> is important in order to get the clients working properly. Then you would log in with the "email address" as <code>bob</code> and the password as <code>password</code> | ||
Note: It is still recommended to use the <code>passwordFile</code> option over the plain text <code>password</code> option as the latter option stores it in plain text in the nix store on the server. | Note: It is still recommended to use the <code>passwordFile</code> option over the plain text <code>password</code> option as the latter option stores it in plain text in the nix store on the server. | ||