-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nix-shell support #111
Comments
{ lib, mkShell, allCrates, cargo }:
let
depsCollector = n: a: a.completeBuildDeps ++ a.completeDeps ++ [a];
allRustDeps = lib.mapAttrsToList depsCollector allCrates;
uniqueRustDeps = lib.unique (builtins.concatLists allRustDeps);
inputs = builtins.map (a: a.buildInputs) uniqueRustDeps;
uniqueInputs = lib.unique (builtins.concatLists inputs);
nativeInputs = builtins.map (a: a.nativeBuildInputs) uniqueRustDeps;
uniqueNativeInputs = lib.unique (builtins.concatLists nativeInputs);
getUniqueValue = list: (assert [(lib.head list)] == lib.unique list; lib.head list);
envVars = lib.zipAttrs (builtins.map (lib.filterAttrs (n: v: n == lib.toUpper n)) uniqueRustDeps);
verifiedEnvVars = lib.mapAttrs (n: v: getUniqueValue v) envVars;
shellAttrs = verifiedEnvVars // {
name = "rust-build-shell";
buildInputs = uniqueInputs;
nativeBuildInputs = uniqueNativeInputs ++ [
cargo
];
};
in mkShell shellAttrs is what I came up locally a little while ago. |
(nb: cargo here is from the mozilla overlay so it does include all the cargo-tools you’d expect) |
@nagisa How do you extract |
If someone know what I can do to create a nix expression for an environment where I can build a https://rustwasm.github.io/docs/wasm-pack/ project, it would be really nice ! |
Provide a derivation that provides a good basis for a
shell.nix
and includes the following buildInputs:cargo
,rustc
,binutils
,clippy
,rustfmt
and others? Mayberls
andrust-analyzer
?cargo test
run. Accumulating on non-rust buildInputs over all crates in the build file via thedefaultCrateOverrides
mechanism is a good start.The text was updated successfully, but these errors were encountered: