PKL Installation via Nix Packages #277

Closed
opened 2025-12-30 01:23:07 +01:00 by adam · 3 comments
Owner

Originally created by @danteay on GitHub (Feb 13, 2025).

Request for Nix implementation

As Nix is getting more popular over the time should be great to create a native Nix derivation for Nix Packages or the NUR repository of Nix to be able to installed easilly on systems that implements Nix

For now my Work arround is create a custom Derivation on my projects where I have to mannually build download hashes for each version and System. Is not the best solution but works.

This is How it looks:

# To import this module, doit in the next way:
#
# home.packages = [
#   (import ../modules/langs/pkl.nix { inherith pkgs; })
# ];
#
# Adjust the path to this file according of the module that is loading it

{ pkgs, ... }:
let
  version = "0.27.0";

  system = builtins.currentSystem;

  archs = {
    "aarch64-darwin" = "macos-aarch64";
    "x86_64-darwin" = "macos-amd64";
    "aarch64-linux" = "linux-aarch64";
    "x86_64-linux" = "linux-amd64";
  };

  shas = {
    "aarch64-darwin" = "sha256-M/mUHGgw5v8K0Ny+lUugKGOKXCt8L518BLBMfbyWFDI=";
    "x86_64-darwin" = "sha256-1kkE1E9eDbnRxM9pwyvkUIPaoP3sAgVqN7ZdQCCzAXs=";
    "aarch64-linux" = "sha256-44wRAs4bX8RT3E+8NbQbNZB/5ayEwbfL+xQtQC+3fAc=";
    "x86_64-linux" = "sha256-5MdrbdAkVtrI0wDqHxxQEC9kFMuUdWdDZHfL98Las6o=";
  };

  arch = archs."${system}";
  sha = shas."${system}";

  url = "https://github.com/apple/pkl/releases/download/${version}/pkl-${arch}";
in
pkgs.stdenv.mkDerivation {
  name = "pkl";
  version = "${version}";

  src = pkgs.fetchurl {
    url = "${url}";
    sha256 = "${sha}";
  };

  phases = [ "installPhase" ];

  installPhase = ''
    mkdir -p $out/bin
    cp $src $out/bin/pkl
    chmod +x $out/bin/pkl
  '';

  meta = {
    description = "A configuration as code language with rich validation and tooling.";
    mainProgram = "pkl";
  };
}
Originally created by @danteay on GitHub (Feb 13, 2025). # Request for Nix implementation As Nix is getting more popular over the time should be great to create a native Nix derivation for Nix Packages or the NUR repository of Nix to be able to installed easilly on systems that implements Nix For now my Work arround is create a custom Derivation on my projects where I have to mannually build download hashes for each version and System. Is not the best solution but works. This is How it looks: ```nix # To import this module, doit in the next way: # # home.packages = [ # (import ../modules/langs/pkl.nix { inherith pkgs; }) # ]; # # Adjust the path to this file according of the module that is loading it { pkgs, ... }: let version = "0.27.0"; system = builtins.currentSystem; archs = { "aarch64-darwin" = "macos-aarch64"; "x86_64-darwin" = "macos-amd64"; "aarch64-linux" = "linux-aarch64"; "x86_64-linux" = "linux-amd64"; }; shas = { "aarch64-darwin" = "sha256-M/mUHGgw5v8K0Ny+lUugKGOKXCt8L518BLBMfbyWFDI="; "x86_64-darwin" = "sha256-1kkE1E9eDbnRxM9pwyvkUIPaoP3sAgVqN7ZdQCCzAXs="; "aarch64-linux" = "sha256-44wRAs4bX8RT3E+8NbQbNZB/5ayEwbfL+xQtQC+3fAc="; "x86_64-linux" = "sha256-5MdrbdAkVtrI0wDqHxxQEC9kFMuUdWdDZHfL98Las6o="; }; arch = archs."${system}"; sha = shas."${system}"; url = "https://github.com/apple/pkl/releases/download/${version}/pkl-${arch}"; in pkgs.stdenv.mkDerivation { name = "pkl"; version = "${version}"; src = pkgs.fetchurl { url = "${url}"; sha256 = "${sha}"; }; phases = [ "installPhase" ]; installPhase = '' mkdir -p $out/bin cp $src $out/bin/pkl chmod +x $out/bin/pkl ''; meta = { description = "A configuration as code language with rich validation and tooling."; mainProgram = "pkl"; }; } ```
adam closed this issue 2025-12-30 01:23:07 +01:00
Author
Owner

@StefMa commented on GitHub (Feb 13, 2025):

Dublicate of #113 and/or #183? 🤔

@StefMa commented on GitHub (Feb 13, 2025): Dublicate of #113 and/or #183? 🤔
Author
Owner

@danteay commented on GitHub (Feb 13, 2025):

Dublicate of #113 and/or #183? 🤔

Maybe just duplicate from #113. Request from #183 speaks about to PKL compile to .nix as now compiles to yaml or json...

@danteay commented on GitHub (Feb 13, 2025): > Dublicate of [#113](https://github.com/apple/pkl/issues/113) and/or [#183](https://github.com/apple/pkl/issues/183)? 🤔 Maybe just duplicate from #113. Request from #183 speaks about to PKL compile to `.nix` as now compiles to yaml or json...
Author
Owner

@bioball commented on GitHub (Feb 14, 2025):

Closing this as a duplicate of #113. Let's continue the conversation there!

@bioball commented on GitHub (Feb 14, 2025): Closing this as a duplicate of #113. Let's continue the conversation there!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#277