Skip to content

Commit 8c8c59a

Browse files
authored
Use mold linker in nix env on Linux (#2628)
* nix: use mold on linux The build and test CI workflows already use mold. So this change only affects development in the nix environments on Linux systems. * CI: ensure nix dev env works on ARM based macOS * chore: fix flake.nix on MacOS * don't use pkgs in overlay I guess when the overlay is applied there is a `pkgs` in scope, but not sure. Probably more idiomatic to refer to attributes of `prev` which is the package set before applying the overlay. * CI: use `just build` instead of custom command Also covers the sequencer-sqlite crate.
1 parent d2ec298 commit 8c8c59a

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# This workflow ensures that the nix dev env works on ARM based macOS.
2+
name: Nix env macOS ARM
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- release-*
9+
tags:
10+
# YYYYMMDD
11+
- "20[0-9][0-9][0-1][0-9][0-3][0-9]*"
12+
pull_request:
13+
branches:
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
env:
21+
RUST_LOG: info,libp2p=off
22+
23+
jobs:
24+
nix-env-macos-arm:
25+
timeout-minutes: 60
26+
runs-on: macos-latest
27+
steps:
28+
- name: Install Nix
29+
uses: cachix/install-nix-action@v30
30+
31+
- name: Enable Cachix
32+
uses: cachix/cachix-action@v15
33+
# If PR is from a non-collaborator (e. g. dependabot) the secrets are missing and the login to cachix fails.
34+
continue-on-error: true
35+
with:
36+
name: espresso-systems-private
37+
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
38+
extraPullNames: nix-community
39+
skipPush: ${{ github.actor == 'dependabot[bot]' }}
40+
41+
- name: Checkout Repository
42+
uses: actions/checkout@v4
43+
with:
44+
submodules: recursive
45+
46+
- uses: Swatinem/rust-cache@v2
47+
name: Enable Rust Caching
48+
with:
49+
prefix-key: v0-rust
50+
51+
- name: Activate nix env
52+
run: nix develop --accept-flake-config -c echo Ok
53+
54+
- name: Build rust crates
55+
run: nix develop --accept-flake-config -c just build
56+
57+
- name: Build contracts
58+
run: nix develop --accept-flake-config -c forge build

flake.nix

+8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@
6666
solhint =
6767
solhintPkg { inherit (prev) buildNpmPackage fetchFromGitHub; };
6868
})
69+
70+
# The mold linker is around 50% faster on Linux than the default linker.
71+
# This overlays a mkShell that is configured to use mold on Linux.
72+
(final: prev: prev.lib.optionalAttrs prev.stdenv.isLinux {
73+
mkShell = prev.mkShell.override {
74+
stdenv = prev.stdenvAdapters.useMoldLinker prev.clangStdenv;
75+
};
76+
})
6977
];
7078
pkgs = import nixpkgs { inherit system overlays; };
7179
crossShell = { config }:

0 commit comments

Comments
 (0)