Skip to content

Commit 2dbd8c9

Browse files
shaunkhzerosnackssveitser
authored
chore: update nix flake (#10485)
* update flake * update env variables * add nix.yml ci job Co-authored-by: sveitser <[email protected]> * review: use nixpkgs for solc --------- Co-authored-by: zerosnacks <[email protected]> Co-authored-by: zerosnacks <[email protected]> Co-authored-by: sveitser <[email protected]>
1 parent 01e9dc2 commit 2dbd8c9

File tree

3 files changed

+104
-123
lines changed

3 files changed

+104
-123
lines changed

.github/workflows/nix.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: nix
2+
3+
on:
4+
schedule:
5+
# Run weekly
6+
- cron: "0 0 * * SUN"
7+
workflow_dispatch:
8+
# Needed so we can run it manually
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
# Opens a PR with an updated flake.lock file
16+
update:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: cachix/install-nix-action@v30
20+
- uses: actions/checkout@v4
21+
- uses: DeterminateSystems/update-flake-lock@main
22+
with:
23+
pr-title: "Update flake.lock"
24+
pr-labels: |
25+
L-ignore
26+
A-dependencies
27+
28+
build:
29+
strategy:
30+
matrix:
31+
runs-on: [ubuntu-latest, macos-latest]
32+
runs-on: ${{ matrix.runs-on }}
33+
steps:
34+
- uses: cachix/install-nix-action@v30
35+
- uses: actions/checkout@v4
36+
37+
- name: Activate nix env
38+
run: nix develop -c echo Ok
39+
40+
- name: Check that we can compile all crates
41+
run: nix develop -c cargo check --all-targets

flake.lock

Lines changed: 26 additions & 79 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 37 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,45 @@
11
{
22
inputs = {
33
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
4-
flake-utils.url = "github:numtide/flake-utils";
5-
rust-overlay = {
6-
url = "github:oxalica/rust-overlay";
7-
inputs = {
8-
nixpkgs.follows = "nixpkgs";
9-
};
10-
};
11-
solc = {
12-
url = "github:hellwolf/solc.nix";
13-
inputs = {
14-
nixpkgs.follows = "nixpkgs";
15-
flake-utils.follows = "flake-utils";
16-
};
4+
fenix = {
5+
url = "github:nix-community/fenix";
6+
inputs.nixpkgs.follows = "nixpkgs";
177
};
188
};
199

20-
outputs = { self, nixpkgs, rust-overlay, flake-utils, solc }:
21-
flake-utils.lib.eachDefaultSystem (system:
22-
let
23-
pkgs = import nixpkgs {
24-
inherit system;
25-
overlays = [ rust-overlay.overlays.default solc.overlay ];
26-
};
27-
lib = pkgs.lib;
28-
toolchain = pkgs.rust-bin.stable.latest.default.override {
29-
extensions = [ "rustfmt" "clippy" "rust-src" ];
30-
};
31-
in
32-
{
33-
devShells.default = pkgs.mkShell {
34-
nativeBuildInputs = with pkgs; [
35-
pkg-config
36-
solc_0_8_23
37-
(solc.mkDefault pkgs solc_0_8_23)
38-
toolchain
39-
];
40-
buildInputs = lib.optionals pkgs.stdenv.isDarwin [
41-
pkgs.darwin.apple_sdk.frameworks.AppKit
42-
];
43-
packages = with pkgs; [
44-
rust-analyzer-unwrapped
45-
];
10+
outputs = { self, nixpkgs, fenix }:
11+
let eachSystem = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
12+
in {
13+
devShells = eachSystem (system:
14+
let
15+
pkgs = import nixpkgs {
16+
inherit system;
17+
overlays = [ fenix.overlays.default ];
18+
};
19+
20+
lib = pkgs.lib;
21+
toolchain = fenix.packages.${system}.stable.toolchain;
22+
in {
23+
default = pkgs.mkShell {
24+
nativeBuildInputs = with pkgs; [
25+
pkg-config
26+
toolchain
27+
28+
# test dependencies
29+
solc
30+
vyper
31+
nodejs
32+
];
33+
buildInputs = lib.optionals pkgs.stdenv.isDarwin
34+
[ pkgs.darwin.apple_sdk.frameworks.AppKit ];
4635

47-
# Environment variables
48-
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
49-
LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.libusb1 ];
50-
};
51-
});
36+
packages = with pkgs; [ rust-analyzer-unwrapped ];
37+
38+
# Environment variables
39+
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
40+
LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.libusb1 ];
41+
CFLAGS = "-DJEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE";
42+
};
43+
});
44+
};
5245
}

0 commit comments

Comments
 (0)