Skip to content

Commit d60ff58

Browse files
committed
Fix Linux builds and documentation issues
- Add correct Linux hashes for solana-release and platform-tools - Replace manual wrapper scripts with wrapProgram in solana-tools.nix - Enable CGO for geth builds on Linux with proper dependencies - Add dontStrip = true to solana-node to avoid stripping text files - Fix documentation generation by making devshells conditional - Add devshell flake module to docs generation context - All packages now build correctly and documentation generates successfully
1 parent 04f2363 commit d60ff58

File tree

4 files changed

+30
-23
lines changed

4 files changed

+30
-23
lines changed

docs/default.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636

3737
docsFlake = flake-parts-lib.mkFlake { inherit inputs; } {
3838
systems = [ system ];
39-
imports = [ "${inputs.flake-parts-website}/render/render-module.nix" ];
39+
imports = [
40+
"${inputs.flake-parts-website}/render/render-module.nix"
41+
inputs.devshell.flakeModule
42+
];
4043
perSystem.render.officialFlakeInputs = inputs;
4144
perSystem.render.inputs =
4245
{

flakeModules/ethereum-development/default.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ in {
1616
pkgs,
1717
self',
1818
system,
19+
options,
1920
...
2021
}: let
2122
cfg = config.ethereum-development;
@@ -30,7 +31,7 @@ in {
3031
};
3132
};
3233

33-
config = lib.mkIf cfg.enable {
34+
config = lib.mkIf cfg.enable (lib.optionalAttrs (options ? devshells) {
3435
devshells.ethereum = {
3536
name = "ethereum-development";
3637

@@ -66,7 +67,7 @@ in {
6667
lighthouse bn --network ${if cfg.network == "mainnet" then "mainnet" else cfg.network} --datadir ./data/lighthouse
6768
'';
6869
};
69-
};
70+
});
7071
}
7172
);
7273
};

packages/ethereum.nix

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,19 @@
2222
subPackages = [ "cmd/geth" ];
2323

2424
# Build configuration
25-
env.CGO_ENABLED = "0";
25+
env.CGO_ENABLED = if pkgs.stdenv.isLinux then "1" else "0";
2626
buildFlags = [ "-mod=readonly" ];
2727

28+
# Add necessary inputs for CGO on Linux
29+
buildInputs = with pkgs; lib.optionals stdenv.isLinux [
30+
glibc
31+
gcc
32+
];
33+
34+
nativeBuildInputs = with pkgs; lib.optionals stdenv.isLinux [
35+
pkg-config
36+
];
37+
2838
meta = with pkgs.lib; {
2939
description = "Official Go implementation of the Ethereum protocol";
3040
homepage = "https://github.com/ethereum/go-ethereum";

packages/solana-tools.nix

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ let
4747
sha256 = if pkgs.stdenv.isDarwin then
4848
"sha256-upgxwAEvh11+IKVQ1FaZGlx8Z8Ps0CEScsbu4Hv3WH0=" # v2.0.22 macOS ARM64 hash
4949
else
50-
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; # TODO: Get correct Linux hash with: nix store prefetch-file --json https://github.com/anza-xyz/agave/releases/download/v2.0.22/solana-release-x86_64-unknown-linux-gnu.tar.bz2
50+
"sha256-kDXSnCXZHYSQt18AtnuBHcqyK9wxEemNx9on7CKW328="; # v2.0.22 Linux x86_64 hash
5151
};
5252

5353
# Platform tools source
@@ -59,7 +59,7 @@ let
5959
sha256 = if pkgs.stdenv.isDarwin then
6060
"sha256-eZ5M/O444icVXIP7IpT5b5SoQ9QuAcA1n7cSjiIW0t0=" # v1.48 macOS ARM64 hash
6161
else
62-
"sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; # TODO: Get correct Linux hash with: nix store prefetch-file --json https://github.com/anza-xyz/platform-tools/releases/download/v1.48/platform-tools-linux-x86_64.tar.bz2
62+
"sha256-qdMVf5N9X2+vQyGjWoA14PgnEUpmOwFQ20kuiT7CdZc="; # v1.48 Linux x86_64 hash
6363
};
6464

6565
nativeBuildInputs = with pkgs; [
@@ -82,6 +82,9 @@ let
8282
darwin.apple_sdk.frameworks.Security
8383
darwin.apple_sdk.frameworks.SystemConfiguration
8484
];
85+
86+
# Disable stripping to avoid issues with text files and scripts
87+
dontStrip = true;
8588

8689
unpackPhase = ''
8790
runHook preUnpack
@@ -156,30 +159,20 @@ let
156159
# Fix broken symlinks
157160
find $out -type l ! -exec test -e {} \; -delete 2>/dev/null || true
158161
159-
# Create wrapper scripts for key tools
162+
# Use wrapProgram to wrap key tools with proper environment
160163
for tool in solana solana-keygen solana-test-validator; do
161164
if [ -f "$out/bin/$tool" ]; then
162-
# Backup original binary
163-
mv "$out/bin/$tool" "$out/bin/.$tool-original"
164-
165-
# Create wrapper script
166-
cat > "$out/bin/$tool" << EOF
167-
#!/bin/bash
168-
export PLATFORM_TOOLS_DIR="$out/platform-tools"
169-
export SBF_SDK_PATH="$out/platform-tools"
170-
export PATH="$out/platform-tools/rust/bin:$out/platform-tools/llvm/bin:\$PATH"
171-
exec "$out/bin/.$tool-original" "\$@"
172-
EOF
173-
chmod +x "$out/bin/$tool"
165+
wrapProgram "$out/bin/$tool" \
166+
--set PLATFORM_TOOLS_DIR "$out/platform-tools" \
167+
--set SBF_SDK_PATH "$out/platform-tools" \
168+
--prefix PATH : "$out/platform-tools/rust/bin" \
169+
--prefix PATH : "$out/platform-tools/llvm/bin"
174170
fi
175171
done
176172
177173
# Create special wrapper for cargo-build-sbf that bypasses platform tools installation
178174
if [ -f "$out/bin/cargo-build-sbf" ]; then
179-
# Backup original binary
180-
mv "$out/bin/cargo-build-sbf" "$out/bin/.cargo-build-sbf-original"
181-
182-
# Create wrapper script that uses cargo directly with SBF target
175+
# Create a custom script that uses cargo directly with SBF target
183176
cat > "$out/bin/cargo-build-sbf" << EOF
184177
#!/bin/bash
185178
export PLATFORM_TOOLS_DIR="$out/platform-tools"

0 commit comments

Comments
 (0)