Overlays: Difference between revisions

imported>Asymmetric
m rename header to be more neutral
imported>C9xl7dq
Add an example of an R packages overlay
Line 244: Line 244:
=== Python Packages Overlay ===
=== Python Packages Overlay ===


Here is an example of Python packages overlay. The trick is to also override python itself with `packageOverrides`.
Here is an example of Python packages overlay. The trick is to also override python itself with <code>packageOverrides</code>.


Github issue with the snippet below: [[https://github.com/NixOS/nixpkgs/issues/26487#issuecomment-307363295]]
Github issue with the snippet below: [[https://github.com/NixOS/nixpkgs/issues/26487#issuecomment-307363295]]
Line 280: Line 280:
}
}
</syntaxhighlight>
</syntaxhighlight>
=== R Packages Overlay ===
Here is an example of an R packages overlay in which it can be seen how to provide different versions of packages then those provided with the used R version. It should be notice that in the case of R and Python the argument to `override` is named differently. Names of these can be find using <code>nix repl</code> and evaluating e.g. <code>python.override.__functionArgs</code>.
<syntaxhighlight lang="nix">
self: super:
{
  rPackages = super.rPackages.override {
    overrides = {
      rprojroot = super.rPackages.buildRPackage rec {
        name = "rprojroot-${version}";
        version = "2.0.2";
        src = super.fetchurl {
          url =
            "https://github.com/r-lib/rprojroot/archive/refs/tags/v2.0.2.tar.gz";
          sha256 = "1i0s1f7hla91yw1fdx0rn7c18dp6jwmg2mlww8dix1kk7qbxfjww";
        };
        nativeBuildInputs = [ super.R ];
      };
      here = super.rPackages.buildRPackage rec {
        name = "here-${version}";
        version = "1.0.1";
        src = super.fetchurl {
          url = "https://github.com/r-lib/here/archive/refs/tags/v1.0.1.tar.gz";
          sha256 = "0ky6sq6n8px3b70s10hy99sccf3vcjjpdhamql5dr7i9igsf8nqy";
        };
        nativeBuildInputs = [ super.R self.rPackages.rprojroot ];
        propagatedBuildInputs = [ self.rPackages.rprojroot ];
      };
    };
  };
}
</syntaxhighlight>


==== References ====
==== References ====