Comments (7)
Two things I really need for this project to be usable in most of my projects:
- Flakes support. I really like to use Flakes instead of other things like
niv
. - Support for
-Zbuild-std
#161. I have many projects that useno_std
environments, and they would be awesome to use with Nix, but currently, no "Nixify your cargo project" package supports building withbuild-std
from crate2nix.
Thank you @kolloch for making this tool!
Here is my two cents.
Nix could be used for configuration rather than a crate2nix.toml
file.
This is what callCabal2nixWithOptions
does.
Here is a prototype callCrate2nix
I am using:
{ pkgs ? import <nixpkgs> {},
lib ? pkgs.lib }:
let
crate2nix = import ./nix/crate2nix.nix {};
callCrate2nix = { src }: pkgs.stdenv.mkDerivation ({
name = "default.nix";
buildCommand = ''
# crate2nix needs to open Cargo.lock with write permissions
chmod u+w ${src}/Cargo.lock
${crate2nix}/bin/crate2nix generate -f ${src}/Cargo.toml -o $out
'';
});
project = callCrate2nix { src = ./.; };
crate2nix_package = (pkgs.callPackage project {}).rootCrate.build;
in with pkgs ; pkgs.symlinkJoin {
name = crate2nix_package.name;
paths = [ crate2nix_package ];
buildInputs = [ makeWrapper cargo ];
postBuild = ''
# Fallback to built dependencies for cargo and nix-prefetch-url
wrapProgram $out/bin/${crate2nix_package.name} \
--suffix PATH ":" ${lib.makeBinPath [ cargo nix ]}
rm -rf $out/lib $out/bin/${crate2nix_package.name}.d
'';
}
The callCrate2nix
could be expanded with additional options. These would be passed to crate2nix
as command line arguments. Another would be to follow the example set by callCrate2nixWithOptions
.
from crate2nix.
@xcthulhu Thanks, I think about that. Is this the standard pattern for generating nix and using it in the same build?
from crate2nix.
Is this the standard pattern for generating nix and using it in the same build?
Hmm... I think yarn2nix
works in a similar way, yeah.
Calling the yarn2nix.mkYarnPackage
in a derivation leaves a few <hash>-yarn.nix
files in the nix store after it runs. My way could use some polish to do the same.
I'm not sure if callCabal2Nix
does the same thing or not.
from crate2nix.
Just a related thought - I wonder if getting this to 1.0 (or even just making progress) would be a suitable project for Summer of Nix? If I had a bit more time, I feel like this would be a nice candidate to propose :)
from crate2nix.
@mitchmindtree Nice idea, I would be open to tutoring/supporting an intern if they really spend a considerable time on this (otherwise onboarding overhead might be a big much).
from crate2nix.
I as looking into -Zbuild-std
a bit, but I feel like the main issue is how -Zbuild-std
works on the Cargo side: the workspaces are completely independent and then mashed together. That means stuff like explicit stdlib deps adjusting e.g. stdlib features won't work.
from crate2nix.
Related Issues (20)
- Cargo.nix includes references to ./crate2nix-sources with cargo workspaces HOT 1
- nixpkgs update breaks empty_cross test due to missing `rust` arguement HOT 7
- rstests adds a stray "/sources" to all globbed #[files] HOT 1
- Support path to Cargo.toml/Cargo.lock in fetched sources
- Tarball issue when building or trying to use template. HOT 1
- Error with dep that has a local dep
- Some sort of support for .cargo/config.toml ? HOT 1
- Overriding `crateConfig` for generated `Cargo.nix`
- Crate hash loading from Cargo.lock is broken in Rust 1.77
- Respect cargo profiles / enable debug info in release mode HOT 1
- Allow some crates to access more files than just those in their folder
- IFD is crazy slow due to copying the entire tree HOT 2
- IFD does not work with git deps HOT 2
- Installs `rustc` from nixpkgs when already installed HOT 4
- error: invalid metadata version found HOT 6
- How to push build artifacts to Cachix?
- Crate overides with IFD HOT 1
- Add `crateDescription` to generated crate definition
- Cross-compiling requires `NIXPKGS_ALLOW_BROKEN=1` to be set HOT 2
- Build fails when using `rust-overlay` due to some dependencies being built with Nixpkgs Rust when cross-compiling HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crate2nix.