Skip to content

Commit

Permalink
Flake-based direnv setup for nixOS users
Browse files Browse the repository at this point in the history
  • Loading branch information
zah committed Feb 20, 2023
1 parent fad3ed6 commit e47387d
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
NBS_ONLY_LOAD_ENV_VARS=1 source env.sh

if command -v nix > /dev/null
then
export NIMBUS_NIX_ENV=1

cd nix
# watch_file tells direnv that changes to any of the watched files
# should trigger a re-evalution of the environment
watch_file flake.nix
watch_file flake.lock
watch_file shell.nix

mkdir -p .flake-profiles
eval "$(nix print-dev-env --profile ".flake-profiles/profile")"
fi
2 changes: 2 additions & 0 deletions nix/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Local file unique for each user
.flake-profiles/
43 changes: 43 additions & 0 deletions nix/flake.lock

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

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

inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11;
flake-utils.url = github:numtide/flake-utils;
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.simpleFlake {
inherit self nixpkgs;
name = "nimbus-eth2";
shell = ./shell.nix;
};
}
23 changes: 23 additions & 0 deletions nix/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{pkgs ? import <nixpkgs> {}}:
with pkgs;
mkShell {
buildInputs =
[
figlet
git
gnumake
rocksdb
]
++ lib.optionals (!stdenv.isDarwin) [
lsb-release
];

shellHook = ''
# By default, the Nix wrapper scripts for executing the system compilers
# will erase `-march=native` because this introduces impurity in the build.
# For the purposes of compiling Nimbus, this behavior is not desired:
export NIX_ENFORCE_NO_NATIVE=0
figlet "Welcome to Nimbus-eth1"
'';
}

0 comments on commit e47387d

Please sign in to comment.