summaryrefslogtreecommitdiff
path: root/pkgs/development/dhall-modules/lib.nix
blob: 826fea8194838e6a64347eb9a87b7969896764cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{ lib }:

let
  # This is essentially the same thing as `lib.makeOverridable`, except storing
  # the override method in a method named `overridePackage` so that it's not
  # shadowed by the `override` method added by `callPackage`
  makePackageOverridable =
    f: args:
    let
      result = lib.makeOverridable f args;

      copyArgs = g: lib.setFunctionArgs g (lib.functionArgs f);

      overrideWith = update: args // (if lib.isFunction update then update args else update);

      overridePackage = copyArgs (update: makePackageOverridable f (overrideWith update));

    in
    result // { inherit overridePackage; };

in
lib
// {
  inherit makePackageOverridable;
}