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

cargo-tauri.hook: init #335751

Merged
merged 16 commits into from
Oct 1, 2024
Merged

Conversation

getchoo
Copy link
Member

@getchoo getchoo commented Aug 19, 2024

Description of changes

With Tauri apps getting more popular and added to nixpkgs, I believe it's time we share the tedious setup required to build them. This PR introduces a new hook in cargo-tauri.hook that builds on top of rustPlatform.buildRustPackage (or more acurately, its hooks) to leverage Tauri's bundling feature in creating packages. It is compatible with the two primary targets we share with Tauri -- Linux and macOS -- and meant to be used alongside pre-existing tools for package managers such as npm, pnpm, and yarn

Supersedes #318117

CC @doronbehar for changes made to yarnConfigHook

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Result of nixpkgs-review run on x86_64-linux 1

5 packages failed to build:
  • insulator2
  • kiwitalk
  • powerdns-admin
  • surrealist
  • treedome
24 packages built:
  • auto-changelog
  • cargo-tauri
  • coc-diagnostic
  • codefresh
  • diagnostic-languageserver
  • dotenv-cli
  • get-graphql-schema
  • gitbutler
  • koodo-reader
  • kuro
  • listmonk
  • modrinth-app
  • modrinth-app-unwrapped
  • nixpkgs-manual
  • postlight-parser
  • pot
  • screego
  • spectral-language-server
  • textlint-rule-prh
  • vim-language-server
  • vimPlugins.coc-diagnostic
  • xplorer
  • yarnConfigHook
  • your_spotify

powerdns-admin has been broken since 574c80a

The remaining packages fail with the now infamous

error[E0282]: type annotations needed for Box<_>


Add a 👍 reaction to pull requests you find important.

@Eveeifyeve
Copy link
Contributor

Eveeifyeve commented Aug 19, 2024

I will look into documenting this as this will help build Tauri apps on nix

@Eveeifyeve
Copy link
Contributor

And soon bun I am looking to make a hook

@doronbehar
Copy link
Contributor

CC @doronbehar for changes made to yarnConfigHook

They seem good. I don't have time unfortunately to review and help with the rest of the PR :/, so I'm unsubscribing myself.

@getchoo
Copy link
Member Author

getchoo commented Aug 19, 2024

I will look into documenting this as this will help build Tauri apps on nix

I've made a section for it in the manual already here -- it should work for a vast majority of projects. There's also the test-app showing a real world example with one of the upstream templates

@happysalada
Copy link
Contributor

Editorconfig check is failing
Ofborg is also failing on insulator2

Apart from that this looks good.

@tengkuizdihar
Copy link
Contributor

because of newer rust version, I got an error when testing treedome. I can make a fix and a quick release, can the new release be in this PR?

@getchoo
Copy link
Member Author

getchoo commented Aug 19, 2024

Editorconfig check is failing

Not really sure what to do there as it's failing due to an icon file

Ofborg is also failing on insulator2

As said in the original comment, this is due to the time crate and unrelated to this PR

because of newer rust version, I got an error when testing treedome. I can make a fix and a quick release, can the new release be in this PR?

Once the update for treedome is merged into master, you can run nixpkgs-review pr 335751 --package treedome and it will automatically merge this PR locally and build treedome. I'll probably end up rebasing on master when I make more changes though, so

@tengkuizdihar tengkuizdihar mentioned this pull request Aug 19, 2024
13 tasks
Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

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

The editorconfig CI test giving an error is the canary in the coalmine. nixpkgs should have as little vendored code as possible, and it's quite easy to make a repository for this example app.

pkgs/by-name/ca/cargo-tauri/test-app/.gitignore Outdated Show resolved Hide resolved
@Eveeifyeve
Copy link
Contributor

I will look into using this once I have a bun install/config hook.

@getchoo
Copy link
Member Author

getchoo commented Aug 23, 2024

Fixed merge conflict with #335795. Treedome should build now

@Eveeifyeve
Copy link
Contributor

Eveeifyeve commented Sep 27, 2024

Result of nixpkgs-review pr 335751 run on aarch64-darwin 1

4 packages marked as broken and skipped:
  • cinny-desktop
  • kiwitalk
  • modrinth-app
  • modrinth-app-unwrapped
2 packages failed to build:
  • en-croissant
  • gitbutler

Eveeifyeve

This comment was marked as outdated.

@getchoo
Copy link
Member Author

getchoo commented Sep 27, 2024

Well it would have a purpose of giving the developer choice on how they will package their apps.

This hook isn't meant for developers to package and distribute their apps outside of nixpkgs. Again, this is an implementation detail; there would be no point in outputting an appimage, deb package, etc

If you really wanted to do this though, tauriBundleType is available, but it's primarily meant to be used for platforms not supported by this hook at all/very special cases. It will require you to add your own dependencies and installation script to work in the way you describe (but fair warning: Nix binaries will probably not work outside of nixpkgs)

Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution, Seth (@getchoo)!

I'm approving. This looks good to me. I plan on merging in another day or so unless someone in the greater Rust-in-nixpkgs community requests changes. (CC @emilazy?)

The build failure of insulator2 is part of #332957.

In what I hope is a my-system-issue, both on master and on this PR, I can't run any of the binaries to validate that they're functioning.

For example,

** (kiwi-talk:248290): WARNING **: 12:20:51.751: webkit_settings_set_enable_offline_web_application_cache is deprecated and does nothing.

(kiwi-talk:248290): Gtk-CRITICAL **: 12:20:51.860: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
Gdk-Message: 12:20:52.015: Error 71 (Protocol error) dispatching to Wayland display.

I pretty strongly suspect this is about how I've configured my system, though, so I'm certainly not blocking this PR on investigating that.

Result of nixpkgs-review pr 335751 run on x86_64-linux 1

1 package marked as broken and skipped:
  • cinny-desktop
2 packages blacklisted:
  • nixos-install-tools
  • tests.nixos-functions.nixos-test
1 package failed to build:
  • insulator2
11 packages built:
  • cargo-tauri
  • en-croissant
  • gitbutler
  • kiwitalk
  • modrinth-app
  • modrinth-app-unwrapped
  • mouse-actions-gui
  • nixpkgs-manual
  • pot
  • surrealist
  • treedome

@getchoo
Copy link
Member Author

getchoo commented Oct 1, 2024

Rebased to fix merge conflicts with the release notes

@philiptaron philiptaron merged commit 69bd130 into NixOS:master Oct 1, 2024
10 of 11 checks passed
@getchoo getchoo deleted the pkgs/tauriBuildHook/init branch October 1, 2024 00:19
@ofalvai ofalvai mentioned this pull request Oct 5, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.