Skip to content
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

nix: fix build on macOS #3136

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Nix on Linux
name: nix

on:
push:
Expand All @@ -10,9 +10,14 @@ permissions: read-all

jobs:
nix:
runs-on: ubuntu-latest
name: nix-build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-14]
runs-on: ${{ matrix.os }}
timeout-minutes: 15 # NOTE (aseipp): keep in-sync with the build.yml timeout limit

name: flake check
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
Expand Down
25 changes: 17 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
pkgs.lib.all (re: builtins.match re relPath == null) regexes;
};

rust-version = pkgs.rust-bin.stable."1.76.0".default;
ourRustVersion = pkgs.rust-bin.stable."1.76.0".default;

ourRustPlatform = pkgs.makeRustPlatform {
rustc = rust-version;
cargo = rust-version;
rustc = ourRustVersion;
cargo = ourRustVersion;
};

# these are needed in both devShell and buildInputs
Expand All @@ -49,6 +49,12 @@
libiconv
];

# work around https://github.com/nextest-rs/nextest/issues/267
# this needs to exist in both the devShell and preCheck phase!
darwinNextestHack = pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
export DYLD_FALLBACK_LIBRARY_PATH=$(${ourRustVersion}/bin/rustc --print sysroot)/lib
'';

# NOTE (aseipp): on Linux, go ahead and use mold by default to improve
# link times a bit; mostly useful for debug build speed, but will help
# over time if we ever get more dependencies, too
Expand Down Expand Up @@ -97,7 +103,10 @@
NIX_JJ_GIT_HASH = self.rev or "";
CARGO_INCREMENTAL = "0";

preCheck = "export RUST_BACKTRACE=1";
preCheck = ''
export RUST_BACKTRACE=1
'' + darwinNextestHack;

postInstall = ''
$out/bin/jj util mangen > ./jj.1
installManPage ./jj.1
Expand Down Expand Up @@ -137,14 +146,14 @@
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# The CI checks against the latest nightly rustfmt, so we should too.
# NOTE (aseipp): include this FIRST before the rust-version override
# below; otherwise, it will be overridden by the rust-version and
# NOTE (aseipp): include this FIRST before the ourRustVersion override
# below; otherwise, it will be overridden by the ourRustVersion and
# we'll get stable rustfmt instead.
(rust-bin.selectLatestNightlyWith (toolchain: toolchain.rustfmt))

# Using the minimal profile with explicit "clippy" extension to avoid
# two versions of rustfmt
(rust-version.override {
(ourRustVersion.override {
extensions = [
"rust-src" # for rust-analyzer
"clippy"
Expand Down Expand Up @@ -181,7 +190,7 @@
export LIBSSH2_SYS_USE_PKG_CONFIG=1
'' + pkgs.lib.optionalString useMoldLinker ''
export RUSTFLAGS="-C link-arg=-fuse-ld=mold"
'';
'' + darwinNextestHack;
};
}));
}