about summary refs log tree commit diff
path: root/third_party
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-11-19T20·42+0200
committerclbot <clbot@tvl.fyi>2023-11-19T22·06+0000
commit9322d29ea9660d9ec2b24ab494efd7d4cee6780f (patch)
tree948efd824eadb0343c581b0d1cdc68382b0f6b09 /third_party
parenta5749fada5c048093f0496ae23a5800e343b88be (diff)
chore(third_party/nixpkgs): add more patches to crate2nix r/7041
Change-Id: I2c2c3d4722a69a1ce5a4f144d0c450d88f40856a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10082
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
Diffstat (limited to 'third_party')
-rw-r--r--third_party/overlays/patches/crate2nix-fix-resolve-missing-target-features-to-null.patch53
-rw-r--r--third_party/overlays/tvl.nix3
2 files changed, 56 insertions, 0 deletions
diff --git a/third_party/overlays/patches/crate2nix-fix-resolve-missing-target-features-to-null.patch b/third_party/overlays/patches/crate2nix-fix-resolve-missing-target-features-to-null.patch
new file mode 100644
index 000000000000..96e0fdd263cc
--- /dev/null
+++ b/third_party/overlays/patches/crate2nix-fix-resolve-missing-target-features-to-null.patch
@@ -0,0 +1,53 @@
+From 5ed4d5f99e8c2ee0e552ceb3842fdf0afaed7534 Mon Sep 17 00:00:00 2001
+From: tilpner <git@tilpner.com>
+Date: Tue, 24 Oct 2023 20:26:29 +0200
+Subject: [PATCH] fix: resolve missing target features to 'null'
+
+---
+ crate2nix/Cargo.nix                              | 16 ++++++++--------
+ crate2nix/src/render.rs                          | 10 +++++-----
+ sample_projects/bin/Cargo.toml                   |  3 +++
+ .../bin_with_git_submodule_dep/Cargo.nix         |  6 +++---
+ sample_projects/codegen/Cargo.nix                |  2 +-
+ 5 files changed, 20 insertions(+), 17 deletions(-)
+
+diff --git a/crate2nix/src/render.rs b/crate2nix/src/render.rs
+index 8ca2f1c..a269fc7 100644
+--- a/src/render.rs
++++ b/src/render.rs
+@@ -224,7 +224,7 @@ fn cfg_to_nix_expr(cfg: &CfgExpr) -> String {
+                 } else if key == "target_family" {
+                     format!("(builtins.elem {} target.{})", escaped_value, target(key))
+                 } else {
+-                    format!("({} == target.{})", escaped_value, target(key))
++                    format!("({} == target.{} or null)", escaped_value, target(key))
+                 });
+             }
+             CfgExpr::Not(expr) => {
+@@ -292,19 +292,19 @@ fn test_render_cfg_to_nix_expr() {
+         &cfg_to_nix_expr(&kv("target_family", "unix"))
+     );
+     assert_eq!(
+-        "(\"linux\" == target.\"os\")",
++        "(\"linux\" == target.\"os\" or null)",
+         &cfg_to_nix_expr(&kv("target_os", "linux"))
+     );
+     assert_eq!(
+-        "(!(\"linux\" == target.\"os\"))",
++        "(!(\"linux\" == target.\"os\" or null))",
+         &cfg_to_nix_expr(&CfgExpr::Not(Box::new(kv("target_os", "linux"))))
+     );
+     assert_eq!(
+-        "((target.\"unix\" or false) || (\"linux\" == target.\"os\"))",
++        "((target.\"unix\" or false) || (\"linux\" == target.\"os\" or null))",
+         &cfg_to_nix_expr(&CfgExpr::Any(vec![name("unix"), kv("target_os", "linux")]))
+     );
+     assert_eq!(
+-        "((target.\"unix\" or false) && (\"linux\" == target.\"os\"))",
++        "((target.\"unix\" or false) && (\"linux\" == target.\"os\" or null))",
+         &cfg_to_nix_expr(&CfgExpr::All(vec![name("unix"), kv("target_os", "linux")]))
+     );
+     assert_eq!("true", &cfg_to_nix_expr(&CfgExpr::All(vec![])));
+-- 
+2.42.0
+
diff --git a/third_party/overlays/tvl.nix b/third_party/overlays/tvl.nix
index c194e5005faa..fd060214cfaf 100644
--- a/third_party/overlays/tvl.nix
+++ b/third_party/overlays/tvl.nix
@@ -118,6 +118,9 @@ depot.nix.readTree.drvTargets {
       # https://github.com/nix-community/crate2nix/pull/309
       ./patches/crate2nix-take-lndir-from-buildPackages.patch
       ./patches/crate2nix-skip-running-tests-when-cross-compiling.patch
+
+      # https://github.com/nix-community/crate2nix/pull/307
+      ./patches/crate2nix-fix-resolve-missing-target-features-to-null.patch
     ];
   });