jungle/web/content/cache/_index.md

1.7 KiB

title description date
Cache nix binary cache 2025-02-26T17:37:19+0100

We provide a binary cache in hut, with the aim of avoiding unnecessary recompilation of packages.

The cache should contain common packages from bsckpkgs, but we don't provide any guarantee that of what will be available in the cache, or for how long. We recommend following the latest version of the jungle flake to avoid cache misses.

Usage

From NixOS

In NixOS, we can add the cache through the nix.settings option, which will enable it for all builds in the system.

{ ... }: {
  nix.settings = {
    substituters = [ "https://jungle.bsc.es" ];
    trusted-public-keys = [ "jungle.bsc.es:pEc7MlAT0HEwLQYPtpkPLwRsGf80ZI26aj29zMw/HH0=" ];
  };
}

Interactively

The cache can also be specified in a per-command basis through the flags --substituters and --trusted-public-keys:

nix build --substituters "https://jungle.bsc.es/cache" --trusted-public-keys "jungle.bsc.es:pEc7MlAT0HEwLQYPtpkPLwRsGf80ZI26aj29zMw/HH0=" <...>

Nix configuration file (non-nixos)

If using nix outside of NixOS, you'll have to update nix.conf

echo "substituters = https://jungle.bsc.es" >> /etc/nix/nix.conf
echo "trusted-public-keys = jungle.bsc.es:pEc7MlAT0HEwLQYPtpkPLwRsGf80ZI26aj29zMw/HH0=" >> /etc/nix/nix.conf

Hint in flakes

By adding the configuration below to a flake.nix, when someone uses the flake, nix will interactively ask to trust and use the provided binary cache:

{
  nixConfig = {
    extra-substituters = [
      "https://jungle.bsc.es/cache"
    ];
    extra-trusted-public-keys = [
      "jungle.bsc.es:pEc7MlAT0HEwLQYPtpkPLwRsGf80ZI26aj29zMw/HH0="
    ];
  };
  outputs = { ... }: {
    ...
  };
}