Skip to content

snowfallorg/quickjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuickJS ❤ Nix

Nix Flakes Ready Built With Snowfall Powered By QuickJS

  

This flake provides a fork of QuickJS and a helper utility to easily build QuickJS-based programs.

Try Without Installing

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

Usage

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.
				};
		};
}

Library

This flake includes a helper library to create QuickJS-based applications using qjsbootstrap.

quickjs.lib.mkBuilder

Create a qjsbootstrap builder.

Type: Attrs -> Attrs

Usage:

mkBuilder pkgs

Result:

{ build = attrs: {/* ... */}; }

Builder.build

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

About

Build QuickJS-based applications with Nix.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published