Skip to content
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

Add support for installing using Nix (zero maintenance) #76

Merged
merged 30 commits into from
Apr 17, 2021

Conversation

srid
Copy link
Contributor

@srid srid commented Apr 8, 2021

This is an improved version of #73 (and resolves #70) wherein the need to change the version and hash every time the Cargo files change is avoided. Now you can just forget about the .nix files (unless a new C dependency is being introduced).

@srid srid marked this pull request as ready for review April 8, 2021 13:11
@srid srid mentioned this pull request Apr 8, 2021
8 tasks
Copy link
Contributor

@balsoft balsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicks, looks great otherwise!

BTW, maybe you could consider adding .envrc with use flake for those of us who use direnv+nix-direnv.

flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
flake.nix Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
@soywod soywod added the enhancement New feature or request label Apr 8, 2021
@srid
Copy link
Contributor Author

srid commented Apr 8, 2021

@soywod This PR fails for 0.2.4; I believe that's because Cargo.lock wasn't updated along with the commit that changed Cargo.toml.

Error message,

++ crate2nix generate -f ./Cargo.toml -o Cargo-generated.nix -h /nix/store/i11yfpm336cwlzl3idsxiq6dm067v3cs-himalaya-crate2nix/crate-hashes.json
Error: while retrieving metadata about ./Cargo.toml: Error during execution of `cargo metadata`: error: the lock file /build/vv6c95617dy8c6hxl0qvh32crl7jqpyj-source/Cargo.lock needs to be updated but --locked was passed to prevent this

@soywod
Copy link
Member

soywod commented Apr 8, 2021

Ah yes indeed, I bumped the version without launching back cargo build, I will update tomorrow

@srid
Copy link
Contributor Author

srid commented Apr 9, 2021

@soywod Since I don't know enough about Nix, I plan to dive in this weekend to understand at least the concept. This way I will understand better what you did and I will be able to merge your work.

By the way, Nix is also useful for non-development purposes, such as wrapping himalaya in conjunction with other tools (pandoc, bat, fzf, etc.) to provide extra workflows, like this one for reading email in CLI:

srid/nixos-config@6362b4d

@balsoft
Copy link
Contributor

balsoft commented Apr 9, 2021

Well, you can export a NixOS module that uses home-manager, or a home-manager module (though that's not as standardized).

@srid
Copy link
Contributor Author

srid commented Apr 10, 2021

I've created a template repo based on this work: https://github.com/srid/rust-nix-template

@srid
Copy link
Contributor Author

srid commented Apr 10, 2021

@balsoft Do you know what the idiomatic way is to add dev-shell Rust dependencies in Nix?

For eg., to make cargo watch available in nix-shell: https://github.com/passcod/cargo-watch

Or certain crate tools available in nix-shell, eg: trunk from https://yew.rs/docs/en/next/getting-started/project-setup/using-trunk

flake.nix Outdated Show resolved Hide resolved
@srid
Copy link
Contributor Author

srid commented Apr 14, 2021

@balsoft Do you know of an idiomatic way to override a crate dependency to point to a git fork?

I noticed that Cargo.toml supports this, but we can't use it because the fetch will fail during nix build (due to blocked network access):

# Cargo.toml
postgrest = { git = "https://github.com/srid/postgrest-rs", branch = "notokio" }

I also tried adding something like this to defaultCrateOverrides, but that doesn't work for some reason (build is still using the crate registry's package stored in nix store),

                postgrest = oldAttrs: with pkgs; {
                  src = inputs.postgrest-rs; 
                };

@srid
Copy link
Contributor Author

srid commented Apr 14, 2021

Ah. Looks like you have to specifying the source in both places (Cargo.toml and flake input+override); then it works ... mysteriously.

@balsoft
Copy link
Contributor

balsoft commented Apr 14, 2021

the fetch will fail during nix build (due to blocked network access):

I thought I fixed this here: nix-community/crate2nix#154 (but only on Nix 2.4)

@soywod soywod force-pushed the master branch 5 times, most recently from a67ac7d to 1c6f249 Compare April 16, 2021 20:21
@soywod soywod added this to the v1.0.0 milestone Apr 17, 2021
@soywod soywod added cli and removed cli labels Apr 17, 2021
@srid
Copy link
Contributor Author

srid commented Apr 17, 2021

@soywod I believe this PR is ready to be merged anytime.

(I keep merging it with master only because I use this branch directly in my nixos configuration).

@soywod soywod merged commit 76f9084 into pimalaya:master Apr 17, 2021
@soywod
Copy link
Member

soywod commented Apr 17, 2021

❤️ Thanks a lot for your giant contribution guys! Feel free to write an entry in the wiki about Nix (if you judge it necessary, ofc).

@soywod
Copy link
Member

soywod commented Apr 17, 2021

In fact, maybe it makes sense to move the Nix section from the README to the wiki, in the Installation section? I would like to keep the README as short and concise as possible (I need to work on it), and to move all the real documentation to the wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nix support
3 participants