Tar cannot exec ZSTD when extracting a source archive

I am trying to override the version of Anki.

Why?

The anki-bin package does not work with ibus input for some reason.
The anki package works with ibus input, but it is stuck with an old Anki version, which cannot open my existing Anki database.

Latest Anki versions are provided in a .tar.zst format, meaning they need to be extracted with zstd.
Although I have zstd installed on my system, tar cannot find it:

error: builder for '/nix/store/c6s13nvg32d57apcfd16pv2dk0acf027-anki-2.1.15.drv' failed with exit code 1;
       last 10 log lines:
       > Using pythonImportsCheckPhase
       > Sourcing python-namespaces-hook
       > qtPreHook
       > unpacking sources
       > unpacking source archive /nix/store/kxy4m10qz99j100vg0y05ygdy5zb9nz5-anki-2.1.60-linux-qt6.tar.zst
       > tar (child): zstd: Cannot exec: No such file or directory
       > tar (child): Error is not recoverable: exiting now
       > tar: Child returned status 2
       > tar: Error is not recoverable: exiting now
       > do not know how to unpack source archive /nix/store/kxy4m10qz99j100vg0y05ygdy5zb9nz5-anki-2.1.60-linux-qt6.tar.zst
       For full logs, run 'nix log /nix/store/c6s13nvg32d57apcfd16pv2dk0acf027-anki-2.1.15.drv'.

I’m a newcome to Nix, so I’m not sure how I would even go about telling the build system that zstd is available.

I’m using Home Manager for my version override, my home.nix looks like this:

{ config, pkgs, lib, ... }:

let
  anki = pkgs.anki.overrideAttrs (old: {
        src = builtins.fetchurl {
          url = "https://apps.ankiweb.net/downloads/archive/anki-2.1.60-linux-qt6.tar.zst";
          sha256 = "21780854c71a6414dab11b5e673ded45a0d0dabb167a5d9c3689dd2b6567cd35";
        };
      });
in
{
  home.packages = [ anki ];
  # other configuration
}

I also tried pkgs.fetchzip instead of builtins.fetchurl, but the same error occurs :confused:

System info

I’m building from a flake.

❯ nix-info      
system: "x86_64-linux", multi-user?: yes, version: nix-env (Nix) 2.11.1, channels(raitis): "", channels(root): "home-manager-22.11.tar.gz, nixos-22.11", nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Although I have zstd installed on my system, tar cannot find it:

This is because nix builds run in a sandbox, and thus don’t have access to your system’s software. To make zstd available to the build environment, you have to explicitly declare it:

anki = pkgs.anki.overrideAttrs (old: {
  src = /* ... */;
  nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.zstd ];
});
1 Like

Thank you, that did the trick! Odd that zstd wasn’t included by default in the build inputs, but at least the fix is easy :slight_smile:

There are far too many things included by default…

It’s easy to pull a complete gcc for no reason…