Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.1.0 flake #947

Draft
wants to merge 22 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{ system ? builtins.currentSystem, src ? ./.
, pkgs ? (import ./nix { inherit system src; }).pkgs }:
pkgs.mantis
let
flake = builtins.getFlake (toString ./.);
in
flake.pkgs.${builtins.currentSystem}.mantis
212 changes: 212 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 80 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
description = "Mantis flake";

inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url =
"github:nixos/nixpkgs?rev=a98302aa9b9628915878a6ea9776c40a0bb02950";
nixpkgs-sbt = {
url = "github:nixos/nixpkgs?rev=e2bb73ce5f786b83e984b80199112f86b8a6cc9d";
flake = false;
};
nixpkgs-kevm = {
url = "github:nixos/nixpkgs?rev=df25e214c8e662d693ef89e45ce56bbf58d6c59e";
flake = false;
};
sbtix = {
url =
"github:input-output-hk/Sbtix?rev=7b969a5641fce10500ca51cbe88af4ea160d7064";
flake = false;
};
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
mantis-faucet-web.url = "github:input-output-hk/mantis-faucet-web";
mantis-explorer.url = "github:input-output-hk/mantis-explorer";
};

outputs = { self, nixpkgs, flake-utils, ... }@inputs:
let
overlay = import ./nix/overlay.nix inputs;

pkgsForSystem = system:
(import nixpkgs) {
inherit system;
overlays = [ overlay ];
};

mkHydraUtils = mkPkgs:
let
# nothing in lib should really depend on the system
libPkgs = mkPkgs "x86_64-linux";
# [attrset] -> attrset
recursiveMerge = libPkgs.lib.foldr libPkgs.lib.recursiveUpdate { };
mkHydraJobsForSystem = attrs: system:
recursiveMerge
(map (n: { "${n}"."${system}" = (mkPkgs system)."${n}"; }) attrs);
in {
collectHydraSets = jobSets: { hydraJobs = recursiveMerge jobSets; };
mkHydraSet = attrs: systems:
recursiveMerge (map (mkHydraJobsForSystem attrs) systems);
};

hydraUtils = mkHydraUtils pkgsForSystem;
inherit (hydraUtils) collectHydraSets mkHydraSet;

in flake-utils.lib.eachDefaultSystem (system: rec {
pkgs = pkgsForSystem system;
legacyPackages = pkgs;

defaultPackage = pkgs.mantis;
devShell = pkgs.mkShell { nativeBuildInputs = with pkgs; [ solc sbt ]; };
apps.mantis = flake-utils.lib.mkApp { drv = pkgs.mantis; };
defaultApp = apps.mantis;
}) // (collectHydraSets [
(mkHydraSet [
"mantis"
"kevm"
"iele"

"mantis-entrypoint"
"mantis-faucet-entrypoint"

"mantis-explorer-evm"
"mantis-explorer-iele"
"mantis-explorer-kevm"

"mantis-faucet-web-evm"
"mantis-faucet-web-iele"
"mantis-faucet-web-kevm"
] [ "x86_64-linux" ])
]);
}
25 changes: 0 additions & 25 deletions nix/default.nix

This file was deleted.

11 changes: 11 additions & 0 deletions nix/entrypoint.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ lib, writeBashBinChecked, awscli, mantis, coreutils, gnugrep, gnused, kevm
, iele }:
writeBashBinChecked "mantis-entrypoint" ''
set -exuo pipefail

export PATH="${
lib.makeBinPath [ coreutils mantis awscli gnugrep gnused kevm iele ]
}"

${builtins.readFile ./entrypoint.sh}
''
39 changes: 39 additions & 0 deletions nix/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

set -exuo pipefail

mkdir -p /tmp "$NOMAD_TASK_DIR/mantis"
cd "$NOMAD_TASK_DIR"

if [ -n "${DAG_NAME:-}" ]; then
if [ -f "ethash/$DAG_NAME" ]; then
echo "found existing DAG"
sha256sum "ethash/$DAG_NAME"
else
mkdir -p ethash
aws \
--endpoint-url "$MONITORING_ADDR" \
s3 cp \
"s3://mantis-kevm-dag/$DAG_NAME" \
"ethash/$DAG_NAME" \
|| echo "Unable to download DAG, skipping."
fi
fi

set +x
echo "Waiting for $REQUIRED_PEER_COUNT peers to show up in the config"
until [ "$(grep -c enode mantis.conf)" -ge "$REQUIRED_PEER_COUNT" ]; do
sleep 1
done
set -x

if [ -n "${COINBASE:-}" ]; then
mkdir -p "$NOMAD_SECRETS_DIR/keystore"
cp "$NOMAD_SECRETS_DIR/account" "$NOMAD_SECRETS_DIR/keystore/UTC--2020-10-16T14-48-29.47Z-$COINBASE"
fi

ulimit -c unlimited
ulimit -n 2048
cp mantis.conf running.conf

exec mantis "-Duser.home=$NOMAD_TASK_DIR" "$@"
Loading