diff --git a/nix/rust.nix b/nix/rust.nix deleted file mode 100644 index eec64ccd7..000000000 --- a/nix/rust.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ sources ? import ./sources.nix }: - -let - pkgs = - import sources.nixpkgs {overlays = [ (import sources.nixpkgs-mozilla) ]; }; - channel = "nightly"; - date = "2020-11-19"; - targets = []; - chan = pkgs.rustChannelOfTargets channel date targets; -in chan diff --git a/nix/scripts.nix b/nix/scripts.nix deleted file mode 100644 index d5e3e344b..000000000 --- a/nix/scripts.nix +++ /dev/null @@ -1,83 +0,0 @@ -# An overlay for custom scripts -final: prev: { - # Run a local minikube cluster. minikube config controlled with $MINIKUBE_ARGS - # Minimum requirements: - # * User can use Docker - # * Docker supports BuildKit - whcluster = final.writeShellScriptBin "whcluster" '' - set -e - default_minikube_args="--cpus=10 --memory=10gb --disk-size=200gb --driver=kvm2 -p minikube-$USER" - export MINIKUBE_ARGS=''${MINIKUBE_ARGS:-$default_minikube_args} - ${final.minikube}/bin/minikube start $MINIKUBE_ARGS - ${final.whinotify}/bin/whinotify - ${final.whkube}/bin/whkube - ''; - - # Change current kubectl context to the wormhole namespace - whkube = final.writeShellScriptBin "whkube" ''${final.kubectl}/bin/kubectl config set-context --current --namespace=wormhole''; - - # Run tilt on the local cluster. Takes guardian count as argument. - whtilt = final.writeShellScriptBin "whtilt" '' - tilt_port=''${1:-10350} - n_guardians=''${2:-5} - echo "Starting Tilt with $n_guardians guardians" - ${final.killall}/bin/killall tilt - ${final.tilt}/bin/tilt up --update-mode exec --port $tilt_port -- --num=$n_guardians --pyth --explorer - ''; - - # increase sysctl value for inotify watch count to sufficient level - whinotify = final.writeShellScriptBin "whinotify" '' - ${final.minikube}/bin/minikube ssh -p minikube-$USER 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' - ''; - - # one-stop-shop for setting up a cluster on a remote machine and - # running tilt on it. MINIKUBE_ARGS defaults expect the remote to be - # beefy. - # - # Usage: whremote - # - # Minimum remote machine requirements: - # * Can run whcluster (see above) - # * Remote user has a working nix installation (single/multi user) - # - # Remote machine nice-to-haves: - # * You have passwordless/cached session access to the remote - - # * The remote is more powerful than your local machine. If not, use whcluster + whtilt locally instead. - whremote = final.writeShellScriptBin "whremote" '' - set -x - set -e - remote_machine=$1 - tilt_port=''${2:-10350} - - explorer_port=''${EXPLORER_PORT:-8001} - guardian_grpc_port=''${GUARDIAN_GRPC_PORT:-8080} - eth_jsonrpc_port=''${ETH_JSONRPC_PORT:-8545} - envoy_admin_port=''${ENVOY_PROXY_ADMIN_PORT:-9901} - - # Use Mutagen to watch local repo and sync it with remote_machine's ~/wormhole - ${final.mutagen}/bin/mutagen sync terminate whremote-sync || true - ${final.mutagen}/bin/mutagen sync create -n whremote-sync . $remote_machine:~/wormhole - ${final.mutagen}/bin/mutagen sync flush whremote-sync - - # Use larger cpu-count and memory values on the remote - export MINIKUBE_ARGS=''${MINIKUBE_ARGS:='--cpus=30 --memory=110g --disk-size=500gb --driver=kvm2 -p minikube-$USER'} - - # Set up/update the remote minikube cluster with whcluster - ssh $remote_machine \ - ". ~/.bash_profile; . ~/.zprofile; . ~/.profile; \ - cd wormhole && \ - nix-shell --option sandbox false --command ' MINIKUBE_ARGS=\"$MINIKUBE_ARGS\" whcluster'" - - # Run tilt using whtilt on the remote and forward its default port to localhost - ssh \ - -L $tilt_port:127.0.0.1:$tilt_port \ - -L $explorer_port:127.0.0.1:$explorer_port \ - -L $guardian_grpc_port:127.0.0.1:$guardian_grpc_port \ - -L $eth_jsonrpc_port:127.0.0.1:$eth_jsonrpc_port \ - -L $envoy_admin_port:127.0.0.1:$envoy_admin_port \ - $remote_machine \ - ". ~/.bash_profile; . ~/.zprofile; . ~/.profile; \ - cd wormhole && \ - nix-shell --option sandbox false --command 'whtilt $tilt_port $n_guardians'" - ''; -} diff --git a/nix/sources.json b/nix/sources.json deleted file mode 100644 index 2c82c8b95..000000000 --- a/nix/sources.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "cargo2nix": { - "branch": "master", - "description": "Build Rust crates with Nix", - "homepage": "", - "owner": "cargo2nix", - "repo": "cargo2nix", - "rev": "c491edfb1b2721c8202afe4051ce7b44adfb668d", - "sha256": "0aby21f72314qfmkqcdv7wpw6cywn7isr7gsh8gz992cn2szjpg4", - "type": "tarball", - "url": "https://github.com/cargo2nix/cargo2nix/archive/c491edfb1b2721c8202afe4051ce7b44adfb668d.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "niv": { - "branch": "master", - "description": "Easy dependency management for Nix projects", - "homepage": "https://github.com/nmattia/niv", - "owner": "nmattia", - "repo": "niv", - "rev": "e0ca65c81a2d7a4d82a189f1e23a48d59ad42070", - "sha256": "1pq9nh1d8nn3xvbdny8fafzw87mj7gsmp6pxkdl65w2g18rmcmzx", - "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/e0ca65c81a2d7a4d82a189f1e23a48d59ad42070.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs": { - "branch": "release-21.05", - "description": "Nix Packages collection", - "homepage": "", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "9d6766c0f0b3b03bd63ffc08b2e23e476145719d", - "sha256": "1hsr5zcmvbakpvzj1b5d2vz7195mbhvv58slplgwglxq8glnl9ff", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/9d6766c0f0b3b03bd63ffc08b2e23e476145719d.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "rust-overlay": { - "branch": "master", - "description": "Pure and reproducible nix overlay for binary distributed rust toolchains", - "homepage": "", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "a3873f83ed5fe58c4c6af09700d27b54aa19b986", - "sha256": "07hll4yalziyzd68gg518kmxs6y31bb2y3ilp1hw4lpbj1jyj4k7", - "type": "tarball", - "url": "https://github.com/oxalica/rust-overlay/archive/a3873f83ed5fe58c4c6af09700d27b54aa19b986.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } -} diff --git a/nix/sources.nix b/nix/sources.nix deleted file mode 100644 index 1938409dd..000000000 --- a/nix/sources.nix +++ /dev/null @@ -1,174 +0,0 @@ -# This file has been generated by Niv. - -let - - # - # The fetchers. fetch_ fetches specs of type . - # - - fetch_file = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } - else - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; - - fetch_tarball = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } - else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; - - fetch_git = name: spec: - let - ref = - if spec ? ref then spec.ref else - if spec ? branch then "refs/heads/${spec.branch}" else - if spec ? tag then "refs/tags/${spec.tag}" else - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; - in - builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; - - fetch_local = spec: spec.path; - - fetch_builtin-tarball = name: throw - ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=tarball -a builtin=true''; - - fetch_builtin-url = name: throw - ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=file -a builtin=true''; - - # - # Various helpers - # - - # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 - sanitizeName = name: - ( - concatMapStrings (s: if builtins.isList s then "-" else s) - ( - builtins.split "[^[:alnum:]+._?=-]+" - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) - ) - ); - - # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: system: - let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; - hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; - hasThisAsNixpkgsPath = == ./.; - in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import {} - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; - - # The actual fetching function. - fetch = pkgs: name: spec: - - if ! builtins.hasAttr "type" spec then - abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs name spec - else if spec.type == "tarball" then fetch_tarball pkgs name spec - else if spec.type == "git" then fetch_git name spec - else if spec.type == "local" then fetch_local spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball name - else if spec.type == "builtin-url" then fetch_builtin-url name - else - abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; - - # If the environment variable NIV_OVERRIDE_${name} is set, then use - # the path directly as opposed to the fetched source. - replace = name: drv: - let - saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; - ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; - in - if ersatz == "" then drv else - # this turns the string into an actual Nix path (for both absolute and - # relative paths) - if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; - - # Ports of functions for older nix versions - - # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 - stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 - stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatMapStrings = f: list: concatStrings (map f list); - concatStrings = builtins.concatStringsSep ""; - - # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 - optionalAttrs = cond: as: if cond then as else {}; - - # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchTarball; - in - if lessThan nixVersion "1.12" then - fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchTarball attrs; - - # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchurl; - in - if lessThan nixVersion "1.12" then - fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchurl attrs; - - # Create the final "sources" from the config - mkSources = config: - mapAttrs ( - name: spec: - if builtins.hasAttr "outPath" spec - then abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); } - ) config.sources; - - # The "config" used by the fetchers - mkConfig = - { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null - , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) - , system ? builtins.currentSystem - , pkgs ? mkPkgs sources system - }: rec { - # The sources, i.e. the attribute set of spec name to spec - inherit sources; - - # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers - inherit pkgs; - }; - -in -mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/nix/tilt.nix b/nix/tilt.nix deleted file mode 100644 index c7e6f016a..000000000 --- a/nix/tilt.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ lib, buildGoModule, fetchFromGitHub, makeWrapper}: - -buildGoModule rec { - pname = "tilt"; - /* Do not use "dev" as a version. If you do, Tilt will consider itself - running in development environment and try to serve assets from the - source tree, which is not there once build completes. */ - version = "0.22.5"; - - src = fetchFromGitHub { - owner = "tilt-dev"; - repo = pname; - rev = "39122ff70"; # right after v0.22.5 - sha256 = null; - }; - vendorSha256 = null; - - subPackages = [ "cmd/tilt" ]; - - buildInputs = [makeWrapper]; - - meta = with lib; { - description = "Local development tool to manage your developer instance when your team deploys to Kubernetes in production"; - homepage = "https://tilt.dev/"; - license = licenses.asl20; - maintainers = with maintainers; [ anton-dessiatov ]; - }; - doCheck = false; - # Explicitly ask to use the upstream-hosted web assets - postFixup = "wrapProgram $out/bin/tilt --set TILT_WEB_MODE prod"; -} diff --git a/nix/xargo.nix b/nix/xargo.nix deleted file mode 100644 index e47e577ad..000000000 --- a/nix/xargo.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ rust ? import ./rust.nix }: ( - self: super: { - xargo = self.rustPlatform.buildRustPackage rec { - pname = "xargo"; - src = self.fetchFromGitHub { - owner = "japaric"; - repo = pname; - }; - cargoSha256 = "unset"; - meta = with self.lib; { - description = "The rust cross-compilation tool"; - homepage = "https://github.com/japaric/xargo"; - maintainers = maintainers.tailhook; - }; - }; - } -) diff --git a/shell.nix b/shell.nix deleted file mode 100644 index b47ec9fa0..000000000 --- a/shell.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ sources ? import nix/sources.nix # Please specify inputs obtained from `sources` as separate params like below -, cargo2nix ? sources.cargo2nix -, nixpkgs ? sources.nixpkgs -, rust-olay ? import sources.rust-overlay -}: -let - scripts-olay = import ./nix/scripts.nix; - cargo2nix-olay = import "${cargo2nix}/overlay"; - tilt-olay = final: prev: { - tilt = prev.callPackage ./nix/tilt.nix {}; - }; - pkgs = import nixpkgs { - overlays = [ - # cargo2nix-olay - rust-olay - tilt-olay - scripts-olay - ]; - }; - cargo2nix-drv = import cargo2nix { - inherit nixpkgs; - }; -in -pkgs.mkShell { - nativeBuildInputs = ( - with pkgs; [ - go-ethereum - go - gopls - hidapi - libudev - niv - nodejs-16_x - openssl - pkgconfig - protobuf - python3 - python3Packages.autopep8 - whcluster - whinotify - whkube - whtilt - whremote - # ( - # rust-bin.stable."1.51.0".default.override { - # extensions = [ - # "rust-src" - # "rust-analysis" - # ]; - # } - # ) - # Provided on Fedora: - kubectl - minikube - tilt - # xargo - ] - ); - DOCKER_BUILDKIT = 1; - PROTOC = "${pkgs.protobuf}/bin/protoc"; - EMITTER_ADDRESS = "changeme"; -}