nix: Pin cargo-about to 0.8.2 (#44901)
`cargo-about` got pinned to 0.8.2 in https://github.com/zed-industries/zed/pull/44012, but this isn't exactly "easy" to accomplish in nix. The version of nixpkgs in the flake inputs uses the proper version, but if you override the nixpkgs input or use the provided overlay, you might end up trying to build with a bad version of `cargo-about`. Since nixpkgs is versioned as a whole, your options are (in rough order of desirability): 1. Hope that nixpkgs simply includes multiple versions of the same package (common for things with stable major versions/breaking changes) 1. Use either `override` or `overrideAttrs` to provide different version/source attributes 1. Depend on multiple versions of nixpkgs to get the specific versions of the packages you want 1. Vendor the whole package build from a specific point in its history Option 1 is out - there's only one version of cargo-about in nixpkgs. Option 2 doesn't seem to work due to the way that `buildRustPackage` wraps the base `mkDerivation` which provides the `override` extension functions. There *might* be a way to make this work, but I haven't dug into the `buildRustPackage` internals enough to say for sure. Edit: I apparently can't read and the problems with this option were already solved for `cargo-bundle`, so this is the final approach! Option 3 always just feels a bit icky and opaque to me. Leaving Option 4. I usually find this approach to be "fine" for small package definitions that aren't actually much bigger than the overridden attributes would have be with the Option 2 approach. ~~Since the `cargo-about` definition is nice and small, this is the approach I chose.~~ ~~Since this has the potential to require a build of `cargo-about`, I'm only actually invoking its build if the provided version is wrong - more or less the same thing that's happening in the `generate-licenses` script, but nix-y.~~ Edit: Shouldn't ever cause a rebuild since there's only one 0.8.2 input source/vendored deps, so anything that was already using it will already be cached. I'm also updating nixpkgs to the latest unstable which currently has `cargo-about 0.8.4` to prove that this works. Unrelatedly, I also ran `nix fmt` as a drive-by change. `nix/build.nix` was a bit out of spec. Release Notes: - N/A
This commit is contained in:
committed by
GitHub
parent
e4029c13c9
commit
91a976bf7b
8
flake.lock
generated
8
flake.lock
generated
@@ -32,11 +32,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 315532800,
|
||||
"narHash": "sha256-5CwQ80ucRHiqVbMEEbTFnjz70/axSJ0aliyzSaFSkmY=",
|
||||
"rev": "f6b44b2401525650256b977063dbcf830f762369",
|
||||
"lastModified": 1765772535,
|
||||
"narHash": "sha256-I715zWsdVZ+CipmLtoCAeNG0etQywiWRE5PaWntnaYk=",
|
||||
"rev": "09b8fda8959d761445f12b55f380d90375a1d6bb",
|
||||
"type": "tarball",
|
||||
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-25.11pre891648.f6b44b240152/nixexprs.tar.xz"
|
||||
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.05pre911985.09b8fda8959d/nixexprs.tar.xz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
|
||||
165
nix/build.nix
165
nix/build.nix
@@ -83,70 +83,94 @@ let
|
||||
|
||||
cargoLock = ../Cargo.lock;
|
||||
|
||||
nativeBuildInputs =
|
||||
[
|
||||
cmake
|
||||
copyDesktopItems
|
||||
curl
|
||||
perl
|
||||
pkg-config
|
||||
protobuf
|
||||
cargo-about
|
||||
rustPlatform.bindgenHook
|
||||
]
|
||||
++ lib.optionals stdenv'.hostPlatform.isLinux [ makeWrapper ]
|
||||
++ lib.optionals stdenv'.hostPlatform.isDarwin [
|
||||
(cargo-bundle.overrideAttrs (
|
||||
new: old: {
|
||||
version = "0.6.1-zed";
|
||||
src = fetchFromGitHub {
|
||||
owner = "zed-industries";
|
||||
repo = "cargo-bundle";
|
||||
rev = "2be2669972dff3ddd4daf89a2cb29d2d06cad7c7";
|
||||
hash = "sha256-cSvW0ND148AGdIGWg/ku0yIacVgW+9f1Nsi+kAQxVrI=";
|
||||
};
|
||||
cargoHash = "sha256-urn+A3yuw2uAO4HGmvQnKvWtHqvG9KHxNCCWTiytE4k=";
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
copyDesktopItems
|
||||
curl
|
||||
perl
|
||||
pkg-config
|
||||
protobuf
|
||||
# Pin cargo-about to 0.8.2. Newer versions don't work with the current license identifiers
|
||||
# See https://github.com/zed-industries/zed/pull/44012
|
||||
(cargo-about.overrideAttrs (
|
||||
new: old: rec {
|
||||
version = "0.8.2";
|
||||
|
||||
# NOTE: can drop once upstream uses `finalAttrs` here:
|
||||
# https://github.com/NixOS/nixpkgs/blob/10214747f5e6e7cb5b9bdf9e018a3c7b3032f5af/pkgs/build-support/rust/build-rust-package/default.nix#L104
|
||||
#
|
||||
# See (for context): https://github.com/NixOS/nixpkgs/pull/382550
|
||||
cargoDeps = rustPlatform.fetchCargoVendor {
|
||||
inherit (new) src;
|
||||
hash = new.cargoHash;
|
||||
patches = new.cargoPatches or [];
|
||||
name = new.cargoDepsName or new.finalPackage.name;
|
||||
};
|
||||
}
|
||||
))
|
||||
];
|
||||
src = fetchFromGitHub {
|
||||
owner = "EmbarkStudios";
|
||||
repo = "cargo-about";
|
||||
tag = version;
|
||||
sha256 = "sha256-cNKZpDlfqEXeOE5lmu79AcKOawkPpk4PQCsBzNtIEbs=";
|
||||
};
|
||||
|
||||
buildInputs =
|
||||
[
|
||||
curl
|
||||
fontconfig
|
||||
freetype
|
||||
# TODO: need staticlib of this for linking the musl remote server.
|
||||
# should make it a separate derivation/flake output
|
||||
# see https://crane.dev/examples/cross-musl.html
|
||||
libgit2
|
||||
openssl
|
||||
sqlite
|
||||
zlib
|
||||
zstd
|
||||
]
|
||||
++ lib.optionals stdenv'.hostPlatform.isLinux [
|
||||
alsa-lib
|
||||
libxkbcommon
|
||||
wayland
|
||||
gpu-lib
|
||||
xorg.libX11
|
||||
xorg.libxcb
|
||||
]
|
||||
++ lib.optionals stdenv'.hostPlatform.isDarwin [
|
||||
apple-sdk_15
|
||||
(darwinMinVersionHook "10.15")
|
||||
];
|
||||
cargoHash = "sha256-NnocSs6UkuF/mCM3lIdFk+r51Iz2bHuYzMT/gEbT/nk=";
|
||||
|
||||
# NOTE: can drop once upstream uses `finalAttrs` here:
|
||||
# https://github.com/NixOS/nixpkgs/blob/10214747f5e6e7cb5b9bdf9e018a3c7b3032f5af/pkgs/build-support/rust/build-rust-package/default.nix#L104
|
||||
#
|
||||
# See (for context): https://github.com/NixOS/nixpkgs/pull/382550
|
||||
cargoDeps = rustPlatform.fetchCargoVendor {
|
||||
inherit (new) src;
|
||||
hash = new.cargoHash;
|
||||
patches = new.cargoPatches or [ ];
|
||||
name = new.cargoDepsName or new.finalPackage.name;
|
||||
};
|
||||
}
|
||||
))
|
||||
rustPlatform.bindgenHook
|
||||
]
|
||||
++ lib.optionals stdenv'.hostPlatform.isLinux [ makeWrapper ]
|
||||
++ lib.optionals stdenv'.hostPlatform.isDarwin [
|
||||
(cargo-bundle.overrideAttrs (
|
||||
new: old: {
|
||||
version = "0.6.1-zed";
|
||||
src = fetchFromGitHub {
|
||||
owner = "zed-industries";
|
||||
repo = "cargo-bundle";
|
||||
rev = "2be2669972dff3ddd4daf89a2cb29d2d06cad7c7";
|
||||
hash = "sha256-cSvW0ND148AGdIGWg/ku0yIacVgW+9f1Nsi+kAQxVrI=";
|
||||
};
|
||||
cargoHash = "sha256-urn+A3yuw2uAO4HGmvQnKvWtHqvG9KHxNCCWTiytE4k=";
|
||||
|
||||
# NOTE: can drop once upstream uses `finalAttrs` here:
|
||||
# https://github.com/NixOS/nixpkgs/blob/10214747f5e6e7cb5b9bdf9e018a3c7b3032f5af/pkgs/build-support/rust/build-rust-package/default.nix#L104
|
||||
#
|
||||
# See (for context): https://github.com/NixOS/nixpkgs/pull/382550
|
||||
cargoDeps = rustPlatform.fetchCargoVendor {
|
||||
inherit (new) src;
|
||||
hash = new.cargoHash;
|
||||
patches = new.cargoPatches or [ ];
|
||||
name = new.cargoDepsName or new.finalPackage.name;
|
||||
};
|
||||
}
|
||||
))
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
curl
|
||||
fontconfig
|
||||
freetype
|
||||
# TODO: need staticlib of this for linking the musl remote server.
|
||||
# should make it a separate derivation/flake output
|
||||
# see https://crane.dev/examples/cross-musl.html
|
||||
libgit2
|
||||
openssl
|
||||
sqlite
|
||||
zlib
|
||||
zstd
|
||||
]
|
||||
++ lib.optionals stdenv'.hostPlatform.isLinux [
|
||||
alsa-lib
|
||||
libxkbcommon
|
||||
wayland
|
||||
gpu-lib
|
||||
xorg.libX11
|
||||
xorg.libxcb
|
||||
]
|
||||
++ lib.optionals stdenv'.hostPlatform.isDarwin [
|
||||
apple-sdk_15
|
||||
(darwinMinVersionHook "10.15")
|
||||
];
|
||||
|
||||
cargoExtraArgs = "-p zed -p cli --locked --features=gpui/runtime_shaders";
|
||||
|
||||
@@ -177,7 +201,7 @@ let
|
||||
ZED_UPDATE_EXPLANATION = "Zed has been installed using Nix. Auto-updates have thus been disabled.";
|
||||
RELEASE_VERSION = version;
|
||||
LK_CUSTOM_WEBRTC = livekit-libwebrtc;
|
||||
PROTOC="${protobuf}/bin/protoc";
|
||||
PROTOC = "${protobuf}/bin/protoc";
|
||||
|
||||
CARGO_PROFILE = profile;
|
||||
# need to handle some profiles specially https://github.com/rust-lang/cargo/issues/11053
|
||||
@@ -217,14 +241,13 @@ let
|
||||
# `webrtc-sys` expects a staticlib; nixpkgs' `livekit-webrtc` has been patched to
|
||||
# produce a `dylib`... patching `webrtc-sys`'s build script is the easier option
|
||||
# TODO: send livekit sdk a PR to make this configurable
|
||||
postPatch =
|
||||
''
|
||||
substituteInPlace webrtc-sys/build.rs --replace-fail \
|
||||
"cargo:rustc-link-lib=static=webrtc" "cargo:rustc-link-lib=dylib=webrtc"
|
||||
''
|
||||
+ lib.optionalString withGLES ''
|
||||
cat ${glesConfig} >> .cargo/config/config.toml
|
||||
'';
|
||||
postPatch = ''
|
||||
substituteInPlace webrtc-sys/build.rs --replace-fail \
|
||||
"cargo:rustc-link-lib=static=webrtc" "cargo:rustc-link-lib=dylib=webrtc"
|
||||
''
|
||||
+ lib.optionalString withGLES ''
|
||||
cat ${glesConfig} >> .cargo/config/config.toml
|
||||
'';
|
||||
in
|
||||
crates: drv:
|
||||
if hasWebRtcSys crates then
|
||||
|
||||
Reference in New Issue
Block a user