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

first party nix (flake) support #241

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

HannesGitH
Copy link

solves #54

i already tried that way back, but now that i understand nix' inner workings much better i though i'll give my previously failed missions another shot. and it worked, whoop whoop.

as nixpkgs already has rquickshare available, feel free to close this pr.

i just wanted to do this as a challenge. But it has two major differences to the variant in nixpkgs:

  • if you want to have first class support (either for ci pipelines, for reproducible builds in general, or just because we can), here you go, nor more relience on downstream nixpkgs
  • the variant in nixpkgs simply wraps the prebuilt appimage (from your github releases) and therefor (besides other drawbacks) only supports x86_65-linux. this one builds itself from source and can therefor be used on many platforms (i myself tested on aarch64-darwin)

but if you dont want to see any nix in your repo, sure thing, just close this PR, no worries :) maybe ill try to add it to nixpkgs then

Copy link
Owner

@Martichou Martichou left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the work you've done here!

I have some question related to the changes, but I also have a need to understand a bit for Nix. How does one build RQuickShare using those files?

You're speaking about CI, what's the expected out file format to share or something?
(excuse me but I have absolutely 0 knowledge about Nix... and I need to understand what's in this repository :))

core_lib/flake.lock Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
@HannesGitH
Copy link
Author

HannesGitH commented Nov 12, 2024

Thanks a lot for the work you've done here!

Sure thing! :) As I said it was primarily as a challenge for myself so no bad feelings if you discard this pr :P

I have some question related to the changes, but I also have a need to understand a bit for Nix. How does one build RQuickShare using those files?

Okay, if you want a deeper dive i'm probably not the BEST person to ask, but as a very short introduction.:Nix is a programming language for declarative, reproducible package management. Rust (with its cargo.lock) and pnpm (with its .lock) already have a rather robust approach, but nix will guarantee reproducibility for everything (that might, depending on who you ask, come at the cost of ease of use tho). But there are currently two similar, yet different approaches: the official, default.nix, and the newer, albeit experimental (tho rather field tested and stable no idea why it's still called experimental), flake.nix, way. As you see i'm a friend of the latter as it brings more guarantees and allows for unified standalone 'flake' repos.
The flake.nix therefor is the one and only entry point in this case. For anyone having nix installed, no matter if only the nix package manager or fully fledged nixos, has to enable the experimental flake support and can then use everything that has a flake.nix file somewhere to deterministically build binaries from the provided source. For example everyone can run this program by running nix run github:martichou/rquickshare (after merging this pr ofc) which intern fetches this flake file along with all the other source code and then runs the build instructions in the flake file for the default package, puts it to you system and runs it. Similarly nix build does the same, without the running, nix shell as well but also adds the resulting binaries to you current path, and nix develop opens the devShell provided in the flake. You can ofc run local flakes simply by nix run . or similar.

You're speaking about CI, what's the expected out file format to share or something? (excuse me but I have absolutely 0 knowledge about Nix... and I need to understand what's in this repository :))

Well, for nix users you don't have to do anything, that's partially the point of source based package managers, but the builder (in this case the tauri.hook given to the rustPlatform.buildRustPackage ) can produce multiple binaries depending on the system type, in tauris case per default it will build .app for darwin and .appimage for linux, windows isnt really supported by nix afaik, tho you could crosscompile to target that aswell but idk..
You could ditch the whole ci pipeline and replace it with a matrixed nix build followed by uploading the artifacts (in a results symlinked folder)

Hope that helps :D

@HannesGitH
Copy link
Author

Swapping the CI for a nix one (which just installs nix and runs the instructions in the flake via nix build) should be fairly straightforward.

If you are interested I could help you with that :)

flake.nix Outdated Show resolved Hide resolved
flake.nix Outdated Show resolved Hide resolved
@Martichou
Copy link
Owner

Thanks for the explanation! This does seems like it would be useful indeed :)

I'm going to merge this once you update the PR to include the link to the PR for Tauri 2 support.
But for the CI I'm not going to replace it, but having Nix in the repo as your prepared, is very welcomed ;)

@HannesGitH
Copy link
Author

HannesGitH commented Nov 17, 2024

cool :)

the pr was just merged, lemme update this flake to not need my nixpkgs fork anymore, should be ready in ~5min

@HannesGitH HannesGitH marked this pull request as draft November 17, 2024 18:29
@HannesGitH HannesGitH marked this pull request as ready for review November 17, 2024 18:39
@taha-yassine
Copy link

Not entirely related, but could the work in this PR be upstreamed to nixpkgs to build from source instead of the current method that wraps the appimage?

@HannesGitH
Copy link
Author

HannesGitH commented Nov 18, 2024

Not entirely related, but could the work in this PR be upstreamed to nixpkgs to build from source instead of the current method that wraps the appimage?

Yeah, thats possible, and I can also do that as well; but tbh I dont know the best strategy to do so as I dont want to simply copy all the logic, I already asked over at discourse

But feel free to open the corresponding package request issue over at nixpkgs (and include the discourse link and this pr) so it gets more attention and someone more knowledgeable can tell me the best strategy

@Martichou
Copy link
Owner

Just curious, what's the implication of upstream Nix for RQuickShare and this PR? Should both coexist or it is not worth it?

I'd be happy to merge this if this still has some value (faster update maybe?).

@HannesGitH
Copy link
Author

HannesGitH commented Nov 20, 2024

tbh if you dont plan on using nix yourself and dont want to rely on me for maintaining the nix part of this repo i dont see much benefit besides it beeing easier to use different versions of rquickshare, including -yes- faster (possibly unstable) updates as one can run each and every commit (after the flake was introduced), provided the build instructions dont change (or one of us maintains the nix files to update the build as well).

this would in theory be possible with nixpkgs as well, but require some manual overrides inside a file.

on the other hand nixpkgs caches all of their builds, so simply running rquickshare the first time is probably faster (if you dont care about the version) when using the nixpkgs package


edit: i fear one would need to update the pnpmDeps hash as well as the cargo hash everytime new dependencies are added to pnpm or cargo, which probably happens from time to time and is rather unfortunate

@HannesGitH
Copy link
Author

HannesGitH commented Nov 20, 2024

if you want to merge tho, let me quickly make some changes i used while making it compatible with nixpkgs

edit: done ✅

@Martichou
Copy link
Owner

Based on what you just said, I think I'd prefer not to move forward with this PR since it will be available upstream. And as you pointed out, I'm not going to use Nix myself and maintaining that would be quite a work to not forget it each time I update deps/add deps, ... :)

I'll keep this PR open until it is added upstream so that we don't forget to include it in the README once available.
Thanks once again for your time and work here 👍

@Elias-Graf
Copy link

Elias-Graf commented Dec 18, 2024

I see some NixOS people here, so sorry for hijacking this a bit... but is the current application working for you guys? For me, my computer (NixOS) does show up on my android device, after toggling from "Always visible" to "Hide from everyone", and back to visible. But if I then click on it, my android device loads for a while and then fails with "Failed". I never received anything on the computer.

I haven't even gotten it to show up the other way around (Computer -> Android)

This is the whole output I'm getting, even after it appeared on my android device, and I pressed the computer:

❯ export RUST_LOG=debug
❯ rquickshare
Could not determine the accessibility bus address
set_up_logging: level: Info
2024-12-18T12:14:59Z  INFO rqs_lib: TcpListener on: 0.0.0.0:33423
2024-12-18T12:14:59Z  INFO rqs_lib::manager: TcpServer: service starting
2024-12-18T12:14:59Z  INFO rqs_lib::hdl::mdns: Broadcasting with: helios
2024-12-18T12:14:59Z  INFO rqs_lib::hdl::ble: BleListener: service starting
2024-12-18T12:14:59Z  INFO rqs_lib::hdl::mdns: MDnsServer: service starting

(me setting the log level seems to also have been a failure ':D)

I know this should probably be a separate issue, and I am happy to open one, but I'm really not sure if this is a NixOS problem, or a problem with the package itself.

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

Successfully merging this pull request may close these issues.

4 participants