about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Olsen <brian@maven-group.org>2024-08-28T13·45+0200
committerclbot <clbot@tvl.fyi>2024-08-28T14·43+0000
commita5fcfd80a16d985bcef7011ad94eab86cc0b4a72 (patch)
tree00d6f3fcea7d4da814eb31dce1bc3a2cef7850dc
parent743407e7abf9cf56274c8c9bcb1edb10d8f943ed (diff)
fix(tvix/nix-compat-derive): Get rid of external feature flag r/8602
The external feature flag was there because I couldn't find a way to
refer to crate and nix-compat with the same name so that the generated
code could be the same.

In essence `use nix_compat::nix_daemon::de::NixDeserialize` is an error
when used inside nix_compat crate.

So my best fix was the external feature flag until I found the solution
used here which also removes the flag completely.

Change-Id: Ia3e89c6c350c3fb22ca87f974a39c21542aae152
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12376
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: Brian Olsen <me@griff.name>
-rw-r--r--tvix/Cargo.nix6
-rw-r--r--tvix/nix-compat-derive/Cargo.toml5
-rw-r--r--tvix/nix-compat-derive/src/lib.rs45
-rw-r--r--tvix/nix-compat/Cargo.toml1
-rw-r--r--tvix/nix-compat/src/lib.rs2
5 files changed, 3 insertions, 56 deletions
diff --git a/tvix/Cargo.nix b/tvix/Cargo.nix
index c9fec85e2e37..be49a5c019b6 100644
--- a/tvix/Cargo.nix
+++ b/tvix/Cargo.nix
@@ -7419,7 +7419,6 @@ rec {
             name = "nix-compat-derive";
             packageId = "nix-compat-derive";
             optional = true;
-            usesDefaultFeatures = false;
           }
           {
             name = "nom";
@@ -7575,10 +7574,7 @@ rec {
             packageId = "tokio-test";
           }
         ];
-        features = {
-          "default" = [ "external" ];
-        };
-        resolvedDefaultFeatures = [ "default" "external" ];
+
       };
       "nix-compat-derive-tests" = rec {
         crateName = "nix-compat-derive-tests";
diff --git a/tvix/nix-compat-derive/Cargo.toml b/tvix/nix-compat-derive/Cargo.toml
index dea8ab5ab159..a8743b426638 100644
--- a/tvix/nix-compat-derive/Cargo.toml
+++ b/tvix/nix-compat-derive/Cargo.toml
@@ -6,11 +6,6 @@ edition = "2021"
 [lib]
 proc-macro = true
 
-[features]
-external = []
-default = ["external"]
-
-
 [dependencies]
 proc-macro2 = { version = "1.0.86",  features = ["proc-macro"] }
 quote = { version = "1.0.36", features = ["proc-macro"] }
diff --git a/tvix/nix-compat-derive/src/lib.rs b/tvix/nix-compat-derive/src/lib.rs
index 59ed9a4f170c..e3faed02ebab 100644
--- a/tvix/nix-compat-derive/src/lib.rs
+++ b/tvix/nix-compat-derive/src/lib.rs
@@ -261,17 +261,6 @@ use syn::{parse_quote, DeriveInput};
 mod de;
 mod internal;
 
-#[cfg(not(feature = "external"))]
-#[proc_macro_derive(NixDeserialize, attributes(nix))]
-pub fn derive_nix_deserialize(item: TokenStream) -> TokenStream {
-    let mut input = syn::parse_macro_input!(item as DeriveInput);
-    let nnixrs: syn::Path = parse_quote!(crate);
-    de::expand_nix_deserialize(nnixrs, &mut input)
-        .unwrap_or_else(syn::Error::into_compile_error)
-        .into()
-}
-
-#[cfg(feature = "external")]
 #[proc_macro_derive(NixDeserialize, attributes(nix))]
 pub fn derive_nix_deserialize(item: TokenStream) -> TokenStream {
     let mut input = syn::parse_macro_input!(item as DeriveInput);
@@ -304,40 +293,6 @@ pub fn derive_nix_deserialize(item: TokenStream) -> TokenStream {
 ///
 /// nix_deserialize_remote!(#[nix(from="u64")] MyU64);
 /// ```
-#[cfg(not(feature = "external"))]
-#[proc_macro]
-pub fn nix_deserialize_remote(item: TokenStream) -> TokenStream {
-    let input = syn::parse_macro_input!(item as RemoteInput);
-    let crate_path = parse_quote!(crate);
-    de::expand_nix_deserialize_remote(crate_path, &input)
-        .unwrap_or_else(syn::Error::into_compile_error)
-        .into()
-}
-
-/// Macro to implement `NixDeserialize` on a type.
-/// Sometimes you can't use the deriver to implement `NixDeserialize`
-/// (like when dealing with types in Rust standard library) but don't want
-/// to implement it yourself. So this macro can be used for those situations
-/// where you would derive using `#[nix(from_str)]`,
-/// `#[nix(from = "FromType")]` or `#[nix(try_from = "FromType")]` if you
-/// could.
-///
-/// #### Example
-///
-/// ```rust
-/// # use nix_compat_derive::nix_deserialize_remote;
-/// #
-/// struct MyU64(u64);
-///
-/// impl From<u64> for MyU64 {
-///     fn from(value: u64) -> Self {
-///         Self(value)
-///     }
-/// }
-///
-/// nix_deserialize_remote!(#[nix(from="u64")] MyU64);
-/// ```
-#[cfg(feature = "external")]
 #[proc_macro]
 pub fn nix_deserialize_remote(item: TokenStream) -> TokenStream {
     let input = syn::parse_macro_input!(item as RemoteInput);
diff --git a/tvix/nix-compat/Cargo.toml b/tvix/nix-compat/Cargo.toml
index 87e9b1e6760c..fade4f117a09 100644
--- a/tvix/nix-compat/Cargo.toml
+++ b/tvix/nix-compat/Cargo.toml
@@ -37,7 +37,6 @@ version = "1.6.1"
 [dependencies.nix-compat-derive]
 path = "../nix-compat-derive"
 optional = true
-default-features = false
 
 [dependencies.tokio]
 optional = true
diff --git a/tvix/nix-compat/src/lib.rs b/tvix/nix-compat/src/lib.rs
index 6eec4b8d03a8..f30c557889a8 100644
--- a/tvix/nix-compat/src/lib.rs
+++ b/tvix/nix-compat/src/lib.rs
@@ -1,3 +1,5 @@
+extern crate self as nix_compat;
+
 pub(crate) mod aterm;
 pub mod derivation;
 pub mod nar;