diff --git a/web/content/hut/_index.md b/web/content/hut/_index.md index 4d70451..4297b72 100644 --- a/web/content/hut/_index.md +++ b/web/content/hut/_index.md @@ -13,6 +13,72 @@ which is available at `hut` or `xeon07`. It runs the following services: - Grafana: to plot the data in the web browser. - Slurmctld: to manage the SLURM nodes. - Gitlab runner: to run CI jobs from Gitlab. +- Nix binary cache: to serve cached nix builds This node is prone to interruptions from all the services it runs, so it is not a good candidate for low noise executions. + +# Binary cache + +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 +{ ... }: { + 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`: + +```sh +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` + +```bash +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: + +```nix +{ + nixConfig = { + extra-substituters = [ + "https://jungle.bsc.es/cache" + ]; + extra-trusted-public-keys = [ + "jungle.bsc.es:pEc7MlAT0HEwLQYPtpkPLwRsGf80ZI26aj29zMw/HH0=" + ]; + }; + outputs = { ... }: { + ... + }; +} +```