Difficulty pulling in submodule for Anki add-on FSRS Helper

Hi all,

I’ve been trying to get a few Anki add-ons built and one of the add-ons I’m trying to pull in is fsrs4anki-helper. This add-on, among others, isn’t offered by nixpkgs ( and checking NixOS search today, it seems like anki, anki-connect, passfail2, review-heatmap, yomichan-forvo-server, local-audio-yomichan have gone AWOL ) so I’ve been using the home-manager example for non-nixpkg add-ons as a template to build the remaining.

The issue I’m encountering is that fsrs4anki-helper includes a submodule, python-i8n, as part of the repository. I didn’t account for this initially and ended up with an empty python_i8n directory and the add-on failing to initialize as a consequence of this. I did a bit of digging around, found fetchSubmodules, enabled it and tried rebuilding but ended up with an empty directory again.

(pkgs.anki-utils.buildAnkiAddon (finalAttrs: {
                    pname = "FSRS_Helper";
                    version = "2bd5fb0";
                    src = pkgs.fetchFromGitHub {
                        owner = "open-spaced-repetition";
                        repo = "fsrs4anki-helper";
                        rev = finalAttrs.version;
                        hash = "sha256-UBosEkM3FtLPzsOsUB3ZYD6WsmDks7yBcRltPWkoQvg=";
                        fetchSubmodules = true;
                    };
                }))

I’m not sure if this is a local caching issue, if I’m not understanding how fetchSubmodules or fetchFromGitHub is supposed to work or what’s happening, but I haven’t managed to get python_i8n pulled in as a submodule of fsrs4anki-helper. I’m fairly new to Nix so apologies in advance if I’m doing something obviously wrong or otherwise missed something obvious. I’m still wrapping my head around the declarative system/derivatives and haven’t developed a good system for tracking down docs or debugging issues yet.

The issue is that fetchFromGitHub produces a fixed-output derivation (FOD), so if you just add fetchSubmodules = true; without re-generating the hash, the old one will be used (which doesn’t include the submodule).

So, if you set hash = "";, rebuild, and use the new hash that’s printed, it should work.

To verify, you can build the following file:

# anki.nix
{
  nixpkgs ? fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-unstable",
  pkgs ? import nixpkgs {
    config = { };
    overlays = [ ];
  },
  lib ? pkgs.lib,
}:
let
  fsrs4anki-helper = pkgs.anki-utils.buildAnkiAddon (finalAttrs: {
    pname = "fsrs4anki-helper";
    version = "24.06.3-unstable-2025-10-24";

    src = pkgs.fetchFromGitHub {
      owner = "open-spaced-repetition";
      repo = "fsrs4anki-helper";
      rev = "2bd5fb0816885990e73a7e95bf07690c2e47c368";
      hash = "sha256-Vu99QaMb++Umke6ANC83EGPQJSa3rnGCnhBVP/zm7V8=";
      fetchSubmodules = true;
    };
  });
in
pkgs.anki.withAddons [
  fsrs4anki-helper
]
nix-build anki.nix && ./result/bin/anki -b /tmp/anki-test

PS: I’ve opened a PR to include the addon in Nixpkgs:

Also, feel free to contribute any other missing addons so others could use them, and if you do, feel free to ping me for review as well.

1 Like

Beautiful. Thank you for taking the time to look at this! Re-generating the hash was the key. Looks like I just didn’t understand how fetchFromGitHub was working. Following your advice, I was able to get fsrs4anki-helper to build and have verified that it’s initializing and functioning as expected. I also appreciate you taking the time to open a PR to have it included in nixpkgs.

I’m building about nine other add-ons outside of this one, six of which I’ve verified are building and working as expected. I’ll study your PR, read through the packaging tutorial/nixpkgs reference and see about opening some PR’s for the add-ons I’ve gotten working.

Thanks again! Not knowing what I was doing wrong was driving me nuts.

1 Like