This flake provides a fork of QuickJS and a helper utility to easily build QuickJS-based programs.
You can run QuickJS without committing to installing it by using the following command.
# To run the REPL.
nix run github:snowfallorg/quickjs
# Or to run a JavaScript file.
nix run github:snowfallorg/quickjs -- ./my-script.js
First, include this flake as an input in your flake.
{
description = "My awesome flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
# Snowfall Lib is not required, but will make configuration easier for you.
snowfall-lib = {
url = "github:snowfallorg/lib";
inputs.nixpkgs.follows = "nixpkgs";
};
quickjs = {
url = "github:snowfallorg/quickjs";
inputs.nixpkgs.follows = "nixpkgs";
};
};
}
Then add the overlay or use the quickjs
package from this flake directly.
{
description = "My awesome flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
# Snowfall Lib is not required, but will make configuration easier for you.
snowfall-lib = {
url = "github:snowfallorg/lib";
inputs.nixpkgs.follows = "nixpkgs";
};
quickjs = {
url = "github:snowfallorg/quickjs";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs:
inputs.snowfall-lib.mkFlake {
inherit inputs;
src = ./.;
overlays = with inputs; [
# To make this flake's packages in your NixPkgs package set.
quickjs.overlay
];
outputs-builder = channels:
let
inherit (channels.nixpkgs) system;
# Use the `quickjs` package directly from the input instead.
quickjs = inputs.quickjs.packages.${system}.quickjs;
in {
# Use either `pkgs.quickjs` or `quickjs` in some way.
};
};
}
This flake includes a helper library to create QuickJS-based applications using qjsbootstrap
.
Create a qjsbootstrap
builder.
Type: Attrs -> Attrs
Usage:
mkBuilder pkgs
Result:
{ build = attrs: {/* ... */}; }
Build a QuickJS-based application.
Type: { files } -> Derivation
Usage:
builder.build {
# Files are appended to `qjsbootstrap` in the order they are listed.
files = [
./my-library.js
./my-script.js
];
}
Result:
Derivation