chore(third_party/crate2nix): bump crate2nix to current HEAD

This will bring conditional features support.

Also invoke crate2nixgenerate with the --all-features argument, so all
dependencies, including the ones for optional features are included in
the Cargo.nix file.

Change-Id: I3bbcb200c9b481f660db89efba650ea4f7418a63
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9470
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2023-09-26 09:50:23 +03:00 committed by clbot
parent 15a3eca321
commit 10717605a2
3 changed files with 32 additions and 22 deletions

View file

@ -1,6 +1,6 @@
# This overlay is used to make TVL-specific modifications in the # This overlay is used to make TVL-specific modifications in the
# nixpkgs tree, where required. # nixpkgs tree, where required.
{ depot, localSystem, ... }: { lib, depot, localSystem, ... }:
self: super: self: super:
let let
@ -109,20 +109,20 @@ depot.nix.readTree.drvTargets {
})); }));
# Pin a newer version of crate2nix from git, which is not officially # Pin a newer version of crate2nix from git, which is not officially
# released but supports `dep:` # released but supports `dep:` and conditional features
crate2nix = super.crate2nix.overrideAttrs (old: rec { crate2nix = super.crate2nix.overrideAttrs (old: rec {
version = "0.11.0-rc.1"; version = "unstable-2023-09-26";
src = self.fetchFromGitHub { src = self.fetchFromGitHub {
owner = "kolloch"; owner = "nix-community";
repo = "crate2nix"; repo = "crate2nix";
rev = "v0.11.0-rc.1"; rev = "8a33aec8795dcc98afbb0cd1030bb1c939ede211";
hash = "sha256:02yvn61w16sgkdxa019l5y9i2ybyk8h4516718gmarqxx5ws2kz8"; hash = "sha256-eFT2SUxTopxEvW0rcxSjQU6nbrQLI2FbyaVgtV8oiTk=";
}; };
cargoDeps = old.cargoDeps.overrideAttrs (_: { cargoDeps = old.cargoDeps.overrideAttrs (_: {
inherit src; inherit src;
outputHash = "sha256:03yny9ikqzfpi2mr27r82g54an2s8k9lqi2i4fqalg7g0s2cr2yd"; outputHash = "sha256-elEIWHxyY3iccprIcbQA6GWFiq/n5kozpGfw/OmoSIg=";
}); });
}); });
} }

View file

@ -1,5 +1,5 @@
# This file was @generated by crate2nix 0.10.0 with the command: # This file was @generated by crate2nix 0.11.0-rc.4 with the command:
# "generate" # "generate" "--all-features"
# See https://github.com/kolloch/crate2nix for more info. # See https://github.com/kolloch/crate2nix for more info.
{ nixpkgs ? <nixpkgs> { nixpkgs ? <nixpkgs>
@ -4102,7 +4102,7 @@ rec {
# We can't filter paths with references in Nix 2.4 # We can't filter paths with references in Nix 2.4
# See https://github.com/NixOS/nix/issues/5410 # See https://github.com/NixOS/nix/issues/5410
src = src =
if (lib.versionOlder builtins.nixVersion "2.4pre20211007") if ((lib.versionOlder builtins.nixVersion "2.4pre20211007") || (lib.versionOlder "2.5" builtins.nixVersion))
then lib.cleanSourceWith { filter = sourceFilter; src = ./nix_cli; } then lib.cleanSourceWith { filter = sourceFilter; src = ./nix_cli; }
else ./nix_cli; else ./nix_cli;
dependencies = [ dependencies = [
@ -4125,7 +4125,7 @@ rec {
# We can't filter paths with references in Nix 2.4 # We can't filter paths with references in Nix 2.4
# See https://github.com/NixOS/nix/issues/5410 # See https://github.com/NixOS/nix/issues/5410
src = src =
if (lib.versionOlder builtins.nixVersion "2.4pre20211007") if ((lib.versionOlder builtins.nixVersion "2.4pre20211007") || (lib.versionOlder "2.5" builtins.nixVersion))
then lib.cleanSourceWith { filter = sourceFilter; src = ./nix-compat; } then lib.cleanSourceWith { filter = sourceFilter; src = ./nix-compat; }
else ./nix-compat; else ./nix-compat;
dependencies = [ dependencies = [
@ -8293,7 +8293,7 @@ rec {
# We can't filter paths with references in Nix 2.4 # We can't filter paths with references in Nix 2.4
# See https://github.com/NixOS/nix/issues/5410 # See https://github.com/NixOS/nix/issues/5410
src = src =
if (lib.versionOlder builtins.nixVersion "2.4pre20211007") if ((lib.versionOlder builtins.nixVersion "2.4pre20211007") || (lib.versionOlder "2.5" builtins.nixVersion))
then lib.cleanSourceWith { filter = sourceFilter; src = ./castore; } then lib.cleanSourceWith { filter = sourceFilter; src = ./castore; }
else ./castore; else ./castore;
dependencies = [ dependencies = [
@ -8425,7 +8425,7 @@ rec {
# We can't filter paths with references in Nix 2.4 # We can't filter paths with references in Nix 2.4
# See https://github.com/NixOS/nix/issues/5410 # See https://github.com/NixOS/nix/issues/5410
src = src =
if (lib.versionOlder builtins.nixVersion "2.4pre20211007") if ((lib.versionOlder builtins.nixVersion "2.4pre20211007") || (lib.versionOlder "2.5" builtins.nixVersion))
then lib.cleanSourceWith { filter = sourceFilter; src = ./cli; } then lib.cleanSourceWith { filter = sourceFilter; src = ./cli; }
else ./cli; else ./cli;
dependencies = [ dependencies = [
@ -8488,7 +8488,7 @@ rec {
# We can't filter paths with references in Nix 2.4 # We can't filter paths with references in Nix 2.4
# See https://github.com/NixOS/nix/issues/5410 # See https://github.com/NixOS/nix/issues/5410
src = src =
if (lib.versionOlder builtins.nixVersion "2.4pre20211007") if ((lib.versionOlder builtins.nixVersion "2.4pre20211007") || (lib.versionOlder "2.5" builtins.nixVersion))
then lib.cleanSourceWith { filter = sourceFilter; src = ./eval; } then lib.cleanSourceWith { filter = sourceFilter; src = ./eval; }
else ./eval; else ./eval;
libName = "tvix_eval"; libName = "tvix_eval";
@ -8624,7 +8624,7 @@ rec {
# We can't filter paths with references in Nix 2.4 # We can't filter paths with references in Nix 2.4
# See https://github.com/NixOS/nix/issues/5410 # See https://github.com/NixOS/nix/issues/5410
src = src =
if (lib.versionOlder builtins.nixVersion "2.4pre20211007") if ((lib.versionOlder builtins.nixVersion "2.4pre20211007") || (lib.versionOlder "2.5" builtins.nixVersion))
then lib.cleanSourceWith { filter = sourceFilter; src = ./eval/builtin-macros; } then lib.cleanSourceWith { filter = sourceFilter; src = ./eval/builtin-macros; }
else ./eval/builtin-macros; else ./eval/builtin-macros;
procMacro = true; procMacro = true;
@ -8661,7 +8661,7 @@ rec {
# We can't filter paths with references in Nix 2.4 # We can't filter paths with references in Nix 2.4
# See https://github.com/NixOS/nix/issues/5410 # See https://github.com/NixOS/nix/issues/5410
src = src =
if (lib.versionOlder builtins.nixVersion "2.4pre20211007") if ((lib.versionOlder builtins.nixVersion "2.4pre20211007") || (lib.versionOlder "2.5" builtins.nixVersion))
then lib.cleanSourceWith { filter = sourceFilter; src = ./serde; } then lib.cleanSourceWith { filter = sourceFilter; src = ./serde; }
else ./serde; else ./serde;
dependencies = [ dependencies = [
@ -8691,7 +8691,7 @@ rec {
# We can't filter paths with references in Nix 2.4 # We can't filter paths with references in Nix 2.4
# See https://github.com/NixOS/nix/issues/5410 # See https://github.com/NixOS/nix/issues/5410
src = src =
if (lib.versionOlder builtins.nixVersion "2.4pre20211007") if ((lib.versionOlder builtins.nixVersion "2.4pre20211007") || (lib.versionOlder "2.5" builtins.nixVersion))
then lib.cleanSourceWith { filter = sourceFilter; src = ./store; } then lib.cleanSourceWith { filter = sourceFilter; src = ./store; }
else ./store; else ./store;
dependencies = [ dependencies = [
@ -11624,11 +11624,21 @@ rec {
explicitFeatures = dependency.features or [ ]; explicitFeatures = dependency.features or [ ];
additionalDependencyFeatures = additionalDependencyFeatures =
let let
dependencyPrefix = (dependency.rename or dependency.name) + "/"; name = dependency.rename or dependency.name;
dependencyFeatures = stripPrefixMatch = prefix: s:
builtins.filter (f: lib.hasPrefix dependencyPrefix f) features; if lib.hasPrefix prefix s
then lib.removePrefix prefix s
else null;
extractFeature = feature: lib.findFirst
(f: f != null)
null
(map (prefix: stripPrefixMatch prefix feature) [
(name + "/")
(name + "?/")
]);
dependencyFeatures = lib.filter (f: f != null) (map extractFeature features);
in in
builtins.map (lib.removePrefix dependencyPrefix) dependencyFeatures; dependencyFeatures;
in in
defaultOrNil ++ explicitFeatures ++ additionalDependencyFeatures; defaultOrNil ++ explicitFeatures ++ additionalDependencyFeatures;

View file

@ -72,7 +72,7 @@ in
# Run crate2nix generate in the current working directory, then # Run crate2nix generate in the current working directory, then
# format the generated file with depotfmt. # format the generated file with depotfmt.
crate2nixGenerate = pkgs.writeShellScriptBin "crate2nix-generate" '' crate2nixGenerate = pkgs.writeShellScriptBin "crate2nix-generate" ''
${pkgs.crate2nix}/bin/crate2nix generate ${pkgs.crate2nix}/bin/crate2nix generate --all-features
${depot.tools.depotfmt}/bin/depotfmt Cargo.nix ${depot.tools.depotfmt}/bin/depotfmt Cargo.nix
''; '';