Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions nixos/doc/manual/release-notes/rl-2311.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@

- `services.fail2ban.jails` can now be configured with attribute sets defining settings and filters instead of lines. The stringed options `daemonConfig` and `extraSettings` have respectively been replaced by `daemonSettings` and `jails.DEFAULT.settings` which use attribute sets.

- The module [services.ankisyncd](#opt-services.ankisyncd.package) has been switched to [anki-sync-server-rs](https://github.com/ankicommunity/anki-sync-server-rs) from the old python version, which was difficult to update, had not been updated in a while, and did not support recent versions of anki.
Unfortunately all servers supporting new clients (newer version of anki-sync-server, anki's built in sync server and this new rust package) do not support the older sync protocol that was used in the old server, so such old clients will also need updating and in particular the anki package in nixpkgs is also being updated in this release.
The module update takes care of the new config syntax and the data itself (user login and cards) are compatible, so users of the module will be able to just log in again after updating both client and server without any extra action.

- `services.nginx` gained a `defaultListen` option at server-level with support for PROXY protocol listeners, also `proxyProtocol` is now exposed in `services.nginx.virtualHosts.<name>.listen` option. It is now possible to run PROXY listeners and non-PROXY listeners at a server-level, see [#213510](https://github.com/NixOS/nixpkgs/pull/213510/) for more details.

- `services.prometheus.exporters` has a new exporter to monitor electrical power consumption based on PowercapRAPL sensor called [Scaphandre](https://github.com/hubblo-org/scaphandre), see [#239803](https://github.com/NixOS/nixpkgs/pull/239803) for more details.
Expand Down
22 changes: 7 additions & 15 deletions nixos/modules/services/misc/ankisyncd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,16 @@ let

stateDir = "/var/lib/${name}";

authDbPath = "${stateDir}/auth.db";
toml = pkgs.formats.toml {};

sessionDbPath = "${stateDir}/session.db";

configFile = pkgs.writeText "ankisyncd.conf" (lib.generators.toINI {} {
sync_app = {
configFile = toml.generate "ankisyncd.conf" {
listen = {
host = cfg.host;
port = cfg.port;
data_root = stateDir;
auth_db_path = authDbPath;
session_db_path = sessionDbPath;

base_url = "/sync/";
base_media_url = "/msync/";
};
});
paths.root_dir = stateDir;
# encryption.ssl_enable / cert_file / key_file
};
Comment on lines 14 to 21
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps be nice to have an RFC42-like settings attr for additional settings.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I focused on migrating equivalent functionality but I guess that might be useful for someone at some point, yes... And it's trivial now we use toml.generate. I guess I can add that tonight.

At this rate though I'd say I want some nixos/test/ankisync.nix first and I'm not sure that'll end well, but I'll leave that for a much later future me; I have no idea how to start the anki client interactively to test sync and don't want to get started with GUI testing :P

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some basic smoke tests would already be pretty good; whether it runs at all or can answer some basic requests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a quick look at the anki protocol and it's a real monster (some binary data sent as post to get a key, then some more binary data including the key to get stats like last modfcations etc.

Can probably just replay something straight out of tcpdump through curl but I have no idea how fragile that'll be, I'll just slack for now.

Also didn't do free form yet -- I didn't remember how to integrate existing felds in the free form nicely and ran out of time for today; might do it later but imo it's orthogonal enough that we don't need to do it now (perfect is the enemy of good etc); I'd rather do in a later PR to keep things separate.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either mkMerge (mkDefault the defaults) or use the built-in update operator (//). First would probably be cleaner.

Not a hard requirement; I won't block on this.

in
{
options.services.ankisyncd = {
Expand Down Expand Up @@ -59,8 +53,6 @@ in
config = mkIf cfg.enable {
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];

environment.etc."ankisyncd/ankisyncd.conf".source = configFile;

systemd.services.ankisyncd = {
description = "ankisyncd - Anki sync server";
after = [ "network.target" ];
Expand All @@ -71,7 +63,7 @@ in
Type = "simple";
DynamicUser = true;
StateDirectory = name;
ExecStart = "${cfg.package}/bin/ankisyncd";
ExecStart = "${cfg.package}/bin/ankisyncd --config ${configFile}";
Restart = "always";
};
};
Expand Down
Loading