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.jdn
Use 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
name
output binarysrc
source path or repo, passed tomkDerivation
version
passed tomkDerivation
buildInputs
additional nix packagesextraDeps
additional Janet sources, see Tipsquickbin
an entry point forjpm quickbin
main
specify Janet code to use as the entry point tojpm quickbin
bin
specify a binary from$JANET_TREE/bin
to 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-project
Missing 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-nix
To generate a list of nix sources from the lockfile. You can pass this list to mkJanet
with the extraDeps
attribute.
- Breaking change: Renamed
entry
toquickbin
- Added alternative entry points
main
to provide Janet code to act as the entry tojpm quickbin
bin
to specify a binary from$JANET_TREE/bin
to use as result
extraDeps
to pass dependencies directly tomkJanet
, useful for building third-party repos without alockfile.jdn
MIT