Skip to content

Commit

Permalink
nixfy
Browse files Browse the repository at this point in the history
Add nix related artifacts such that we can create a development
environment for nixos uses
  • Loading branch information
kayvank committed Oct 12, 2024
1 parent 291f123 commit 488bb05
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 106 deletions.
134 changes: 58 additions & 76 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,80 +8,62 @@

};
outputs = { self, nixpkgs, rust-overlay, flake-utils, foundry, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default foundry.overlay ];
};

toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
cargoTomlContents = builtins.readFile ./Cargo.toml;
version = (builtins.fromTOML cargoTomlContents).package.version;

ethereumEs = pkgs.rustPlatform.buildRustPackage {
inherit version;
name = "ethereumEs";
buildInputs = with pkgs; [ openssl ];
nativeBuildInputs = with pkgs; [ pkg-config openssl.dev ];

src = pkgs.lib.cleanSourceWith { src = self; };

cargoLock.lockFile = ./Cargo.lock;

GIT_COMMIT_HASH_SHORT = self.shortRev or "unknown";

};

packages = {
ethereumEs = ethereumEs;
default = packages.ethereumEs;
};

overlays.default = final: prev: { ethereumEs = packages.ethereumEs; };

gitRev = if (builtins.hasAttr "rev" self) then self.rev else "dirty";
in {
inherit packages overlays;

devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
foundry-bin

solc

toolchain
openssl
cargo-insta
pkg-config
eza
rust-analyzer-unwrapped

nodejs
nodePackages.typescript
nodePackages.typescript-language-server

docker
watchexec
cowsay
];
shellHook = ''
alias ls=eza
alias find=fd
echo "hello-world-avs" | cowsay
export RUST_SRC_PATH="${toolchain}/lib/rustlib/src/rust/library"
export CARGO_HOME="$(pwd)/.cargo"
export PATH="$CARGO_HOME/bin:$PATH"
export RUST_BACKTRACE=1
export CARGO_NET_GIT_FETCH_WITH_CLI=true
export ETH_RPC_URL='127.0.0.1:8545'
export ETHERSCAN_API_KEY='11'
cargo install cargo-expand
cargo install --version 0.5.7 sqlx-cli --no-default-features --features postgres
# cargo install cargo-udeps ## lets not do this till we ready for prod
cargo install bunyan
'';
};
});
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default foundry.overlay ];
};

toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
cargoTomlContents = builtins.readFile ./Cargo.toml;
version = (builtins.fromTOML cargoTomlContents).package.version;

ethereumEs = pkgs.rustPlatform.buildRustPackage {
inherit version;
name = "ethereumEs";
buildInputs = with pkgs; [ openssl ];
nativeBuildInputs = with pkgs; [ pkg-config openssl.dev ];

src = pkgs.lib.cleanSourceWith { src = self; };

cargoLock.lockFile = ./Cargo.lock;

# GIT_COMMIT_HASH_SHORT = self.shortRev or "unknown";

};
in {

overlays.default = final: prev: { ethereumEs = ethereumEs; };

gitRev = if (builtins.hasAttr "rev" self) then self.rev else "dirty";

devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
foundry-bin
solc
toolchain
openssl
cargo-insta
pkg-config
eza
rust-analyzer-unwrapped
nodejs_20
nodePackages.typescript
nodePackages.typescript-language-server
watchexec
];
shellHook = ''
export RUST_SRC_PATH="${toolchain}/lib/rustlib/src/rust/library"
export CARGO_HOME="$(pwd)/.cargo"
export PATH="$CARGO_HOME/bin:$PATH"
export RUST_BACKTRACE=1
export CARGO_NET_GIT_FETCH_WITH_CLI=true
export ETH_RPC_URL='127.0.0.1:8545'
export ETHERSCAN_API_KEY='fake-key'
export HOLESKY_PRIVATE_KEY='fake-key'
export PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
'';
};
});
}
48 changes: 18 additions & 30 deletions package-lock.json

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

0 comments on commit 488bb05

Please sign in to comment.