Skip to content

Commit

Permalink
vouch: remove duplication
Browse files Browse the repository at this point in the history
If we want to maintain multiple versions of packages, how do we reduce
the duplication of definitions?
  • Loading branch information
zimbatm committed Feb 19, 2024
1 parent e05b9bc commit 779ab65
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 50 deletions.
43 changes: 43 additions & 0 deletions pkgs/vouch/builder.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
buildGoModule,
mcl,
bls,
}: let
builder = {
version,
src,
vendorHash,
}: overrides: let
originalAttrs = {
inherit version src vendorHash;

pname = "vouch";

runVend = true;

buildInputs = [mcl bls];

doCheck = false;

meta = {
description = "An Ethereum 2 multi-node validator client";
homepage = "https://github.com/attestantio/vouch";
mainProgram = "vouch";
platforms = ["x86_64-linux"];
};

passthru.mkPackage = builder;
};

overridesType = builtins.typeOf overrides;

buildAttrs =
if overridesType == "set"
then originalAttrs // overrides
else if overridesType == "lambda"
then originalAttrs // (overrides originalAttrs)
else throw "unsupported type '${overridesType}' for the overrides";
in
buildGoModule buildAttrs;
in
builder
39 changes: 14 additions & 25 deletions pkgs/vouch/default.nix
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
{
buildGoModule,
callPackage,
fetchFromGitHub,
mcl,
bls,
}:
buildGoModule rec {
pname = "vouch";
version = "1.7.6";
}: let
mkVouch = callPackage ./builder.nix {inherit mcl bls;};
in
mkVouch rec {
version = "1.7.6";

src = fetchFromGitHub {
owner = "attestantio";
repo = pname;
rev = "v${version}";
hash = "sha256-zno/8uUkejS0zqOijGZdzknafavbvCU72uj/44on1f8=";
};
src = fetchFromGitHub {
owner = "attestantio";
repo = "vouch";
rev = "v${version}";
hash = "sha256-zno/8uUkejS0zqOijGZdzknafavbvCU72uj/44on1f8=";
};

runVend = true;
vendorHash = "sha256-zNHLg/nIKvIbMZtyDANxEQ04dygFHxwrM3JJkD1zcjo=";

buildInputs = [mcl bls];

doCheck = false;

meta = {
description = "An Ethereum 2 multi-node validator client";
homepage = "https://github.com/attestantio/vouch";
mainProgram = "vouch";
platforms = ["x86_64-linux"];
};
}
vendorHash = "sha256-zNHLg/nIKvIbMZtyDANxEQ04dygFHxwrM3JJkD1zcjo=";
} {}
39 changes: 14 additions & 25 deletions pkgs/vouch/unstable.nix
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
{
buildGoModule,
callPackage,
fetchFromGitHub,
mcl,
bls,
}:
buildGoModule rec {
pname = "vouch";
version = "1.8.0-beta.3";
}: let
mkVouch = callPackage ./builder.nix {inherit mcl bls;};
in
mkVouch rec {
version = "1.8.0-beta.3";

src = fetchFromGitHub {
owner = "attestantio";
repo = pname;
rev = "v${version}";
hash = "sha256-CK6cLXJYMQL+ZRv8bYabgQ0GeDWK8Jcek6d/Wow2LI0=";
};
src = fetchFromGitHub {
owner = "attestantio";
repo = "vouch";
rev = "v${version}";
hash = "sha256-CK6cLXJYMQL+ZRv8bYabgQ0GeDWK8Jcek6d/Wow2LI0=";
};

runVend = true;
vendorHash = "sha256-Mp+RA2L4mOe089ceyKh3m5Q8zLsdwyx6geMFrqbn5Dk=";

buildInputs = [mcl bls];

doCheck = false;

meta = {
description = "An Ethereum 2 multi-node validator client";
homepage = "https://github.com/attestantio/vouch";
mainProgram = "vouch";
platforms = ["x86_64-linux"];
};
}
vendorHash = "sha256-Mp+RA2L4mOe089ceyKh3m5Q8zLsdwyx6geMFrqbn5Dk=";
} {}

0 comments on commit 779ab65

Please sign in to comment.