depot/pkgs/development/dhall-modules/lib.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

25 lines
696 B
Nix

{ 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;
}