fix(tvix/nix-compat-derive): Get rid of external feature flag

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:🇩🇪: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>
This commit is contained in:
Brian Olsen 2024-08-28 15:45:50 +02:00 committed by clbot
parent 743407e7ab
commit a5fcfd80a1
5 changed files with 3 additions and 56 deletions

View file

@ -7419,7 +7419,6 @@ rec {
name = "nix-compat-derive"; name = "nix-compat-derive";
packageId = "nix-compat-derive"; packageId = "nix-compat-derive";
optional = true; optional = true;
usesDefaultFeatures = false;
} }
{ {
name = "nom"; name = "nom";
@ -7575,10 +7574,7 @@ rec {
packageId = "tokio-test"; packageId = "tokio-test";
} }
]; ];
features = {
"default" = [ "external" ];
};
resolvedDefaultFeatures = [ "default" "external" ];
}; };
"nix-compat-derive-tests" = rec { "nix-compat-derive-tests" = rec {
crateName = "nix-compat-derive-tests"; crateName = "nix-compat-derive-tests";

View file

@ -6,11 +6,6 @@ edition = "2021"
[lib] [lib]
proc-macro = true proc-macro = true
[features]
external = []
default = ["external"]
[dependencies] [dependencies]
proc-macro2 = { version = "1.0.86", features = ["proc-macro"] } proc-macro2 = { version = "1.0.86", features = ["proc-macro"] }
quote = { version = "1.0.36", features = ["proc-macro"] } quote = { version = "1.0.36", features = ["proc-macro"] }

View file

@ -261,17 +261,6 @@ use syn::{parse_quote, DeriveInput};
mod de; mod de;
mod internal; 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))] #[proc_macro_derive(NixDeserialize, attributes(nix))]
pub fn derive_nix_deserialize(item: TokenStream) -> TokenStream { pub fn derive_nix_deserialize(item: TokenStream) -> TokenStream {
let mut input = syn::parse_macro_input!(item as DeriveInput); 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); /// 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] #[proc_macro]
pub fn nix_deserialize_remote(item: TokenStream) -> TokenStream { pub fn nix_deserialize_remote(item: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(item as RemoteInput); let input = syn::parse_macro_input!(item as RemoteInput);

View file

@ -37,7 +37,6 @@ version = "1.6.1"
[dependencies.nix-compat-derive] [dependencies.nix-compat-derive]
path = "../nix-compat-derive" path = "../nix-compat-derive"
optional = true optional = true
default-features = false
[dependencies.tokio] [dependencies.tokio]
optional = true optional = true

View file

@ -1,3 +1,5 @@
extern crate self as nix_compat;
pub(crate) mod aterm; pub(crate) mod aterm;
pub mod derivation; pub mod derivation;
pub mod nar; pub mod nar;