Code Monkey home page Code Monkey logo

Comments (13)

yusdacra avatar yusdacra commented on August 24, 2024

Thanks for the info. Can you try out #110 ? It should handle what you are talking about.

from nix-cargo-integration.

waalge avatar waalge commented on August 24, 2024

A bit smoother. Still had some issues and it took several attempts to get there.

nix-shell -p cargo
cargo new hello-x
cd hello-x/
nix flake init -t github:yusdacra/nix-cargo-integration/919017ea66b17f20df6c5721aacdbcb5e35924f1
hx flake.nix # Edit url to point at commit; rename example crate.
cargo run
git add .
nix run .#generate-lockfiles # Suggested in other error messages, but also fails
nix develop # Fails
nix develop .#hello-x

Most of these issues can easily avoided with some docs - I was just guessing.

How stupid is it to have an devShell just to init a new project so that cargo can be made available via the flake,
and there is a command to generate the lock file and add it to git without manual work?
eg it can be dropped into without a crate being available.

mkdir hello-x
cd hello-x 
nix flake init -t github:yusdacra/nix-cargo-integration
# Either `nix run .#init` Or 
nix develop .#bare
cargo init ... 
nci-update-crate # command exposed in devshell. Ensures that crate correctly added to flake & set as default. 

Maybe this is silly.

from nix-cargo-integration.

yusdacra avatar yusdacra commented on August 24, 2024

The generate-lockfiles app should be working, can you post the error message? Or make a repo with the erroring flake and etc. We could provide a shell but I don't think it's good UX, a nix app should do all of the work ideally (generate-lockfiles). Thanks!

from nix-cargo-integration.

waalge avatar waalge commented on August 24, 2024

The annoying faff is having to drop into a nix-shell to use cargo to init.
Maybe the template includes the files output "cargo init" so that it can be entered immediately?

I'll make a repo...

from nix-cargo-integration.

waalge avatar waalge commented on August 24, 2024

Is it that there is a path that is absolute rather than relative?

[nix-shell:~/tmp/hello-x]$ nix run .#generate-lockfiles
trace: Cargo.lock not found for project at path .
Please ensure the lockfile exists for your project.
If you are using a VCS, ensure the lockfile is added to the VCS and not ignored (eg. run `git add /Cargo.lock` for git).

This project will be skipped and won't have any outputs generated.
Run `nix run .#generate-lockfiles` to generate lockfiles for projects that don't have one.

error: manifest path `/Cargo.toml` does not exist
fatal: /Cargo.lock: '/Cargo.lock' is outside repository at '/home/waalge/tmp/hello-x'

from nix-cargo-integration.

waalge avatar waalge commented on August 24, 2024

https://github.com/waalge/hello-x-nci/commits/main

Some notes of input/output in the commit messages.

from nix-cargo-integration.

yusdacra avatar yusdacra commented on August 24, 2024

Maybe the template includes the files output "cargo init" so that it can be entered immediately?

There is a simple-crate template included in the templates (you can use it with nix flake init -t github:yusdacra/nix-cargo-integration/flake-parts#simple-crate, don't forget to change the nci input in the resulting flake to the flake-parts branch too though). That is what you mean by that I assume?

Is it that there is a path that is absolute rather than relative?

This is a bug, I fixed it just now. Please try it again.

from nix-cargo-integration.

waalge avatar waalge commented on August 24, 2024

That is exactly what I mean :) it works much more smoothly.

If I knew this existed, I would have used this multiple times in the past month to quick spin up a repo to try some library.

Its a bit of a stall for there to be no default shell, and no help message

$ nix develop # <-- BAD
warning: Git tree '/home/waalge/tmp/hello-nci' is dirty
error: flake 'git+file:///home/waalge/tmp/hello-nci' does not provide attribute 'devShells.x86_64-linux.default', 'devShell.x86_64-linux', 'packages.x86_64-linux.default' or 'defaultPackage.x86_64-linux'
       Did you mean devShells?
 $ nix develop .#my-crate # <-- GOOD

Don't want to over engineer this. But.
Every user is going to want to immediately rename "my-crate". Which has to be done in multiple places. There's an option to add a welcomeText onto a template, and/or pass args
https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake-init.html#options
I've not used this, but i'd be interested in trying

from nix-cargo-integration.

waalge avatar waalge commented on August 24, 2024

I don't think templates with args exist.

I've made some changes here:

https://github.com/waalge/nix-cargo-integration/tree/waalge/flake-parts

from nix-cargo-integration.

yusdacra avatar yusdacra commented on August 24, 2024

Ok, I added welcomeText's to the examples and tweaked them a bit more. Would be happy if you could check them out, hopefully it should address the issues you had.

from nix-cargo-integration.

waalge avatar waalge commented on August 24, 2024

Think it looks good.

There are other fairly immediate pit falls

from nix-cargo-integration.

yusdacra avatar yusdacra commented on August 24, 2024

rust analyzer not working, and having to add

Is this not working in the nix-cargo-integration devshell?

from nix-cargo-integration.

waalge avatar waalge commented on August 24, 2024

hmm. Maybe it was and then I broke it... not sure. Maybe await someone else reporting it as an issue.

Thanks for assisting with this, and this project

from nix-cargo-integration.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.