Skip to content

Commit

Permalink
Use mold linker in nix env on Linux (#2628)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
sveitser authored Feb 17, 2025
1 parent d2ec298 commit 8c8c59a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/nix-env-macos-arm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This workflow ensures that the nix dev env works on ARM based macOS.
name: Nix env macOS ARM

on:
push:
branches:
- main
- release-*
tags:
# YYYYMMDD
- "20[0-9][0-9][0-1][0-9][0-3][0-9]*"
pull_request:
branches:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
RUST_LOG: info,libp2p=off

jobs:
nix-env-macos-arm:
timeout-minutes: 60
runs-on: macos-latest
steps:
- name: Install Nix
uses: cachix/install-nix-action@v30

- name: Enable Cachix
uses: cachix/cachix-action@v15
# If PR is from a non-collaborator (e. g. dependabot) the secrets are missing and the login to cachix fails.
continue-on-error: true
with:
name: espresso-systems-private
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
extraPullNames: nix-community
skipPush: ${{ github.actor == 'dependabot[bot]' }}

- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive

- uses: Swatinem/rust-cache@v2
name: Enable Rust Caching
with:
prefix-key: v0-rust

- name: Activate nix env
run: nix develop --accept-flake-config -c echo Ok

- name: Build rust crates
run: nix develop --accept-flake-config -c just build

- name: Build contracts
run: nix develop --accept-flake-config -c forge build
8 changes: 8 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
solhint =
solhintPkg { inherit (prev) buildNpmPackage fetchFromGitHub; };
})

# The mold linker is around 50% faster on Linux than the default linker.
# This overlays a mkShell that is configured to use mold on Linux.
(final: prev: prev.lib.optionalAttrs prev.stdenv.isLinux {
mkShell = prev.mkShell.override {
stdenv = prev.stdenvAdapters.useMoldLinker prev.clangStdenv;
};
})
];
pkgs = import nixpkgs { inherit system overlays; };
crossShell = { config }:
Expand Down

0 comments on commit 8c8c59a

Please sign in to comment.