Skip to content

turnerdev/janet-nix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

janet-nix

nix flake helpers for Janet projects using jpm (Janet Project Manager).

Should be considered alpha.

Prerequisites

Install dependencies for the current project and create a lockfile:

jpm deps
jpm make-lockfile
git add lockfile.jdn

Usage

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 .

API

mkJanet accepts the following parameters. All are optional aside from name, src and one of either quickbin, main or bin

  • name output binary
  • src source path or repo, passed to mkDerivation
  • version passed to mkDerivation
  • buildInputs additional nix packages
  • extraDeps additional Janet sources, see Tips
  • quickbin an entry point for jpm quickbin
  • main specify Janet code to use as the entry point to jpm quickbin
  • bin specify a binary from $JANET_TREE/bin to use as result

Templates

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

Tips

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.

Changelog

v0.1.0

  • Breaking change: Renamed entry to quickbin
  • Added alternative entry points
    • main to provide Janet code to act as the entry to jpm quickbin
    • bin to specify a binary from $JANET_TREE/bin to use as result
  • extraDeps to pass dependencies directly to mkJanet, useful for building third-party repos without a lockfile.jdn

License

MIT

Releases

No releases published

Packages

No packages published