nix flake helpers for Janet projects using jpm (Janet Project Manager).
Should be considered alpha.
Install dependencies for the current project and create a lockfile:
jpm deps
jpm make-lockfile
git add lockfile.jdnUse mkJanet to create derivations for executables:
{
packages = forAllSystems (system: {
my-new-program = janet-nix.packages.${system}.mkJanet {
name = "my-new-program";
src = ./.;
quickbin = "init.janet";
};
});
}Build and run:
nix build .
nix run .mkJanet accepts the following parameters. All are optional aside from name, src and one of either quickbin, main or bin
nameoutput binarysrcsource path or repo, passed tomkDerivationversionpassed tomkDerivationbuildInputsadditional nix packagesextraDepsadditional Janet sources, see Tipsquickbinan entry point forjpm quickbinmainspecify Janet code to use as the entry point tojpm quickbinbinspecify a binary from$JANET_TREE/binto use as result
Create a minimal Janet project with dev shell and build derivation:
nix flake new --template github:turnerdev/janet-nix ./my-new-project
cd ./my-new-project
git init
git add .Alternatively, use the full template to include other development tools (jfmt and judge as of now):
nix flake new --template github:turnerdev/janet-nix#full ./my-new-projectMissing lockfile.jdn
When wrapping third-party repos, you may find that lockfile.jdn is missing. To work around this, first check-out the repo in question to a temporary directory, build the lock file as normal and then run:
nix run github:turnerdev/janet-nixTo generate a list of nix sources from the lockfile. You can pass this list to mkJanet with the extraDeps attribute.
- Breaking change: Renamed
entrytoquickbin - Added alternative entry points
mainto provide Janet code to act as the entry tojpm quickbinbinto specify a binary from$JANET_TREE/binto use as result
extraDepsto pass dependencies directly tomkJanet, useful for building third-party repos without alockfile.jdn
MIT