janet2nix is a set of tools for writing and packaging janet applications with and for the nix package manager.
See the example repo for how to use in a flake.
janet2nix provides 4 tools.
mkJanetApplication
accepts an attrset with 3 properties;
name
- this should be the name of your final executable. The function currently looks for this name to copy to thebin/
folder.src
- this gets passed to mkDerivation, all the same rules apply.withJanetPackages
- this is a list of packages built usingmkJanetPackage
mkJanetApplication
will run jpm install
for each dependency listed in withJanetPackages
.
It currently ignores any dependency listed
pkgs.mkJanetApplication {
name = "example";
src = ./.; # local
withJanetPackages = [
# Add any janet dependencies. These are made using mkJanetPackage
pkgs.janetPackages.spork
];
};
mkJanetPackage
downloads a jpm package from a public git repository and sets it up to be installed by jpm install
.
pkgs.mkJanetPackage {
name = "sh";
url = "https://github.com/andrewchambers/janet-sh.git";
rev = "221bcc869bf998186d3c56a388c8313060bfd730";
hash = "sha256-pFR5kIFpAV0ReYGE9QRc63fzD39TqwGI15RxdsqExl4=";
withJanetPackages = [
pkgs.janetPackages.posix-spawn
];
};
mkJanetTree
accepts an attrset with 2 properties;
name
- this should be the name of your final executable. The function currently looks for this name to copy to thebin/
folder.withJanetPackages
- this is a list of packages built usingmkJanetPackage
mkJanetTree
will build a derivation that provides a janet and jpm binary with there path set to find any provided packages. jpm install
is run for every package.
pkgs.mkJanetTree {
name = "example";
withJanetPackages = [
# Add any janet dependencies. These are made using mkJanetPackage
pkgs.janetPackages.spork
];
};
Some jpm packages are pre-packaged here.
Current list includes:
- spork
- sh
- posix-spawn
- Read
project.janet
file to generate dependencies instead of explicitly creating them. - Read
project.janet
file determine what executable to copy tobin/
. - Optionally copy library exes to
$out/bin/
. - Make all the "blessed" janet packages available in
pkgs.janetPackages
. - Switch mkJanetPackage to take a
src
attribute instead of assuming a git repo.