Skip to content

Commit

Permalink
chore: add nix flake for dev shell (#6412)
Browse files Browse the repository at this point in the history
* chore: add nix flake for dev shell

* chore: use same flake-utils input for solc overlay

* chore: add macOS deps to nix flake
  • Loading branch information
beeb authored Dec 10, 2023
1 parent ef1989d commit 22f3d70
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 0 deletions.
109 changes: 109 additions & 0 deletions flake.lock

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

56 changes: 56 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
solc = {
url = "github:hellwolf/solc.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};

outputs = { self, nixpkgs, rust-overlay, flake-utils, solc }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default solc.overlay ];
};
lib = pkgs.lib;
toolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
extensions = [ "rustfmt" "clippy" "rust-src" ];
});
in
{
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
pkg-config
libusb1
] ++ lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.AppKit
];
buildInputs = [
pkgs.rust-analyzer-unwrapped
toolchain
];
packages = with pkgs; [
solc_0_8_20
(solc.mkDefault pkgs solc_0_8_20)
];

# Environment variables
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.libusb1 ];
};
});
}

0 comments on commit 22f3d70

Please sign in to comment.