Request to Add pkl (Configuration as Code Language) Package to NixOS #50

Open
opened 2025-12-30 01:20:02 +01:00 by adam · 18 comments
Owner

Originally created by @byteshiva on GitHub (Feb 11, 2024).

Issue Description

Problem

The pkl package, a Configuration as Code language developed by Apple, is not currently available in the NixOS packages.

Desired Outcome

Include the pkl package in NixOS packages.

Package Information

  • Package Name: pkl
  • GitHub Repository: apple/pkl

Additional Context

pkl is a Configuration as Code language with rich validation and tooling. Adding it to NixOS packages would benefit users involved in configuration management and development workflows.

Environment Information

  • NixOS Version: 23.11 or current
  • Nixpkgs Channel: unstable
  1. NixOS Website
  2. NixOS Package Search - pkl

Thank you for considering this request.

Originally created by @byteshiva on GitHub (Feb 11, 2024). ### Issue Description #### Problem The `pkl` package, a Configuration as Code language developed by Apple, is not currently available in the NixOS packages. #### Desired Outcome Include the `pkl` package in NixOS packages. #### Package Information - **Package Name:** pkl - **GitHub Repository:** [apple/pkl](https://github.com/apple/pkl) #### Additional Context [pkl](https://github.com/apple/pkl) is a Configuration as Code language with rich validation and tooling. Adding it to NixOS packages would benefit users involved in configuration management and development workflows. ### Environment Information - **NixOS Version:** 23.11 or current - **Nixpkgs Channel:** unstable #### Reference Links 1. [NixOS Website](https://nixos.org/) 2. [NixOS Package Search - pkl](https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=pkl) Thank you for considering this request.
Author
Owner

@byteshiva commented on GitHub (Feb 11, 2024):

To make it work in NixOS, I followed the steps below (using jpkl).

  1. Downloaded jpkl:

    curl -L -o jpkl https://repo1.maven.org/maven2/org/pkl-lang/pkl-cli-java/0.25.2/pkl-cli-java-0.25.2.jar
    
  2. Made the script executable:

    chmod +x jpkl
    
  3. Checked file type (confirmed as POSIX shell script executable):

    file jpkl
    jpkl: POSIX shell script executable (binary data)
    
  4. Checked dynamic dependencies:

    ldd ./jpkl
    not a dynamic executable
    
  5. Set up a Nix shell with the appropriate JDK:

    nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz -p jdk
    
  6. Verified installation:

    ./jpkl --version
    Pkl 0.25.2 (Linux 6.1.69, Java 19.0.2)
    
@byteshiva commented on GitHub (Feb 11, 2024): To make it work in NixOS, I followed the steps below (using jpkl). 1. Downloaded jpkl: ```bash curl -L -o jpkl https://repo1.maven.org/maven2/org/pkl-lang/pkl-cli-java/0.25.2/pkl-cli-java-0.25.2.jar ``` 2. Made the script executable: ```bash chmod +x jpkl ``` 3. Checked file type (confirmed as POSIX shell script executable): ```bash file jpkl jpkl: POSIX shell script executable (binary data) ``` 4. Checked dynamic dependencies: ```bash ldd ./jpkl not a dynamic executable ``` 5. Set up a Nix shell with the appropriate JDK: ```bash nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz -p jdk ``` 6. Verified installation: ```bash ./jpkl --version Pkl 0.25.2 (Linux 6.1.69, Java 19.0.2) ```
Author
Owner

@byteshiva commented on GitHub (Feb 11, 2024):

output

~/jpkl eval bird.pkl 

name = "Swallow"
job {
  title = "Sr. Nest Maker"
  company = "Nests R Us"
  yearsOfExperience = 2
}
~/jpkl eval -f json bird.pkl 
{
  "name": "Swallow",
  "job": {
    "title": "Sr. Nest Maker",
    "company": "Nests R Us",
    "yearsOfExperience": 2
  }
}

~/jpkl eval -f plist bird.pkl 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>name</key>
  <string>Swallow</string>
  <key>job</key>
  <dict>
    <key>title</key>
    <string>Sr. Nest Maker</string>
    <key>company</key>
    <string>Nests R Us</string>
    <key>yearsOfExperience</key>
    <integer>2</integer>
  </dict>
</dict>
</plist>

@byteshiva commented on GitHub (Feb 11, 2024): output ``` ~/jpkl eval bird.pkl name = "Swallow" job { title = "Sr. Nest Maker" company = "Nests R Us" yearsOfExperience = 2 } ``` ``` ~/jpkl eval -f json bird.pkl { "name": "Swallow", "job": { "title": "Sr. Nest Maker", "company": "Nests R Us", "yearsOfExperience": 2 } } ``` ``` ~/jpkl eval -f plist bird.pkl <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>name</key> <string>Swallow</string> <key>job</key> <dict> <key>title</key> <string>Sr. Nest Maker</string> <key>company</key> <string>Nests R Us</string> <key>yearsOfExperience</key> <integer>2</integer> </dict> </dict> </plist> ```
Author
Owner

@byteshiva commented on GitHub (Feb 11, 2024):

I've written a brief blog post on setting up Pkl using Nix flakes on NixOS.

Details available at https://byteshiva.medium.com/simplifying-configuration-with-pkl-cli-on-nixos-08790fbe4e5c

@byteshiva commented on GitHub (Feb 11, 2024): I've written a brief blog post on setting up Pkl using Nix flakes on NixOS. Details available at [https://byteshiva.medium.com/simplifying-configuration-with-pkl-cli-on-nixos-08790fbe4e5c](https://byteshiva.medium.com/simplifying-configuration-with-pkl-cli-on-nixos-08790fbe4e5c)
Author
Owner

@izzymelons commented on GitHub (Feb 11, 2024):

There's a request (https://github.com/NixOS/nixpkgs/issues/286104) with a WIP PR for packaging pkl on the nixpkgs repo: https://github.com/NixOS/nixpkgs/pull/286658

There's also another flake (https://github.com/capslock/pkl-flake) which I've been using for the last few days. I think it just repackages the official native binary releases, so it doesn't require pulling in the entire JDK.

@izzymelons commented on GitHub (Feb 11, 2024): There's a request (https://github.com/NixOS/nixpkgs/issues/286104) with a WIP PR for packaging pkl on the nixpkgs repo: https://github.com/NixOS/nixpkgs/pull/286658 There's also another flake (https://github.com/capslock/pkl-flake) which I've been using for the last few days. I think it just repackages the official native binary releases, so it doesn't require pulling in the entire JDK.
Author
Owner

@rafaelrc7 commented on GitHub (Feb 12, 2024):

I've been trying to package it for NixOS. The ideal way would be to build from source and not download the binary, the latter is only done for proprietary programs, in which case it is the only option. However, I've been having some issues, as described in the PR (https://github.com/NixOS/nixpkgs/pull/286658), and any help would be appreciated.

However, it is not hard to build pkl yourself in nix, if you desire. To build the Java version, you just need gradle_7 and jdk17 and run gradle build. To build the native package it is a bit harder... You need graalvm for JDK 11, that got removed and is only available in 23.05 (github:nixos/nixpkgs/23.05#graalvm11-ce). You then need to edit pkl-cli.gradle.kts, removing the dependsOn(":installGraalVm") from Exec.configureExecutable and in the same function, change executable into just native-image, this way gradle will use the graalvm downloaded from nix instead of trying to download it itself, what will not work. Then gradle nativeBuild will work.

@rafaelrc7 commented on GitHub (Feb 12, 2024): I've been trying to package it for NixOS. The ideal way would be to build from source and not download the binary, the latter is only done for proprietary programs, in which case it is the only option. However, I've been having some issues, as described in the PR (https://github.com/NixOS/nixpkgs/pull/286658), and any help would be appreciated. However, it is not hard to build pkl yourself in nix, if you desire. To build the Java version, you just need `gradle_7` and `jdk17` and run `gradle build`. To build the native package it is a bit harder... You need graalvm for JDK 11, that got removed and is only available in 23.05 (`github:nixos/nixpkgs/23.05#graalvm11-ce`). You then need to edit `pkl-cli.gradle.kts`, removing the `dependsOn(":installGraalVm")` from `Exec.configureExecutable` and in the same function, change `executable` into just `native-image`, this way gradle will use the graalvm downloaded from nix instead of trying to download it itself, what will not work. Then `gradle nativeBuild` will work.
Author
Owner

@lilyball commented on GitHub (Jul 19, 2024):

According to https://github.com/NixOS/nixpkgs/pull/286658#issuecomment-2229226963 the PR NixOS/nixpkgs#272380 (gradle: add setup hook) got merged, which might unblock the pkl work.

@lilyball commented on GitHub (Jul 19, 2024): According to https://github.com/NixOS/nixpkgs/pull/286658#issuecomment-2229226963 the PR [NixOS/nixpkgs#272380 (gradle: add setup hook)](https://github.com/NixOS/nixpkgs/pull/272380) got merged, which might unblock the pkl work.
Author
Owner

@goktug97 commented on GitHub (Mar 1, 2025):

Managed to compile it for x86_64-linux via flakes, though it requires unstable branch for gradle and kotlin

nix run .#fetch-deps # Generate deps.json
nix build # or nix run
flake.nix
{
  description = "PKL-CLI";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };
  outputs =
    {
      self,
      nixpkgs,
      flake-utils,
      nixpkgs-unstable,
    }:
    flake-utils.lib.eachSystem
      [
        "x86_64-linux"
        "aarch64-linux"
        "x86_64-darwin"
        "aarch64-darwin"
      ]
      (
        system:
        let
          javaVersion = 21;

          overlay = final: prev: {
            gradle = (import nixpkgs-unstable { inherit system; }).gradle.override { };
            kotlin = (import nixpkgs-unstable { inherit system; }).kotlin.override { };
          };

          pkgs = import nixpkgs {
            inherit system;
            overlays = [ overlay ];
          };

          jdk = pkgs."jdk${toString javaVersion}";
          gradle = pkgs.gradle.override { java = jdk; };
          kotlin = pkgs.kotlin.override { jre = jdk; };

          pkl = pkgs.stdenv.mkDerivation (finalAttrs: {
            pname = "pkl";
            version = "0.28.0";
            src = pkgs.fetchFromGitHub {
              owner = "apple";
              repo = "pkl";
              rev = "${finalAttrs.version}";
              hash = "sha256-/csM7ERakBwtBhiMwsMS8NypMiW4f8X890O/+DUqTKQ=";
            };
            nativeBuildInputs = [
              gradle
              kotlin
              jdk
              pkgs.graalvm-ce
            ];

            mitmCache = gradle.fetchDeps {
              pkg = pkl;
              data = ./deps.json;
            };

            __darwinAllowLocalNetworking = true;

            gradleFlags = [
              "-x" "spotlessCheck"
              "-DreleaseBuild=true"
              "-PprojVersion=${finalAttrs.version}"
              "-Dorg.gradle.java.home=${jdk}"
              "-Dfile.encoding=utf-8"
              "-DcommitId=842c46e"
              "--stacktrace"
            ];

            gradleBuildTask = "buildNative";

            patches = [ ./graalvm.patch ];

            postPatch = ''
              export graalvm="${pkgs.graalvm-ce}"
              substituteAllInPlace buildSrc/src/main/kotlin/BuildInfo.kt
              substituteInPlace buildSrc/build.gradle.kts \
                --replace-fail "vendor = JvmVendorSpec.ADOPTIUM" ""
              substituteInPlace buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts \
                --replace-fail "vendor = info.jdkVendor" ""
              substituteInPlace buildSrc/src/main/kotlin/BuildInfo.kt \
                --replace-fail "vendor.set(jdkVendor)" ""
              substituteInPlace buildSrc/src/main/kotlin/pklNativeBuild.gradle.kts \
                --replace-fail "dependsOn(assembleNative, checkNative)" \
                 "dependsOn(assembleNative)"
            '';

            doCheck = false;

            preBuild = ''
              gradleFlagsArray+=(-PprojVersionInfo="${finalAttrs.version} NixOS")
            '';

            installPhase = ''
              cp -r pkl-cli/build/executable/pkl-${system} $out
            '';

            meta.sourceProvenance = with pkgs.lib.sourceTypes; [
              fromSource
              binaryBytecode
              binaryNativeCode
            ];
          });
        in
        {
          packages = {
            default = pkgs.writeShellApplication {
              name = "pkl";
              text = ''exec ${pkl} "$@"'';
            };
          };

          apps = {
            fetch-deps = {
              type = "app";
              program = "${pkl.mitmCache.updateScript}";
            };
            default = {
              type = "app";
              program = "${pkl}";
            };
          };

          devShells.default = pkgs.mkShell {
            buildInputs = [
              self.packages.${system}.default
              jdk
              gradle
              kotlin
            ];
          };
        }
      );
}
graalvm.patch
diff --git a/buildSrc/src/main/kotlin/BuildInfo.kt b/buildSrc/src/main/kotlin/BuildInfo.kt
index 3020857b..7f76e708 100644
--- a/buildSrc/src/main/kotlin/BuildInfo.kt
+++ b/buildSrc/src/main/kotlin/BuildInfo.kt
@@ -100,10 +100,14 @@ open class BuildInfo(private val project: Project) {
       File(homeDir, "${baseName}.$extension")
     }
 
-    val installDir: File by lazy { File(homeDir, baseName) }
+    val installDir: File by lazy {
+      // File(homeDir, baseName)
+      File("@graalvm@")
+    }
 
     val baseDir: String by lazy {
-      if (os.isMacOsX) "$installDir/Contents/Home" else installDir.toString()
+      // if (os.isMacOsX) "$installDir/Contents/Home" else installDir.toString()
+      "@graalvm@"
     }
   }

diff --git a/pkl-cli/pkl-cli.gradle.kts b/pkl-cli/pkl-cli.gradle.kts
index 87679e3c..ff0e697f 100644
--- a/pkl-cli/pkl-cli.gradle.kts
+++ b/pkl-cli/pkl-cli.gradle.kts
@@ -302,20 +302,20 @@ fun Exec.configureExecutable(
 /** Builds the pkl CLI for macOS/amd64. */
 val macExecutableAmd64: TaskProvider<Exec> by
   tasks.registering(Exec::class) {
-    dependsOn(":installGraalVmAmd64")
+    // dependsOn(":installGraalVmAmd64")
     configureExecutable(
       buildInfo.graalVmAmd64,
-      layout.buildDirectory.file("executable/pkl-macos-amd64"),
+      layout.buildDirectory.file("executable/pkl-x86_64-darwin"),
     )
   }
 
 /** Builds the pkl CLI for macOS/aarch64. */
 val macExecutableAarch64: TaskProvider<Exec> by
   tasks.registering(Exec::class) {
-    dependsOn(":installGraalVmAarch64")
+    // dependsOn(":installGraalVmAarch64")
     configureExecutable(
       buildInfo.graalVmAarch64,
-      layout.buildDirectory.file("executable/pkl-macos-aarch64"),
+      layout.buildDirectory.file("executable/pkl-aarch64-darwin"),
       listOf("-H:+AllowDeprecatedBuilderClassesOnImageClasspath"),
     )
   }
@@ -323,10 +323,10 @@ val macExecutableAarch64: TaskProvider<Exec> by
 /** Builds the pkl CLI for linux/amd64. */
 val linuxExecutableAmd64: TaskProvider<Exec> by
   tasks.registering(Exec::class) {
-    dependsOn(":installGraalVmAmd64")
+    // dependsOn(":installGraalVmAmd64")
     configureExecutable(
       buildInfo.graalVmAmd64,
-      layout.buildDirectory.file("executable/pkl-linux-amd64"),
+      layout.buildDirectory.file("executable/pkl-x86_64-linux"),
     )
   }
 
@@ -338,10 +338,10 @@ val linuxExecutableAmd64: TaskProvider<Exec> by
  */
 val linuxExecutableAarch64: TaskProvider<Exec> by
   tasks.registering(Exec::class) {
-    dependsOn(":installGraalVmAarch64")
+    // dependsOn(":installGraalVmAarch64")
     configureExecutable(
       buildInfo.graalVmAarch64,
-      layout.buildDirectory.file("executable/pkl-linux-aarch64"),
+      layout.buildDirectory.file("executable/pkl-aarch64-linux"),
       listOf(
         // Ensure compatibility for kernels with page size set to 4k, 16k and 64k
         // (e.g. Raspberry Pi 5, Asahi Linux)
@@ -358,7 +358,7 @@ val linuxExecutableAarch64: TaskProvider<Exec> by
  */
 val alpineExecutableAmd64: TaskProvider<Exec> by
   tasks.registering(Exec::class) {
-    dependsOn(":installGraalVmAmd64")
+    // dependsOn(":installGraalVmAmd64")
     configureExecutable(
       buildInfo.graalVmAmd64,
       layout.buildDirectory.file("executable/pkl-alpine-linux-amd64"),
@@ -368,7 +368,7 @@ val alpineExecutableAmd64: TaskProvider<Exec> by
 
 val windowsExecutableAmd64: TaskProvider<Exec> by
   tasks.registering(Exec::class) {
-    dependsOn(":installGraalVmAmd64")
+    // dependsOn(":installGraalVmAmd64")
     configureExecutable(
       buildInfo.graalVmAmd64,
       layout.buildDirectory.file("executable/pkl-windows-amd64"),
@goktug97 commented on GitHub (Mar 1, 2025): Managed to compile it for `x86_64-linux` via flakes, though it requires unstable branch for `gradle` and `kotlin` ```bash nix run .#fetch-deps # Generate deps.json nix build # or nix run ``` <details> <summary>flake.nix</summary> ```nix { description = "PKL-CLI"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, flake-utils, nixpkgs-unstable, }: flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ] ( system: let javaVersion = 21; overlay = final: prev: { gradle = (import nixpkgs-unstable { inherit system; }).gradle.override { }; kotlin = (import nixpkgs-unstable { inherit system; }).kotlin.override { }; }; pkgs = import nixpkgs { inherit system; overlays = [ overlay ]; }; jdk = pkgs."jdk${toString javaVersion}"; gradle = pkgs.gradle.override { java = jdk; }; kotlin = pkgs.kotlin.override { jre = jdk; }; pkl = pkgs.stdenv.mkDerivation (finalAttrs: { pname = "pkl"; version = "0.28.0"; src = pkgs.fetchFromGitHub { owner = "apple"; repo = "pkl"; rev = "${finalAttrs.version}"; hash = "sha256-/csM7ERakBwtBhiMwsMS8NypMiW4f8X890O/+DUqTKQ="; }; nativeBuildInputs = [ gradle kotlin jdk pkgs.graalvm-ce ]; mitmCache = gradle.fetchDeps { pkg = pkl; data = ./deps.json; }; __darwinAllowLocalNetworking = true; gradleFlags = [ "-x" "spotlessCheck" "-DreleaseBuild=true" "-PprojVersion=${finalAttrs.version}" "-Dorg.gradle.java.home=${jdk}" "-Dfile.encoding=utf-8" "-DcommitId=842c46e" "--stacktrace" ]; gradleBuildTask = "buildNative"; patches = [ ./graalvm.patch ]; postPatch = '' export graalvm="${pkgs.graalvm-ce}" substituteAllInPlace buildSrc/src/main/kotlin/BuildInfo.kt substituteInPlace buildSrc/build.gradle.kts \ --replace-fail "vendor = JvmVendorSpec.ADOPTIUM" "" substituteInPlace buildSrc/src/main/kotlin/pklJavaLibrary.gradle.kts \ --replace-fail "vendor = info.jdkVendor" "" substituteInPlace buildSrc/src/main/kotlin/BuildInfo.kt \ --replace-fail "vendor.set(jdkVendor)" "" substituteInPlace buildSrc/src/main/kotlin/pklNativeBuild.gradle.kts \ --replace-fail "dependsOn(assembleNative, checkNative)" \ "dependsOn(assembleNative)" ''; doCheck = false; preBuild = '' gradleFlagsArray+=(-PprojVersionInfo="${finalAttrs.version} NixOS") ''; installPhase = '' cp -r pkl-cli/build/executable/pkl-${system} $out ''; meta.sourceProvenance = with pkgs.lib.sourceTypes; [ fromSource binaryBytecode binaryNativeCode ]; }); in { packages = { default = pkgs.writeShellApplication { name = "pkl"; text = ''exec ${pkl} "$@"''; }; }; apps = { fetch-deps = { type = "app"; program = "${pkl.mitmCache.updateScript}"; }; default = { type = "app"; program = "${pkl}"; }; }; devShells.default = pkgs.mkShell { buildInputs = [ self.packages.${system}.default jdk gradle kotlin ]; }; } ); } ``` </details> <details> <summary>graalvm.patch</summary> ```patch diff --git a/buildSrc/src/main/kotlin/BuildInfo.kt b/buildSrc/src/main/kotlin/BuildInfo.kt index 3020857b..7f76e708 100644 --- a/buildSrc/src/main/kotlin/BuildInfo.kt +++ b/buildSrc/src/main/kotlin/BuildInfo.kt @@ -100,10 +100,14 @@ open class BuildInfo(private val project: Project) { File(homeDir, "${baseName}.$extension") } - val installDir: File by lazy { File(homeDir, baseName) } + val installDir: File by lazy { + // File(homeDir, baseName) + File("@graalvm@") + } val baseDir: String by lazy { - if (os.isMacOsX) "$installDir/Contents/Home" else installDir.toString() + // if (os.isMacOsX) "$installDir/Contents/Home" else installDir.toString() + "@graalvm@" } } diff --git a/pkl-cli/pkl-cli.gradle.kts b/pkl-cli/pkl-cli.gradle.kts index 87679e3c..ff0e697f 100644 --- a/pkl-cli/pkl-cli.gradle.kts +++ b/pkl-cli/pkl-cli.gradle.kts @@ -302,20 +302,20 @@ fun Exec.configureExecutable( /** Builds the pkl CLI for macOS/amd64. */ val macExecutableAmd64: TaskProvider<Exec> by tasks.registering(Exec::class) { - dependsOn(":installGraalVmAmd64") + // dependsOn(":installGraalVmAmd64") configureExecutable( buildInfo.graalVmAmd64, - layout.buildDirectory.file("executable/pkl-macos-amd64"), + layout.buildDirectory.file("executable/pkl-x86_64-darwin"), ) } /** Builds the pkl CLI for macOS/aarch64. */ val macExecutableAarch64: TaskProvider<Exec> by tasks.registering(Exec::class) { - dependsOn(":installGraalVmAarch64") + // dependsOn(":installGraalVmAarch64") configureExecutable( buildInfo.graalVmAarch64, - layout.buildDirectory.file("executable/pkl-macos-aarch64"), + layout.buildDirectory.file("executable/pkl-aarch64-darwin"), listOf("-H:+AllowDeprecatedBuilderClassesOnImageClasspath"), ) } @@ -323,10 +323,10 @@ val macExecutableAarch64: TaskProvider<Exec> by /** Builds the pkl CLI for linux/amd64. */ val linuxExecutableAmd64: TaskProvider<Exec> by tasks.registering(Exec::class) { - dependsOn(":installGraalVmAmd64") + // dependsOn(":installGraalVmAmd64") configureExecutable( buildInfo.graalVmAmd64, - layout.buildDirectory.file("executable/pkl-linux-amd64"), + layout.buildDirectory.file("executable/pkl-x86_64-linux"), ) } @@ -338,10 +338,10 @@ val linuxExecutableAmd64: TaskProvider<Exec> by */ val linuxExecutableAarch64: TaskProvider<Exec> by tasks.registering(Exec::class) { - dependsOn(":installGraalVmAarch64") + // dependsOn(":installGraalVmAarch64") configureExecutable( buildInfo.graalVmAarch64, - layout.buildDirectory.file("executable/pkl-linux-aarch64"), + layout.buildDirectory.file("executable/pkl-aarch64-linux"), listOf( // Ensure compatibility for kernels with page size set to 4k, 16k and 64k // (e.g. Raspberry Pi 5, Asahi Linux) @@ -358,7 +358,7 @@ val linuxExecutableAarch64: TaskProvider<Exec> by */ val alpineExecutableAmd64: TaskProvider<Exec> by tasks.registering(Exec::class) { - dependsOn(":installGraalVmAmd64") + // dependsOn(":installGraalVmAmd64") configureExecutable( buildInfo.graalVmAmd64, layout.buildDirectory.file("executable/pkl-alpine-linux-amd64"), @@ -368,7 +368,7 @@ val alpineExecutableAmd64: TaskProvider<Exec> by val windowsExecutableAmd64: TaskProvider<Exec> by tasks.registering(Exec::class) { - dependsOn(":installGraalVmAmd64") + // dependsOn(":installGraalVmAmd64") configureExecutable( buildInfo.graalVmAmd64, layout.buildDirectory.file("executable/pkl-windows-amd64"), ``` </details>
Author
Owner

@hugolgst commented on GitHub (Apr 26, 2025):

has anyone tried moving forward with this?

@hugolgst commented on GitHub (Apr 26, 2025): has anyone tried moving forward with this?
Author
Owner

@hugolgst commented on GitHub (Apr 26, 2025):

started this PR https://github.com/NixOS/nixpkgs/pull/402086

@hugolgst commented on GitHub (Apr 26, 2025): started this PR https://github.com/NixOS/nixpkgs/pull/402086
Author
Owner

@hugolgst commented on GitHub (May 1, 2025):

https://github.com/NixOS/nixpkgs/pull/402086 got merged

@hugolgst commented on GitHub (May 1, 2025): https://github.com/NixOS/nixpkgs/pull/402086 got merged
Author
Owner

@bioball commented on GitHub (May 1, 2025):

Nice, thanks for your work here, @hugolgst!

Just so I understand what's going on here: this adds jpkl, and not the native executables?

@bioball commented on GitHub (May 1, 2025): Nice, thanks for your work here, @hugolgst! Just so I understand what's going on here: this adds jpkl, and not the native executables?
Author
Owner

@hugolgst commented on GitHub (May 1, 2025):

Exactly, we had trouble running the tests with the setup we had with the native executables and therefore decided not to move forward for now. We can however reiterate in a future PR. The plan, at least on my end, was to package it asap. It's a pretty big tool and was missing from nixpkgs.
Is that a concern of yours that the native executables are not included?

@hugolgst commented on GitHub (May 1, 2025): Exactly, we had trouble running the tests with the setup we had with the native executables and therefore decided not to move forward for now. We can however reiterate in a future PR. The plan, at least on my end, was to package it asap. It's a pretty big tool and was missing from nixpkgs. Is that a concern of yours that the native executables are not included?
Author
Owner

@bioball commented on GitHub (May 1, 2025):

It's a good idea to support both; the native executable has different perf characteristics (it has minimal startup overhead vs Java, for example):

$ time pkl eval -x '1 + 1' pkl:base
2
________________________________________________________
Executed in   21.77 millis    fish           external
   usr time    6.30 millis    0.22 millis    6.08 millis
   sys time   10.21 millis    2.00 millis    8.21 millis

$ time jpkl eval -x '1 + 1' pkl:base
2
________________________________________________________
Executed in  641.25 millis    fish           external
   usr time  914.41 millis    0.18 millis  914.24 millis
   sys time  126.64 millis    1.70 millis  124.94 millis

We can help with figuring out what's going on with the native executable builds. I'd likely need some pointers on how to debug Nix builds (I've never used NixOS).

But, just getting the Java executable added is great!

@bioball commented on GitHub (May 1, 2025): It's a good idea to support both; the native executable has different perf characteristics (it has minimal startup overhead vs Java, for example): ```shell $ time pkl eval -x '1 + 1' pkl:base 2 ________________________________________________________ Executed in 21.77 millis fish external usr time 6.30 millis 0.22 millis 6.08 millis sys time 10.21 millis 2.00 millis 8.21 millis $ time jpkl eval -x '1 + 1' pkl:base 2 ________________________________________________________ Executed in 641.25 millis fish external usr time 914.41 millis 0.18 millis 914.24 millis sys time 126.64 millis 1.70 millis 124.94 millis ``` We can help with figuring out what's going on with the native executable builds. I'd likely need some pointers on how to debug Nix builds (I've never used NixOS). But, just getting the Java executable added is great!
Author
Owner

@hugolgst commented on GitHub (May 1, 2025):

That's a good point, we figured out it would also be better for build speed obviously.
No worries, you can just install nix, not necessarily run an entire nixos machine! I personally am using nix on macos and it works out just fine. :)
We can peer-code a PR together and try to move forward with this.
I will add a reminder to initiate a draft PR by the end of next week and mention you over there

@hugolgst commented on GitHub (May 1, 2025): That's a good point, we figured out it would also be better for build speed obviously. No worries, you can just install nix, not necessarily run an entire nixos machine! I personally am using nix on macos and it works out just fine. :) We can peer-code a PR together and try to move forward with this. I will add a reminder to initiate a draft PR by the end of next week and mention you over there
Author
Owner

@bioball commented on GitHub (May 1, 2025):

Sounds great!

@bioball commented on GitHub (May 1, 2025): Sounds great!
Author
Owner

@hugolgst commented on GitHub (May 2, 2025):

🎉

nix-shell -p pkl -I nixpkgs=channel:nixpkgs-unstable
Image
@hugolgst commented on GitHub (May 2, 2025): 🎉 ```bash nix-shell -p pkl -I nixpkgs=channel:nixpkgs-unstable ``` <img width="860" alt="Image" src="https://github.com/user-attachments/assets/c82edfc2-813e-4785-958a-17b3e31eeae3" />
Author
Owner

@hugolgst commented on GitHub (May 5, 2025):

Somebody beat me to it :) https://github.com/NixOS/nixpkgs/pull/404324

@hugolgst commented on GitHub (May 5, 2025): Somebody beat me to it :) https://github.com/NixOS/nixpkgs/pull/404324
Author
Owner

@dtomvan commented on GitHub (May 5, 2025):

We can help with figuring out what's going on with the native executable builds. I'd likely need some pointers on how to debug Nix builds (I've never used NixOS).

I think right now there are multiple problems:

You can do it on any distro (would probably also help if someone had a Mac, which can also run nix). A very concise guide to helping with the new PR:

  1. Run the determinate nix installer (this is a fork of the official nix installer with better defaults and it has a good uninstaller)
  2. git clone --bare --depth 1 --origin upstream https://github.com/nixos/nixpkgs; cd nixpkgs (you can do a full clone too but it takes at least 5GB of disk space and takes a while to pull)
  3. git fetch upstream pull/404324/head:pkl
  4. git worktree add pkl; cd pkl
  5. nix-build -A pkl

The build recipe file in question lives in pkgs/by-name/pk/pkl/package.nix in nixpkgs.

@dtomvan commented on GitHub (May 5, 2025): > We can help with figuring out what's going on with the native executable builds. I'd likely need some pointers on how to debug Nix builds (I've never used NixOS). I think right now there are multiple problems: - On darwin, the graalvm step fails, [`Could not initialize class com.oracle.truffle.api.Truffle`](https://github.com/dtomvan/nixpkgs-review-gha/actions/runs/14834675226/job/41643302301#step:7:2700) - On the native build, `日本語.pkl` fails: `Error: invalid value for <modules>: Malformed input or input contains unmappable characters: /$snippetsDir/input/modules/日本語.pkl` You can do it on any distro (would probably also help if someone had a Mac, which can also run `nix`). A very concise guide to helping with the new PR: 1. Run the [determinate nix installer](https://determinate.systems/nix-installer/) (this is a fork of the official nix installer with better defaults and it has a good uninstaller) 2. `git clone --bare --depth 1 --origin upstream https://github.com/nixos/nixpkgs; cd nixpkgs` (you can do a full clone too but it takes at least 5GB of disk space and takes a while to pull) 3. `git fetch upstream pull/404324/head:pkl` 4. `git worktree add pkl; cd pkl` 5. `nix-build -A pkl` The build recipe file in question lives in `pkgs/by-name/pk/pkl/package.nix` in nixpkgs.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#50