feat(buildGo): Add 'overrideGo' argument overriding function
This makes it possible to override arguments to the Go builders downstream in the style of `overrideAttrs` from standard nixpkgs derivations. For example, given a Nix value `foo` that builds a binary called `foo` the name of this binary could be changed and a new dependency on `somelib` added like so: foo.overrideGo(old: { name = "bar"; deps = old.deps ++ [ somelib ]; })
This commit is contained in:
parent
28e587b348
commit
6a526620e2
1 changed files with 14 additions and 2 deletions
16
buildGo.nix
16
buildGo.nix
|
@ -48,6 +48,13 @@ let
|
||||||
|
|
||||||
pathToName = p: replaceStrings ["/"] ["_"] (toString p);
|
pathToName = p: replaceStrings ["/"] ["_"] (toString p);
|
||||||
|
|
||||||
|
# Add an `overrideGo` attribute to a function result that works
|
||||||
|
# similar to `overrideAttrs`, but is used specifically for the
|
||||||
|
# arguments passed to Go builders.
|
||||||
|
makeOverridable = f: orig: (f orig) // {
|
||||||
|
overrideGo = new: makeOverridable f (orig // (new orig));
|
||||||
|
};
|
||||||
|
|
||||||
# High-level build functions
|
# High-level build functions
|
||||||
|
|
||||||
# Build a Go program out of the specified files and dependencies.
|
# Build a Go program out of the specified files and dependencies.
|
||||||
|
@ -130,6 +137,11 @@ let
|
||||||
inherit external;
|
inherit external;
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
# Only the high-level builder functions are exposed
|
# Only the high-level builder functions are exposed, but made
|
||||||
inherit program package proto grpc external;
|
# overrideable.
|
||||||
|
program = makeOverridable program;
|
||||||
|
package = makeOverridable package;
|
||||||
|
proto = makeOverridable proto;
|
||||||
|
grpc = makeOverridable grpc;
|
||||||
|
external = makeOverridable external;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue