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

instant-scala: init at 0.1.0 #337451

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

instant-scala: init at 0.1.0 #337451

wants to merge 2 commits into from

Conversation

jatcwang
Copy link

Description of changes

Add instant-scala (https://github.com/jatcwang/instant-scala), a wrapper script around scala-cli/GraalVM which allow writing scala scripts that starts instantly.

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.

Add a 👍 reaction to pull requests you find important.

Copy link
Member

@Bot-wxt1221 Bot-wxt1221 left a comment

Choose a reason for hiding this comment

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

Rename your PR title to: instant-scale: init at 0.1.0.

Move the package to pkgs/by-name. We are currently moving all package in pkgs/top-level/all-packages.nix to pkgs/by-name

pkgs/development/tools/misc/instant-scala/default.nix Outdated Show resolved Hide resolved
pkgs/development/tools/misc/instant-scala/default.nix Outdated Show resolved Hide resolved
pkgs/development/tools/misc/instant-scala/default.nix Outdated Show resolved Hide resolved
pkgs/development/tools/misc/instant-scala/default.nix Outdated Show resolved Hide resolved
pkgs/development/tools/misc/instant-scala/default.nix Outdated Show resolved Hide resolved
pkgs/development/tools/misc/instant-scala/default.nix Outdated Show resolved Hide resolved
pkgs/development/tools/misc/instant-scala/default.nix Outdated Show resolved Hide resolved
pkgs/development/tools/misc/instant-scala/default.nix Outdated Show resolved Hide resolved
sha256 = "jqSvKTL8NzqjwqDj/+55YWecx2bnzuArP8RdfH5q/1U=";
};

propagateBuildInputs = [
Copy link
Member

Choose a reason for hiding this comment

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

Why use propagateBuildInputs.

Copy link
Author

Choose a reason for hiding this comment

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

The idea is that any downsteram packages (if any) that uses instant-scala will require bash & scala-cli to run anyway.

(If I'm understanding it right.. Basing my interpretation off https://gist.github.com/CMCDragonkai/45359ee894bc0c7f90d562c4841117b5)

Copy link
Author

@jatcwang jatcwang Sep 12, 2024

Choose a reason for hiding this comment

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

I have changed it to buildInputs for now but keen to learn which way is correct based on what this script (instant-scala) is doing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, first of all, it should be propagatedBuildInputs, so I don't believe this is doing anything but defining a list that is not used?

propagatedBuildInputs is only for buildInputs that have to be "on the PATH" during a build of something that depends on your derivation. Instead you should patch the script, with patchShebangs and/or manually so that that is not necessary.


propagateBuildInputs = [
pkgs.bash
pkgs.scala-cli
Copy link
Member

Choose a reason for hiding this comment

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

Will this work?

@jatcwang
Copy link
Author

Thanks a lot for the thorough review @Bot-wxt1221! I'll check and get them fixed as soon as I got time.

@jatcwang jatcwang changed the title Add package instant-scala instant-scale: init at 0.1.0 Sep 12, 2024
src = fetchFromGitHub {
owner = "jatcwang";
repo = "instant-scala";
rev = "/refs/tags/v${finalAttrs.version}";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
rev = "/refs/tags/v${finalAttrs.version}";
rev = "refs/tags/v${finalAttrs.version}";

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

Choose a reason for hiding this comment

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

Not fixed actually

};

buildInputs = with pkgs; [
bash
Copy link
Member

Choose a reason for hiding this comment

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

I mean that bash is included by default.

Copy link
Author

Choose a reason for hiding this comment

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

I see I didn't know that. Removed

lib,
stdenv,
fetchFromGitHub,
pkgs,
Copy link
Member

Choose a reason for hiding this comment

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

Do not include the hole pkgs. just include the package you used like scale-cli.

Copy link
Author

Choose a reason for hiding this comment

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

Done!

Comment on lines 25 to 27
mkdir -p $out/bin
cp ${finalAttrs.pname} $out/bin/${finalAttrs.pname}
chmod +x $out/bin/${finalAttrs.pname}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
mkdir -p $out/bin
cp ${finalAttrs.pname} $out/bin/${finalAttrs.pname}
chmod +x $out/bin/${finalAttrs.pname}
install -Dm755 instant-scala $out/bin/instant-scala

Copy link
Member

Choose a reason for hiding this comment

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

Avoid using finalAttrs.pname as program name because people may override the pname.

Copy link
Author

Choose a reason for hiding this comment

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

That makes sense. What should I use instead? Sorry I'm not familiar with latest best practices.
I found #310373 but it doesn't seem obvious to me what I should use.
The official doc https://nixos.org/manual/nixpkgs/stable/ is using rec 🫨

Copy link
Member

@Bot-wxt1221 Bot-wxt1221 Sep 13, 2024

Choose a reason for hiding this comment

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

Just use instant-scala. Don't use pname as the name of binary.

Copy link
Author

Choose a reason for hiding this comment

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

Sure I can do that. What about version?
(I'm trying to learn what the best practice is - if I do want to reuse variables but still allow downstream to override)

Copy link
Member

Choose a reason for hiding this comment

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

That's OK. The reason why don't use pname is for override. If we override pname. Build will fail.

Copy link
Author

Choose a reason for hiding this comment

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

Updated

homepage = "https://github.com/jatcwang/${finalAttrs.pname}";
license = lib.licenses.asl20;
maintainers = [ lib.maintainer.jatcwang ];
mainProgram = finalAttrs.pname;
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

@Bot-wxt1221 Bot-wxt1221 self-requested a review September 12, 2024 23:02
Copy link
Member

@Bot-wxt1221 Bot-wxt1221 left a comment

Choose a reason for hiding this comment

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

Will this really work?

Copy link
Member

@Bot-wxt1221 Bot-wxt1221 left a comment

Choose a reason for hiding this comment

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

I don't know will darwin work for this installPhase.

src = fetchFromGitHub {
owner = "jatcwang";
repo = "instant-scala";
rev = "/refs/tags/v${finalAttrs.version}";
Copy link
Member

Choose a reason for hiding this comment

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

Not fixed actually

Comment on lines 24 to 26
mkdir -p $out/bin
cp instant-scala $out/bin/instant-scala
chmod +x $out/bin/instant-scala
Copy link
Member

Choose a reason for hiding this comment

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

Use install instead.

Copy link
Contributor

@sarahec sarahec Sep 17, 2024

Choose a reason for hiding this comment

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

Use install instead.

Sorry, my metallic friend. You'd use install if there was an installer script or makefile, but the repo has a plain bash script. The install phase, as written, looks correct.

From the manual:
"The default installPhase creates the directory $out and calls make install"

Since there's no makefile, creating $out and copying appropriately is the right answer.

Copy link
Member

@sikmir sikmir Sep 17, 2024

Choose a reason for hiding this comment

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

Bot-wxt1221 is right, use install -Dm755 instant-scala -t $out/bin instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Bot-wxt1221 my apologies. TIL.

@Bot-wxt1221 Bot-wxt1221 requested a review from a team September 16, 2024 23:31
@sarahec
Copy link
Contributor

sarahec commented Sep 17, 2024

Please fix the title of this PR -- it should be instant-scala instead of scalE

Comment on lines +9455 to +9460
jatcwang = {
email = "[email protected]";
github = "jatcwang";
githubId = 4957161;
name = "Jacob Wang";
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This is normally done as its own commit titledmaintainers: add jatcwang

Copy link
Author

Choose a reason for hiding this comment

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

done

description = "Write Scala scripts that starts instantly using scala-cli and GraalVM";
homepage = "https://github.com/jatcwang/instant-scala";
license = lib.licenses.asl20;
maintainers = [ lib.maintainer.jatcwang ];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
maintainers = [ lib.maintainer.jatcwang ];
maintainers = with lib.maintainers; [ jatcwang ];

Copy link
Contributor

Choose a reason for hiding this comment

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

Causes a build failure that keeps me from testing the Darwin build. Sorry.

license = lib.licenses.asl20;
maintainers = [ lib.maintainer.jatcwang ];
mainProgram = "instant-scala";
platforms = lib.platforms.unix;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
platforms = lib.platforms.unix;

Not needed, should be fine on all platforms that run Scala.

Copy link
Author

Choose a reason for hiding this comment

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

removed

@jatcwang jatcwang changed the title instant-scale: init at 0.1.0 instant-scala: init at 0.1.0 Sep 18, 2024
@Bot-wxt1221
Copy link
Member

Rename your second commit message to instant-scala: init at 0.1.0


meta = {
description = "Write Scala scripts that starts instantly using scala-cli and GraalVM";
homepage = "https://github.com/jatcwang/instant-scala";
Copy link
Member

Choose a reason for hiding this comment

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

miss changelog here.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed sorry

Copy link
Member

@Bot-wxt1221 Bot-wxt1221 left a comment

Choose a reason for hiding this comment

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

LGTM

meta = {
description = "Write Scala scripts that starts instantly using scala-cli and GraalVM";
homepage = "https://github.com/jatcwang/instant-scala";
changelog = "https://github.com/jatcwang/instant-scala/releases";
Copy link
Contributor

@sarahec sarahec Sep 18, 2024

Choose a reason for hiding this comment

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

Suggested change
changelog = "https://github.com/jatcwang/instant-scala/releases";
changelog = "https://github.com/jatcwang/instant-scala/releases/v${finalAttrs.version}";

Copy link
Author

Choose a reason for hiding this comment

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

Done thanks

meta = {
description = "Write Scala scripts that starts instantly using scala-cli and GraalVM";
homepage = "https://github.com/jatcwang/instant-scala";
changelog = "https://github.com/jatcwang/instant-scala/releases/${finalAttrs.version}";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
changelog = "https://github.com/jatcwang/instant-scala/releases/${finalAttrs.version}";
changelog = "https://github.com/jatcwang/instant-scala/releases/v${finalAttrs.version}";

Copy link
Author

Choose a reason for hiding this comment

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

Updated!

@sarahec
Copy link
Contributor

sarahec commented Sep 18, 2024

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

1 package built:
  • instant-scala

Copy link
Contributor

@sarahec sarahec left a comment

Choose a reason for hiding this comment

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

LGTM

@sarahec
Copy link
Contributor

sarahec commented Sep 18, 2024

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

1 package built:
  • instant-scala

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.

7 participants