Ca-derivations: Difference between revisions

imported>Mjbecze
m remove reference to ca-reference
The NGI0 Cache doesn't exist since at least summer of 2024
 
(6 intermediate revisions by 5 users not shown)
Line 12: Line 12:


<syntaxhighlight lang="nix">{ pkgs, ... }: {
<syntaxhighlight lang="nix">{ pkgs, ... }: {
   nix = {
   nix.settings.experimental-features = [
    package = pkgs.nixUnstable;
    "ca-derivations"
    extraOptions = ''
  ];
      experimental-features = ca-derivations ca-references
    '';
  };
}</syntaxhighlight>
}</syntaxhighlight>
=== Non NixOS ===
=== Non NixOS ===


TODO
Make sure the file `/etc/nix/nix.conf` exists and contains the following:
 
<syntaxhighlight lang="ini">
experimental-features = ca-derivations
</syntaxhighlight>


== Using CA derivations ==
== Using CA derivations ==


The feature is currently opt-in, meaning that each derivation must individually be marked as content-addressed. When using <code>nixpkgs-unstable</code>, this can be done by setting <code>__contentAddressed = true</code> in the call to mkDerivation.
The feature is opt-in, meaning that each derivation must individually be marked as content-addressed. When using <code>nixpkgs-unstable</code>, this can be done by setting <code>__contentAddressed = true</code> in the call to mkDerivation.


It is also possible to mark all the derivations as content-addressed by default, by passing <code>config.contentAddressedByDefault = true</code> as argument to nixpkgs.
It is also possible to mark all the derivations as content-addressed by default, by passing <code>config.contentAddressedByDefault = true</code> as argument to nixpkgs.
Be warned that although there’s a [https://hydra.ngi0.nixos.org/jobset/ca-test/nixpkgs hydra instance testing ''some stuff''], it’s not a channel blocker, and [https://cache.ngi0.nixos.org its associated binary cache] won’t contain nearly as many things as <code>cache.nixos.org</code>. So doing so will probably entail rebuilding most of your system yourself, and you ''might'' encounter some unexpected breakages.
To use the binary cache <code>cache.ngi0.nixos.org</code> to speed up your builds, merge the following into your <code>nix.conf</code>:
<pre>substituters = https://cache.ngi0.nixos.org/
trusted-public-keys = cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA=</pre>
== Ensuring that a derivation is properly content-addressed ==
== Ensuring that a derivation is properly content-addressed ==