diff --git a/source/guides/recipes/add-binary-cache.md b/source/guides/recipes/add-binary-cache.md index e360b63b9..2d743070f 100755 --- a/source/guides/recipes/add-binary-cache.md +++ b/source/guides/recipes/add-binary-cache.md @@ -1,22 +1,22 @@ (custom-binary-cache)= # Configure Nix to use a custom binary cache -Nix can be configured to use a binary cache with the [`substituters`](https://nix.dev/manual/nix/2.21/command-ref/conf-file.html#conf-substituters) and [`trusted-public-keys`](https://nix.dev/manual/nix/2.21/command-ref/conf-file.html#conf-trusted-public-keys) settings, either exclusively or in addition to cache.nixos.org. +Nix can be configured to use a binary cache with the [`substituters`](https://nix.dev/manual/nix/latest/command-ref/conf-file.html#conf-substituters) and [`trusted-public-keys`](https://nix.dev/manual/nix/latest/command-ref/conf-file.html#conf-trusted-public-keys) settings, either exclusively or in addition to cache.nixos.org. :::{tip} Follow the tutorial to [set up an HTTP binary cache](setup-http-binary-cache) and create a key pair for signing store objects. ::: -For example, given a binary cache at `https://example.org` with public key `My56...Q==%`, and some derivation in `default.nix`, make Nix exclusively use that cache once by passing [settings as command line flags](https://nix.dev/manual/nix/2.21/command-ref/conf-file#command-line-flags): +For example, given a binary cache at `https://example.org` with public key `My56...Q==%`, and some derivation in `default.nix`, make Nix exclusively use that cache once by passing [settings as command line flags](https://nix.dev/manual/nix/latest/command-ref/conf-file#command-line-flags): ```shell-session $ nix-build --substituters https://example.org --trusted-public-keys example.org:My56...Q==% ``` -To permanently use the custom cache in addition to the public cache, add to the [Nix configuration file](https://nix.dev/manual/nix/2.21/command-ref/conf-file#configuration-file): +To permanently configure trying the custom cache before the public cache, add it as `extra-substiters` with lower `priority` value to the [Nix configuration file](https://nix.dev/manual/nix/latest/command-ref/conf-file#configuration-file): ```shell-session -$ echo "extra-substituters = https://example.org" >> /etc/nix/nix.conf +$ echo "extra-substituters = https://example.org?priority=30" >> /etc/nix/nix.conf $ echo "extra-trusted-public-keys = example.org:My56...Q==%" >> /etc/nix/nix.conf ``` @@ -33,9 +33,13 @@ On NixOS, Nix is configured through the [`nix.settings`](https://search.nixos.or ```nix { ... }: { nix.settings = { - substituters = [ "https://example.org" ]; + substituters = [ "https://example.org?priority=30" ]; trusted-public-keys = [ "example.org:My56...Q==%" ]; }; } ``` :::: + +:::{tip} +Use [remote build machines](distributed-build-setup-tutorial) as preferred binary caches to reduce your external traffic. +::: diff --git a/source/tutorials/nixos/distributed-builds-setup.md b/source/tutorials/nixos/distributed-builds-setup.md index 933569911..9268487d1 100644 --- a/source/tutorials/nixos/distributed-builds-setup.md +++ b/source/tutorials/nixos/distributed-builds-setup.md @@ -293,7 +293,7 @@ To maximise parallelism, enable automatic garbage collection, and prevent Nix bu ``` :::{tip} -Refer to the [Nix reference manual](https://nix.dev/manual/nix/2.23/command-ref/conf-file) for details on the options available in [`nix.settings`](https://search.nixos.org/options?show=nix.settings). +Refer to the [Nix reference manual](https://nix.dev/manual/nix/latest/command-ref/conf-file) for details on the options available in [`nix.settings`](https://search.nixos.org/options?show=nix.settings). ::: Remote builders can have different performance characteristics. @@ -314,6 +314,10 @@ Set the `nix.buildMachines.*.publicHostKey` field to each remote builder's publi To set up multiple builders, repeat the instructions in the [](set-up-remote-builder) section for each remote builder. Add all new remote builders to the `nix.buildMachines` attribute shown in the [](set-up-distributed-builds) section. +:::{tip} +Configure remote build machines to [host a binary cache](setup-http-binary-cache) and use them as [preferred binary caches](custom-binary-cache) to reduce your external traffic. +::: + ## Alternatives - [nixbuild.net](https://nixbuild.net) - Nix remote builders as a service