You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to build a monolithic Rust app using Nix through cargo2nix. I want to be able to:
Compile on the host machine (in my personal case, aarch64-darwin),
Have host-independent, cross-compilation working to produce artifacts for my target architectures (aarch64-linux & x86_64-linux).
This is how I set up my flake.nix:
{inputs={nixpkgs.url="github:NixOS/nixpkgs/nixos-unstable";flake-utils.url="github:numtide/flake-utils";rust-overlay.url="github:oxalica/rust-overlay";rust-overlay.inputs.nixpkgs.follows="nixpkgs";rust-overlay.inputs.flake-utils.follows="flake-utils";cargo2nix.url="github:cargo2nix/cargo2nix";cargo2nix.inputs.nixpkgs.follows="nixpkgs";cargo2nix.inputs.flake-utils.follows="flake-utils";cargo2nix.inputs.rust-overlay.follows="rust-overlay";};outputs={nixpkgs,flake-utils,rust-overlay,cargo2nix, ... }:
flake-utils.lib.eachDefaultSystem(system:
let# All of the local derivations should be added here as an overlay# to make them available to the devshells under `pkgs`.overlays=[(import./tools/nix/overlays)(importrust-overlay)cargo2nix.overlays.default];rustConfig={rustVersion="1.76.0";packageFun=import./Cargo.nix;};pkgs=importnixpkgs{inheritsystemoverlays;config.allowUnfree=true;};pkgsLinuxAmd64=pkgs//{crossSystem.config="x86_64-unknown-linux-musl";};pkgsLinuxArm64=pkgs//{crossSystem.config="aarch64-unknown-linux-gnu";};rustPkgs=pkgs.rustBuilder.makePackageSetrustConfig;rustPkgsLinuxAmd64=pkgsLinuxAmd64.rustBuilder.makePackageSet(rustConfig//{target="x86_64-unknown-linux-musl";});rustPkgsLinuxArm64=pkgsLinuxArm64.rustBuilder.makePackageSet(rustConfig//{target="aarch64-unknown-linux-gnu";});inrec{packages.cargo2nix=cargo2nix.outputs.packages."${system}".cargo2nix;packages.backend-app=(rustPkgs.workspace.backend-app{});packages.backend-app-linux-amd64=(rustPkgsLinuxAmd64.workspace.backend-app{});packages.backend-app-linux-arm64=(rustPkgsLinuxArm64.workspace.backend-app{});apps.backend-app=flake-utils.lib.mkApp{name="app";drv=packages.backend-app;};});}
However, when running nix build .#backend-app-linux-arm64 or nix build .#backend-app-linux-amd64 I get this error:
warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/bpqmcm3gk60biz91lvpwrqws0r8m07n6-crate-rustls-native-certs-0.6.3.drv^*'
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/142ybpb7afscdgapf9xr6961smxjky6i-rustls-native-certs-0.6.3.tar.gz
source root is rustls-native-certs-0.6.3
setting SOURCE_DATE_EPOCH to timestamp 1153704088 of file rustls-native-certs-0.6.3/tests/smoketests.rs
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: buildPhase
[target."cfg(all(unix, not(target_os = \"macos\")))".dependencies.openssl-probe]
[target."cfg(target_os = \"macos\")".dependencies.security-framework]
Compiling rustls-native-certs v0.6.3 (/private/tmp/nix-build-crate-rustls-native-certs-0.6.3.drv-0/rustls-native-certs-0.6.3)
error[E0433]: failed to resolve: use of undeclared crate or module `openssl_probe`
--> src/unix.rs:7:28
|
7 | let likely_locations = openssl_probe::probe();
| ^^^^^^^^^^^^^ use of undeclared crate or module `openssl_probe`
[target."cfg(all(unix, not(target_os = \"macos\")))".dependencies.openssl-probe]
[target."cfg(target_os = \"macos\")".dependencies.security-framework]
Compiling rustls-native-certs v0.6.3 (/private/tmp/nix-build-crate-rustls-native-certs-0.6.3.drv-0/rustls-native-certs-0.6.3)
error[E0433]: failed to resolve: use of undeclared crate or module `openssl_probe`
--> src/unix.rs:7:28
|
7 | let likely_locations = openssl_probe::probe();
| ^^^^^^^^^^^^^ use of undeclared crate or module `openssl_probe`
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> src/unix.rs:10:14
|
10 | Some(cert_file) => load_pem_certs(&cert_file),
| ^^^^^^^^^ doesn't have a size known at compile-time
|
= help: within `Path`, the trait `Sized` is not implemented for `[u8]`
note: required because it appears within the type `Path`
--> /nix/store/airkdq5n6dfrkqpcsfckvfl7lqm6411l-rust-minimal-1.76.0/lib/rustlib/src/rust/library/std/src/path.rs:1992:12
|
1992 | pub struct Path {
| ^^^^
= note: all local variables must have a statically known size
= help: unsized locals are gated as an unstable feature
I am probably doing something wrong. Any idea what that is?
Thank you folks 🙏🏻
The text was updated successfully, but these errors were encountered:
I'm trying to build a monolithic Rust app using Nix through
cargo2nix
. I want to be able to:aarch64-darwin
),aarch64-linux
&x86_64-linux
).This is how I set up my
flake.nix
:However, when running
nix build .#backend-app-linux-arm64
ornix build .#backend-app-linux-amd64
I get this error:I am probably doing something wrong. Any idea what that is?
Thank you folks 🙏🏻
The text was updated successfully, but these errors were encountered: