Unable to use fetchpatch

How should I make fetchpatch available in this code? Also, prev.patches doesn’t seem to be available.

I try to apply a patch to a Grafana, but Nix returns:
error: undefined variable 'fetchpatch'.

When I try to add fetchpatch to the input attrSet I get:
error: attribute 'fetchpatch' missing

The code below is in an imports list of my machine.

{
  pkgs,
  lib,
  config,
  utils,
  ...
}:

let
  grafanaPatched = pkgs.unstable.grafana.overrideAttrs (
    final: prev: {
      grafanaImages = fs.toSource {
        root = ./.;
        fileset = images;
      };
      patches = prev.patches ++ [
        (fetchpatch {
          name = "provision-organisations.patch";
          url = "https://github.com/grafana/grafana/commit/e3ba7dec1fb896080e07e52f4d9de33762964d7c.patch";
          sha256 = "";
        })
      ];
      postFixup = lib.strings.concatStrings [
        prev.postFixup
        ''
          # replacing some images
        ''
      ];
    }
  );
in
{
  services.grafana = {
    enable = true;
    package = grafanaPatched;
  };
}

try: pkgs.fetchpatch

1 Like