Giter VIP home page Giter VIP logo

janet-nix's Introduction

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

janet-nix's People

Contributors

turnerdev avatar

Stargazers

 avatar  avatar

Watchers

 avatar

janet-nix's Issues

Building a project without a lockfile.jdn

I am new to both Janet and Nix and am trying to use this flake build Judge. The problem is that Judge doesn't have a lockfile.jdn. Checking out mkJanet it seems like there needs to be a lockfile to allow it to fetch the sources. Is it possible to generate a lockfile if one doesn't exist?

The only solution I have working right now is to fork judge and add one.

My package:

judge = janet-nix.packages.x86_64-linux.mkJanet {
  name = "judge";
  src = pkgs.fetchFromGitHub {
    owner = "ianthehenry";
    repo = "judge";
    rev = "v2.4.0";
    sha256 = "sha256-ef2ol4k36tRCDyOdvBXu38t2U3baMRBM4b+eWOikW7w=";
  };
  entry = "./src/judge";
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.