Skip to content

pkl: init at 0.28.2#402086

Merged
FliegendeWurst merged 1 commit intoNixOS:masterfrom
hugolgst:pkl/0.28.2
May 1, 2025
Merged

pkl: init at 0.28.2#402086
FliegendeWurst merged 1 commit intoNixOS:masterfrom
hugolgst:pkl/0.28.2

Conversation

@hugolgst
Copy link
Member

@hugolgst hugolgst commented Apr 26, 2025

Since #286658 was not moving, tried initiating a new PR

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/)
  • 25.05 Release Notes (or backporting 24.11 and 25.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.

@github-actions github-actions bot added 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Apr 26, 2025
Copy link
Contributor

@dtomvan dtomvan left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM. (just some nitpicks and some new style changes like in d1b9886)

@dtomvan
Copy link
Contributor

dtomvan commented Apr 27, 2025

Seems like somethings messed up with the foojay entry in the lockfile:

Relevant logs: here and here

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 402086

Logs: https://github.com/dtomvan/nixpkgs-review-gha/actions/runs/14692110820


x86_64-linux

❌ 1 package failed to build:
  • pkl

aarch64-linux

❌ 1 package failed to build:
  • pkl

x86_64-darwin

❌ 1 package failed to build:
  • pkl

aarch64-darwin

❌ 1 package failed to build:
  • pkl

@dtomvan
Copy link
Contributor

dtomvan commented Apr 27, 2025

nix-shell maintainers/scripts/update.nix --argstr package pkl.mitmCache seems to fail (only relevant bit):

Cannot find a Java installation on your machine (Linux 6.12.24 amd64) matching: {languageVersion=21, vendor=Eclipse Temurin, implementation=vendor-specific}. 
Some toolchain resolvers had provisioning failures: foojay (Unable to download toolchain matching the requirements ({languageVersion=21, vendor=Eclipse Temurin, implementation=vendor-specific}) from 'https://api.foojay.io/disco/v3.0/ids/4c4f879899012ff0a8b2e2117df03b0e/redirect', due to: 
Unpacked JDK archive does not contain a Java home: /tmp/nix-shell-2-0/tmp.LjhZvKMrxU/.tmp/jdks/OpenJDK21U-jdk_x64_linux_hotspot_2115592472458233801916.tmp).

This foojay disco-api thing (found here) seems to be used to install a specific wanted version of openjdk21 automatically (I think specified here), which isn't something we want, we should probably just build with in-tree temurin-bin-21 (because they so desperately want to be built by temurin)...

The following patch to your branch makes it work I think:

use-temurin-instead.patch
From 634671fcbc9201c724f51621376cdd4b465a8bdf Mon Sep 17 00:00:00 2001
From: Tom van Dijk <18gatenmaker6@gmail.com>
Date: Sun, 27 Apr 2025 15:50:46 +0200
Subject: [PATCH] pkl: use temurin-bin-21 instead

---
 pkgs/by-name/pk/pkl/deps.json   |  7 -------
 pkgs/by-name/pk/pkl/package.nix | 10 +++++-----
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/pkgs/by-name/pk/pkl/deps.json b/pkgs/by-name/pk/pkl/deps.json
index a8c3ae6bdf85..af9adaa00978 100644
--- a/pkgs/by-name/pk/pkl/deps.json
+++ b/pkgs/by-name/pk/pkl/deps.json
@@ -1,13 +1,6 @@
 {
   "!comment": "This is a nixpkgs Gradle dependency lockfile. For more details, refer to the Gradle section in the nixpkgs manual.",
   "!version": 1,
-  "https://api.foojay.io": {
-    "disco/v3": {
-      "0/distributions": "sha256-Rp8uUFqKgDZZzFuikOVIsHVgg4+U3LLrecTM8E1E8+Q=",
-      "0/ids/73bcfb608d1fde9fb62e462f834a3299/redirect": "sha256-b8sl8/caX/JF3sTr6L1cZD8XmlzQphwI5YqMZZFNL5c=",
-      "0/packages": "sha256-AW0nLYHR4yQcJ9TIw6xdDIMUByoYUo+Vn+1YKMst0ec="
-    }
-  },
   "https://plugins.gradle.org/m2": {
     "com/github/johnrengelman#shadow/8.1.1": {
       "jar": "sha256-CEGXVVWQpTuyG1lQijMwVZ9TbdtEjq/R7GdfVGIDb88=",
diff --git a/pkgs/by-name/pk/pkl/package.nix b/pkgs/by-name/pk/pkl/package.nix
index fc7c91474c3c..2605dfc56e7c 100644
--- a/pkgs/by-name/pk/pkl/package.nix
+++ b/pkgs/by-name/pk/pkl/package.nix
@@ -3,12 +3,12 @@
   lib,
   fetchFromGitHub,
   gradle,
-  jdk21,
+  temurin-bin-21,
   kotlin,
   nix-update-script,
 }:
 let
-  jdk = jdk21;
+  jdk = temurin-bin-21;
   gradleOverlay = gradle.override { java = jdk; };
   kotlinOverlay = kotlin.override { jre = jdk; };
   commitHash = "8bd738e";
@@ -43,8 +43,8 @@ stdenv.mkDerivation (finalAttrs: {
     "-DreleaseBuild=true"
     "-Dorg.gradle.java.home=${jdk}"
     "-DcommitId=${commitHash}"
-    "-Dorg.gradle.java.toolchains.autoProvision=false"
-    "-Dorg.gradle.java.toolchains.auto-detect=false"
+    "-Porg.gradle.java.installations.auto-download=false"
+    "-Porg.gradle.java.installations.auto-detect=false"
   ];
 
   JAVA_TOOL_OPTIONS = "-Dfile.encoding=utf-8";
@@ -61,7 +61,7 @@ stdenv.mkDerivation (finalAttrs: {
   '';
 
   passthru.updateScript = nix-update-script { };
-  
+
   meta = {
     description = "A configuration as code language with rich validation and tooling.";
     homepage = "https://pkl-lang.org";
-- 
2.49.0

Built on x86_64-linux.

Note that this triggers a kotlinc and gradle rebuild, but those aren't from source so that cost almost no time. Also I manually removed that foojay.io entry, but it might re-appear after an update, so this is just a bodge.

@hugolgst
Copy link
Member Author

Thank you @dtomvan. I had forgotten to mention it failed to build

@dtomvan
Copy link
Contributor

dtomvan commented Apr 27, 2025

#402115 just got merged into master, so nixpkgs-review currently needs to rebuild all reverse dependents of file... So I cannot test the build with nixpkgs-review-gha anymore... I guess wait until hydra built it all?

@hugolgst
Copy link
Member Author

I guess so

@hugolgst hugolgst marked this pull request as ready for review April 27, 2025 15:33
@hugolgst hugolgst self-assigned this Apr 27, 2025
@hugolgst
Copy link
Member Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 402086


aarch64-darwin

✅ 1 package built:
  • pkl

Copy link
Contributor

@dtomvan dtomvan left a comment

Choose a reason for hiding this comment

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

Only nit I have. Happy to see pkl finally packaged 🎉

In the previous PR someone wanted a different path for "pkldoc" I think. Is that still needed?

@dtomvan
Copy link
Contributor

dtomvan commented Apr 27, 2025

Also, it could be nice to have support for a graalvm native build for its better performance compared to jpkl. Here's how @rafaelrc7 initially did it, might come in useful here: https://github.com/rafaelrc7/nixpkgs/blob/547687c5e341c9b0a9290bb277ef6cc81d1a3554/pkgs/by-name/pk/pkl/package.nix

@hugolgst
Copy link
Member Author

don't have that much time anymore to spend actually building on this PR. how big of an improvement are we talking here?
is that worth it? seems like a patch is needed

@dtomvan
Copy link
Contributor

dtomvan commented Apr 27, 2025

That's alright, I'll give it a try tomorrow then. Just a suggestion anyways but I think I'd be helpful to nixos users (otherwise some people might say "pkl is always just slower on nix for no reason" for example)

Copy link
Contributor

@nyukuru nyukuru left a comment

Choose a reason for hiding this comment

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

Please add the tests to the build, #286658 (comment) should still be useful.

@hugolgst
Copy link
Member Author

@dtomvan good point. i can have a go and will see if it takes too much time i will update you

@hugolgst hugolgst requested a review from nyukuru April 28, 2025 06:46
@hugolgst hugolgst mentioned this pull request Apr 28, 2025
13 tasks
@hugolgst
Copy link
Member Author

hugolgst commented Apr 28, 2025

Tried implementing tests but it fails and I do not have that much time left to spend on this PR. If anybody's willing to help me figure out why it fails it would be greatly appreciated
(#286658 (comment))

nix build .#pkl --keep-failed

@marcusramberg
Copy link
Contributor

Shouldn't this be wrapping java? When I build and try to run it I get

[nix-shell:~/.cache/nixpkgs-review/pr-402086]$ ./results/pkl-aarch64-linux/bin/pkl
./results/pkl-aarch64-linux/bin/pkl: line 3: exec: java: not found

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one person. label Apr 30, 2025
@dtomvan
Copy link
Contributor

dtomvan commented May 1, 2025

Something must've slipped through. I have definitely checked that the jpkl worked before. Now I get:

$ nix-build -A pkl
[...]
$ file ./result/bin/pkl
./result/bin/pkl: data

Copy link
Contributor

@dtomvan dtomvan left a comment

Choose a reason for hiding this comment

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

That file, albeit a weird format, seems to work when run with nix-shell -p temurin-bin-21 (which I accidentally must've done while reviewing), so maybe, instead of that sed command, which doesn't seems to work consistently, rather something like wrapProgram $out/bin/pkl --prefix PATH : "${lib.makeBinPath [ jdk ]}" should be used?

@hugolgst
Copy link
Member Author

hugolgst commented May 1, 2025

pushed your suggestion + dynamically getting the commit hash to feed to -DcommitId

@hugolgst
Copy link
Member Author

hugolgst commented May 1, 2025

image

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 402086


aarch64-darwin

✅ 1 package built:
  • pkl

@hugolgst
Copy link
Member Author

hugolgst commented May 1, 2025

any kind souls willing to test on other platforms?

@hugolgst hugolgst requested a review from dtomvan May 1, 2025 13:47
@FliegendeWurst
Copy link
Member

The wrapper seems to be broken on Linux, I'm looking into a fix right now.

@dtomvan
Copy link
Contributor

dtomvan commented May 1, 2025

By the way this can all be worked around when built as a native executable. That way it's also faster. The drv I made for that is here if you are interested in copying some parts of that.

@hugolgst
Copy link
Member Author

hugolgst commented May 1, 2025

@dtomvan didnt you say last time you had trouble running the tests with that setup?

@dtomvan
Copy link
Contributor

dtomvan commented May 1, 2025

You are right. We could just disable tests for the native build, but that kind-of defeats the point of all this effort to make the tests pass....

@hugolgst
Copy link
Member Author

hugolgst commented May 1, 2025

We'll see if @FliegendeWurst manages to fix the Linux build
Otherwise we can explore your solution

Copy link
Member

@FliegendeWurst FliegendeWurst left a comment

Choose a reason for hiding this comment

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

With these changes the Linux build works

@hugolgst
Copy link
Member Author

hugolgst commented May 1, 2025

builds & runs on darwin
thank you @FliegendeWurst

@hugolgst hugolgst requested a review from FliegendeWurst May 1, 2025 14:59
@hugolgst
Copy link
Member Author

hugolgst commented May 1, 2025

unless anybody has something else to point out we should probably move forward with this pr

Copy link
Member

@FliegendeWurst FliegendeWurst left a comment

Choose a reason for hiding this comment

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

Works on Linux and Darwin

Copy link
Contributor

@dtomvan dtomvan left a comment

Choose a reason for hiding this comment

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

The following is probably redundant, but since I still have a "changes requested" next to my name, here you go:

nixpkgs-review result for #402086

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 402086

Logs: https://github.com/dtomvan/nixpkgs-review-gha/actions/runs/14777679232


x86_64-linux

✅ 1 package built:
  • pkl

aarch64-linux

✅ 1 package built:
  • pkl

x86_64-darwin (sandbox = false)

✅ 1 package built:
  • pkl

aarch64-darwin (sandbox = false)

✅ 1 package built:
  • pkl

@FliegendeWurst FliegendeWurst merged commit 383b556 into NixOS:master May 1, 2025
25 of 27 checks passed
@hugolgst
Copy link
Member Author

hugolgst commented May 1, 2025

Thanks a lot guys, really appreciate all the help. Great work

@hugolgst hugolgst mentioned this pull request May 1, 2025
@ealap ealap mentioned this pull request May 5, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants