fetchFromGitHub
pkgs.fetchFromGitHub
Functor
Docs pulled from | This Revision | 27 minutes ago
Contribute
Enhance the ecosystem with your expertise! Contribute to fill the gaps in documentation. Your input can make a difference.
Noogle detected
This is a Functor
Learn about functors
Implementation
The following is the current implementation of this function.
origArgs:
let
result = f origArgs;
# Re-call the function but with different arguments
overrideArgs = mirrorArgs (
/**
Change the arguments with which a certain function is called.
In some cases, you may find a list of possible attributes to pass in this function's `__functionArgs` attribute, but it will not be complete for an original function like `args@{foo, ...}: ...`, which accepts arbitrary attributes.
This function was provided by `lib.makeOverridable`.
*/
newArgs: makeOverridable f (origArgs // (if isFunction newArgs then newArgs origArgs else newArgs))
);
in
if isAttrs result then
result
// {
override = overrideArgs;
overrideDerivation =
fdrv: makeOverridable (mirrorArgs (args: overrideDerivation (f args) fdrv)) origArgs;
${if result ? overrideAttrs then "overrideAttrs" else null} =
/**
Override the attributes that were passed to `mkDerivation` in order to generate this derivation.
This function is provided by `lib.makeOverridable`, and indirectly by `callPackage` among others, in order to make the combination of `override` and `overrideAttrs` work.
Specifically, it re-adds the `override` attribute to the result of `overrideAttrs`.
The real implementation of `overrideAttrs` is provided by `stdenv.mkDerivation`.
*/
# NOTE: part of the above documentation had to be duplicated in `mkDerivation`'s `overrideAttrs`.
# design/tech debt issue: https://github.com/NixOS/nixpkgs/issues/273815
fdrv: makeOverridable (mirrorArgs (args: (f args).overrideAttrs fdrv)) origArgs;
}
else if isFunction result then
# Transform the result into a functor while propagating its arguments
setFunctionArgs result (functionArgs result)
// {
override = overrideArgs;
}
else
result