This commit is contained in:
death916 2025-05-14 08:12:50 -07:00
parent db004f1d86
commit d611a2c60a

View file

@ -1,11 +1,18 @@
self: super:
let
# Pin to a specific nightly that supports edition2024
rustNightly = super.rust-bin.nightly."2025-05-14".default.override {
extensions = [ "rust-src" ];
};
# Create a wrapper script for rustc that enables edition2024
rustcWrapper = super.writeShellScriptBin "rustc" ''
exec ${super.rust-bin.nightly.latest.rustc}/bin/rustc --allow-features=edition2024 "$@"
'';
# Create a wrapper script for cargo that enables edition2024
cargoWrapper = super.writeShellScriptBin "cargo" ''
export RUSTC=${rustcWrapper}/bin/rustc
export RUSTC_BOOTSTRAP=1
exec ${super.rust-bin.nightly.latest.cargo}/bin/cargo "$@"
'';
in {
halloy = super.rustPlatform.buildRustPackage rec {
halloy = super.stdenv.mkDerivation rec {
pname = "halloy";
version = "2025.5";
@ -15,31 +22,41 @@ in {
rev = version;
sha256 = "sha256-cG/B6oiRkyoC5fK7bLdCDQYZymfMZspWXvOkqpwHRPk=";
};
# Force use of pinned nightly toolchain
cargo = rustNightly;
rustc = rustNightly;
# Required for edition2024 features
RUSTC_BOOTSTRAP = 1;
# Patch all Cargo.toml files recursively
postPatch = ''
# Use our custom wrappers
nativeBuildInputs = with super; [
pkg-config
rustcWrapper
cargoWrapper
rust-bin.nightly.latest.rustc
rust-bin.nightly.latest.cargo
];
# Patch all Cargo.toml files
postUnpack = ''
cd $sourceRoot
find . -name Cargo.toml -exec sed -i '1i cargo-features = ["edition2024"]' {} \;
# Create .cargo/config.toml to enable edition2024
mkdir -p .cargo
cat > .cargo/config.toml << EOF
[unstable]
edition2024 = true
EOF
'';
# Build with cargo
buildPhase = ''
export RUSTC_BOOTSTRAP=1
export RUSTFLAGS="--allow-features=edition2024"
cargo build --release
'';
# Install the binary
installPhase = ''
mkdir -p $out/bin
cp target/release/halloy $out/bin/
'';
# Use crane's vendor approach for better dependency handling
cargoDeps = super.rustPlatform.importCargoLock {
lockFile = src + "/Cargo.lock";
outputHashes = {
"cryoglyph-0.1.0" = "sha256-X7S9jq8wU6g1DDNEzOtP3lKWugDnpopPDBK49iWvD4o=";
"dark-light-2.0.0" = "sha256-e826vF7iSkGUqv65TXHBUX04Kz2aaJJEW9f7JsAMaXE=";
"iced-0.14.0-dev" = "sha256-FEGk1zkXM9o+fGMoDtmi621G6pL+Yca9owJz4q2Lzks=";
"dpi-0.1.1" = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
};
nativeBuildInputs = with super; [ pkg-config ];
buildInputs = with super; [
libxkbcommon