Anki: Difference between revisions
→Installation: anki-bin and anki now have almst the same version |
add syntax highlighting |
||
| (4 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
Anki is a spaced repetition system (SRS) commonly used to learn new languages. Information is placed on individual flashcards, which are sorted into decks. Anki is extensible using [[Python]] addons. | |||
In addition to the desktop software, Anki has an iOS app, Android app, and web interface available. Decks/flashcards can be synced using a self hosted instance of <code> | In addition to the desktop software, Anki has an iOS app, Android app, and web interface available. Decks/flashcards can be synced using a self hosted instance of <code>anki-sync-server</code> or an AnkiWeb account. | ||
== Installation == | == Installation == | ||
<code>anki-bin</code> | <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 == | |||
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. | |||
=== Configuring Addons === | |||
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]] | ||
== Self Hosting == | |||
You can self host an instance of anki-sync-server via the NixOS module. | |||
The default port for this service is 27701. | |||
The most simplest setup for it you can have is like below: | |||
;NixOS | |||
<syntaxhighlight lang=nix> | |||
services.anki-sync-server = { | |||
enable = true; | |||
address = "0.0.0.0"; | |||
openFirewall = true; | |||
users = [ | |||
{ | |||
username = "bob"; | |||
password = "password"; | |||
} | |||
]; | |||
}; | |||
</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. | |||
Note: This does let anyone on your local network access your anki-sync-server instance and it is exposed under http. It also exposes your password in plain text on the server. A better recommendation is to use the <code>passwordFile</code> option. | |||
=== Reverse Proxy === | |||
You can reverse proxy anki-sync-server to make sure it's running under a https connection and in order to restrict it more to your vpn of choice. | |||
A complete setup for that using caddy as the reverse proxy would be: | |||
;NixOS | |||
<syntaxhighlight lang=nix> | |||
services.anki-sync-server = { | |||
enable = true; | |||
address = "127.0.0.1"; | |||
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> | |||
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. | |||