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

babashka: Add wrapper #241119

Merged
merged 1 commit into from
Jul 3, 2023
Merged

babashka: Add wrapper #241119

merged 1 commit into from
Jul 3, 2023

Conversation

jlesquembre
Copy link
Member

To resolve dependecies in bb.edn files, Babashka depends on some Clojure files and Java, see:
https://github.com/borkdude/deps.clj/tree/master#deps_clj_tools_dir

The wrapper also adds rlwrap, as recommended in the Babashka documentation:
https://book.babashka.org/#_repl

Adding Clojure and the JDK to the derivation increases considerably the closure size. I'm adding a boolean, wrapBinary, to make easier to disable the wrapper, and reduce the closure size. That could be useful to, for example, create a Docker image.

I'm also formatting the file with nixpkgs-fmt.

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 23.11 Release Notes (or backporting 23.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.

@ofborg ofborg bot added 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 labels Jul 2, 2023
Copy link
Contributor

@thiagokokada thiagokokada left a comment

Choose a reason for hiding this comment

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

The idea is good, but I don't think this is a good approach. Since the wrap is done in the same derivation as the program, if we disable the wrapper we end up needing to recompile the whole babashka.

I would prefer this being a separate derivation, like the mpv or neovim packages, where we have babashka-unwrapped to be the non-wrapped derivation and babashka is the wrapped one. This way, the wrap can even be modified (e.g. using another JDK) without triggering a recompilation.

@bennyandresen
Copy link
Member

I think the unwrapped/wrapped suggestion seems smart. I also think having convenience built in to the main package would be nice, so I support the idea of this PR.

Thanks for working on this!

@jlesquembre
Copy link
Member Author

@thiagokokada It makes sense, I added a babashka-unwrapped derivation.

It's not clear in the git diff, but the babahka-unwrapped.nix is the previous babashka.nix file, I only changed the pname.

I also noticed that we can remove the jdk dependency in the neil package.

seems to hit the sweet spot for those cases.
installPhase =
let unwrapped-bin = "${babashka-unwrapped}/bin/bb"; in
''
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add the unwrapped package as passthru? See the mpv package for example.

Copy link
Member Author

@jlesquembre jlesquembre Jul 2, 2023

Choose a reason for hiding this comment

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

You mean just passthru.unwrapped = babashka-unwrapped?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes.

@thiagokokada
Copy link
Contributor

Also please fix eval error.

@jlesquembre jlesquembre force-pushed the bb-wrapper branch 2 times, most recently from ce20017 to 74d4215 Compare July 2, 2023 21:22
@@ -0,0 +1,99 @@
{ lib
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we reorganize this in a subdirectory babashka? And then this is the unwrapped.nix file while the wrapper is default.nix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or this is the default.nix and the other is the wrapper.nix. Not sure how is the common way to organize this.

mpv is again a good example.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, I went with default.nix for the unwrapped version, looking at mpv and neovim, seems the convention.

@jlesquembre
Copy link
Member Author

We also have obb, which depends on babashka, but it's broken, I'm marking it as broken:
https://hydra.nixos.org/job/nixpkgs/trunk/obb.aarch64-darwin/all

@ofborg ofborg bot requested a review from willcohen July 2, 2023 22:20
@willcohen
Copy link
Contributor

Please mark as broken. I need to devote a little time next month to try to get it working again!

@ofborg ofborg bot requested a review from willcohen July 2, 2023 22:42
To resolve dependecies in `bb.edn` files, Babashka depends on some
Clojure files and Java, see:
https://github.com/borkdude/deps.clj/tree/master#deps_clj_tools_dir

The wrapper also adds rlwrap, as recommended in the Babashka
documentation:
https://book.babashka.org/#_repl

I'm also formatting the file with nixpkgs-fmt
@thiagokokada
Copy link
Contributor

@ofborg eval

@ofborg ofborg bot requested a review from thiagokokada July 3, 2023 09:39
@thiagokokada
Copy link
Contributor

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

4 packages built:
  • babashka
  • babashka-unwrapped
  • bbin
  • neil

@thiagokokada
Copy link
Contributor

If anyone is interested in the impacts of the wrapper in derivation size:

[nix-shell:~/.cache/nixpkgs-review/pr-241119]$ nix path-info -Sh ./results/babashka
/nix/store/yk88wjbp7afsw4vrfqr3n5qnyd06gbn6-babashka-1.3.181	1020.9M

[nix-shell:~/.cache/nixpkgs-review/pr-241119]$ nix path-info -Sh ./results/babashka-unwrapped
/nix/store/3lg2dnnvsav7lm229cidgzyrynqv0b78-babashka-unwrapped-1.3.181	111.5M

@jlesquembre
Copy link
Member Author

If anyone is interested in the impacts of the wrapper in derivation size:

[nix-shell:~/.cache/nixpkgs-review/pr-241119]$ nix path-info -Sh ./results/babashka
/nix/store/yk88wjbp7afsw4vrfqr3n5qnyd06gbn6-babashka-1.3.181	1020.9M

[nix-shell:~/.cache/nixpkgs-review/pr-241119]$ nix path-info -Sh ./results/babashka-unwrapped
/nix/store/3lg2dnnvsav7lm229cidgzyrynqv0b78-babashka-unwrapped-1.3.181	111.5M

Adding java doesn't help:

/nix/store/20p0j42kgzq6ch4a5450npzz7hp3asma-openjdk-17.0.7+7	 928.3M

@thiagokokada thiagokokada merged commit 552ed97 into NixOS:master Jul 3, 2023
@jlesquembre jlesquembre deleted the bb-wrapper branch July 3, 2023 12:59
@jlesquembre
Copy link
Member Author

thanks @thiagokokada !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants