mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 14:20:35 +01:00
Request to Add pkl (Configuration as Code Language) Package to NixOS #50
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @byteshiva on GitHub (Feb 11, 2024).
Issue Description
Problem
The
pklpackage, a Configuration as Code language developed by Apple, is not currently available in the NixOS packages.Desired Outcome
Include the
pklpackage in NixOS packages.Package Information
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
Reference Links
Thank you for considering this request.
@byteshiva commented on GitHub (Feb 11, 2024):
To make it work in NixOS, I followed the steps below (using jpkl).
Downloaded jpkl:
Made the script executable:
Checked file type (confirmed as POSIX shell script executable):
Checked dynamic dependencies:
Set up a Nix shell with the appropriate JDK:
Verified installation:
@byteshiva commented on GitHub (Feb 11, 2024):
output
@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
@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.
@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_7andjdk17and rungradle 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 editpkl-cli.gradle.kts, removing thedependsOn(":installGraalVm")fromExec.configureExecutableand in the same function, changeexecutableinto justnative-image, this way gradle will use the graalvm downloaded from nix instead of trying to download it itself, what will not work. Thengradle nativeBuildwill 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) got merged, which might unblock the pkl work.
@goktug97 commented on GitHub (Mar 1, 2025):
Managed to compile it for
x86_64-linuxvia flakes, though it requires unstable branch forgradleandkotlinflake.nix
graalvm.patch
@hugolgst commented on GitHub (Apr 26, 2025):
has anyone tried moving forward with this?
@hugolgst commented on GitHub (Apr 26, 2025):
started this PR https://github.com/NixOS/nixpkgs/pull/402086
@hugolgst commented on GitHub (May 1, 2025):
https://github.com/NixOS/nixpkgs/pull/402086 got merged
@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?
@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?
@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):
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!
@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
@bioball commented on GitHub (May 1, 2025):
Sounds great!
@hugolgst commented on GitHub (May 2, 2025):
🎉
@hugolgst commented on GitHub (May 5, 2025):
Somebody beat me to it :) https://github.com/NixOS/nixpkgs/pull/404324
@dtomvan commented on GitHub (May 5, 2025):
I think right now there are multiple problems:
Could not initialize class com.oracle.truffle.api.Truffle日本語.pklfails:Error: invalid value for <modules>: Malformed input or input contains unmappable characters: /$snippetsDir/input/modules/日本語.pklYou 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: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)git fetch upstream pull/404324/head:pklgit worktree add pkl; cd pklnix-build -A pklThe build recipe file in question lives in
pkgs/by-name/pk/pkl/package.nixin nixpkgs.