Skip to content

Commit

Permalink
feat(bundles): add genesis to bundles
Browse files Browse the repository at this point in the history
refactor(bundles): unify mkBundle and mkBundleNext
  • Loading branch information
cor committed Oct 19, 2023
1 parent c75a124 commit 1be46ac
Showing 1 changed file with 33 additions and 32 deletions.
65 changes: 33 additions & 32 deletions unionvisor/unionvisor.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,60 +24,61 @@
};
};

mkBundle = name: versions: meta:
mkBundle = { name, versions, genesis, meta, nextVersion ? "" }:
pkgs.linkFarm "union-bundle-${name}" ([
{
name = "meta.json";
path = pkgs.writeText "meta.json" (builtins.toJSON meta);
}
{
name = "unionvisor";
path = "${unionvisorAll.packages.unionvisor}/bin/unionvisor";
}
] ++ map
(version: {
name =
"${meta.versions_directory}/${version}/${meta.binary_name}";
path = pkgs.lib.getExe (get-flake "${inputs."${swapDotsWithUnderscores version}"}").packages.${system}.uniond;
})
versions);
mkNextBundle = name: versions: nextVersion: meta:
pkgs.linkFarm "union-bundle-${name}" ([
{
name = "meta.json";
path = pkgs.writeText "meta.json" (builtins.toJSON meta);
name = "genesis.json";
path = genesis;
}
{
name = "unionvisor";
path = "${unionvisorAll.packages.unionvisor}/bin/unionvisor";
}
{
name = "${meta.versions_directory}/${nextVersion}/${meta.binary_name}";
path = pkgs.lib.getExe self'.packages.uniond;
}
] ++ map
]
++ # add all `versions` to the bundle
map
(version: {
name =
"${meta.versions_directory}/${version}/${meta.binary_name}";
path = pkgs.lib.getExe (get-flake "${inputs."${swapDotsWithUnderscores version}"}").packages.${system}.uniond;
})
versions);
versions
++ # add `nextVersion` to the bundle if supplied
pkgs.lib.lists.optional (nextVersion != "") ({
name = "${meta.versions_directory}/${nextVersion}/${meta.binary_name}";
path = pkgs.lib.getExe self'.packages.uniond;
}));
in
{
inherit (unionvisorAll) checks;
packages = {
inherit (unionvisorAll.packages) unionvisor;
bundle-testnet =
mkBundle "testnet" [ "v0.8.0" "v0.9.0" "v0.10.0" "v0.11.0" "v0.12.0" "v0.13.0" ] {
binary_name = "uniond";
versions_directory = "versions";
fallback_version = "v0.8.0";
bundle-testnet-3 =
mkBundle {
name = "testnet-3";
versions = [ "v0.8.0" "v0.9.0" "v0.10.0" "v0.11.0" "v0.12.0" "v0.13.0" ];
genesis = ../networks/genesis/union-testnet-3/genesis.json;
meta = {
binary_name = "uniond";
versions_directory = "versions";
fallback_version = "v0.8.0";
};
};
bundle-testnet-next =
mkNextBundle "testnet" [ "v0.8.0" "v0.9.0" "v0.10.0" "v0.11.0" "v0.12.0" "v0.13.0" ] "v0.14.0" {
binary_name = "uniond";
versions_directory = "versions";
fallback_version = "v0.8.0";
mkBundle {
name = "testnet-3";
versions = [ "v0.8.0" "v0.9.0" "v0.10.0" "v0.11.0" "v0.12.0" "v0.13.0" ];
nextVersion = "v0.14.0";
genesis = ../networks/genesis/union-testnet-3/genesis.json;
meta = {
binary_name = "uniond";
versions_directory = "versions";
fallback_version = "v0.8.0";
};
};
};
};
Expand All @@ -90,7 +91,7 @@
enable = mkEnableOption "Unionvisor service";
bundle = mkOption {
type = types.package;
default = self.packages.${pkgs.system}.bundle-testnet;
default = self.packages.${pkgs.system}.bundle-testnet-3;
};
moniker = mkOption { type = types.str; };
};
Expand Down

0 comments on commit 1be46ac

Please sign in to comment.