This commit is contained in:
death916 2025-05-14 08:49:33 -07:00
parent d639b392b2
commit 8c496762f3

View file

@ -1,7 +1,5 @@
self: super:
let
# Define a Rust platform that uses nightly by default for all its operations.
# `super.rust-bin.nightly.latest.default` comes from the rust-overlay you have in your flake.nix.
nightlyRustPlatform = super.makeRustPlatform {
cargo = super.rust-bin.nightly.latest.default;
rustc = super.rust-bin.nightly.latest.default;
@ -18,54 +16,34 @@ in {
sha256 = "sha256-cG/B6oiRkyoC5fK7bLdCDQYZymfMZspWXvOkqpwHRPk=";
};
# RUSTC_BOOTSTRAP = 1 allows the use of -Z flags (unstable features)
# with the nightly toolchain. This should be inherited by dependency builds.
RUSTC_BOOTSTRAP = 1;
# Add doc_cfg to the allowed features
RUSTFLAGS = "-Z allow-features=edition2024,doc_cfg";
# Set RUSTFLAGS globally. The nightly cargo used by nightlyRustPlatform
# for compiling dependencies should pick this up.
RUSTFLAGS = "-Z allow-features=edition2024";
# The postPatch for the main halloy package.
# This ensures halloy itself declares edition 2024.
# Dependencies like cryoglyph are handled by the nightly cargo respecting RUSTFLAGS.
postPatch = ''
# Ensure Halloy's main Cargo.toml uses edition 2024 and has the cargo-features line.
# This is mostly for the top-level crate.
if ! grep -q 'edition = "2024"' Cargo.toml; then
if grep -q 'edition = ' Cargo.toml; then
sed -i 's/edition = .*/edition = "2024"/' Cargo.toml
else
# A simple way to add it if not present at all
sed -i '/\[package\]/a edition = "2024"' Cargo.toml
fi
fi
# Add cargo-features for both edition2024 and doc_cfg
if ! grep -q 'cargo-features = \["edition2024"\]' Cargo.toml; then
sed -i '1i cargo-features = ["edition2024"]' Cargo.toml
sed -i '1i cargo-features = ["edition2024", "doc_cfg"]' Cargo.toml
fi
# Patch async_executors to enable doc_cfg feature
find . -path "*async_executors*" -name "lib.rs" -exec sed -i '1i #![feature(doc_cfg)]' {} \;
'';
# cargoLock manages fixed-output derivations for dependencies.
# The nightlyRustPlatform should use its nightly cargo to build these.
cargoLock = {
# Assuming Cargo.lock is present in the fetched source of halloy
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=";
"winit-0.30.8" = "sha256-hlVhlQ8MmIbNFNr6BM4edKdZbe+ixnPpKm819zauFLQ=";
# You will get an error for this placeholder.
# Replace it with the actual hash provided in the error message.
"dpi-0.1.1" = "sha256-hlVhlQ8MmIbNFNr6BM4edKdZbe+ixnPpKm819zauFLQ=";
};
};
# System dependencies for Halloy
nativeBuildInputs = with super; [ pkg-config ]; # Rust toolchain is handled by nightlyRustPlatform
nativeBuildInputs = with super; [ pkg-config ];
buildInputs = with super; [
libxkbcommon
openssl
@ -81,7 +59,6 @@ in {
description = "Halloy IRC Client";
homepage = "https://github.com/squidowl/halloy";
license = licenses.gpl3Only;
maintainers = with maintainers; [ ]; # Add your handle if you wish
platforms = platforms.linux;
};
};