Skip to content

chore: update nix flake #10485

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
75 changes: 45 additions & 30 deletions flake.lock

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

87 changes: 46 additions & 41 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,52 +1,57 @@
{
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";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
solc = {
url = "github:hellwolf/solc.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
inputs = { nixpkgs.follows = "nixpkgs"; };
};
};

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

# Environment variables
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.libusb1 ];
};
});
lib = pkgs.lib;
toolchain = fenix.packages.${system}.stable.toolchain;
in {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
pkg-config
solc_0_8_27
# default for foundry's tests
(solc.mkDefault pkgs solc_0_8_27)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest solc is now 0.8.30

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unstable unfortunately doesn't have 0.8.30 yet but i've just updated it to use solc directly from nixpkgs instead of needing on overlay per @beeb suggestion

toolchain
];
buildInputs = lib.optionals pkgs.stdenv.isDarwin
[ pkgs.darwin.apple_sdk.frameworks.AppKit ];

packages = with pkgs; [ rust-analyzer-unwrapped ];

shellHook = ''
# Directly set CFLAGS to what we need.
# This will overwrite any CFLAGS inherited from the parent environment.
# -O2: Enable optimization (for _FORTIFY_SOURCE and jemalloc performance).
# -DJEMALLOC_STRERROR_R_RETURNS_CHAR_P: Hint for jemalloc's strerror_r usage.
export CFLAGS="-O2 -DJEMALLOC_STRERROR_R_RETURNS_CHAR_P"

# Simple trim of whitespace
export CFLAGS=$(echo "$CFLAGS" | xargs)
'';

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