Giter Club home page Giter Club logo

purescript-overlay's Introduction

PureScript Overlay

daily-update darwin-support nix-unit-tests

Pure and reproducible overlay for the standard PureScript toolchain, including support for Nix flakes. The toolchain is auto-updated every day. Currently supported tools:

  • purs, the compiler
  • spago, the package manager
  • purs-tidy, the code formatter
  • purs-backend-es, the optimizer
  • purescript-language-server, the language server protocol

โš ๏ธ This library is unstable and may be reorganized. Use at your own risk!

The overlay is tested on the following architectures:

  • x86_64-linux
  • x86_64-darwin (Intel Mac)
  • aarch64-darwin (M1 Mac)
  • aarch64-linux

The included overlay inserts the latest stable and unstable executables into your packages (ie. purs, purs-unstable, and so on). You can see all specific versions in the named.json file. It also provides many versions of each executable under a -bin namespace (ie. purs-bin, spago-bin, and so on) so you can access specific versions of a tool. For example, you can use purs-bin.purs-0_15_8 to get the 0.15.8 PureScript compiler. These are tracked in the manifests directory.

There is also an included library named purix which provides helper functions for building PureScript packages, namely:

  • buildSpagoLock: Build output directories for any package or workspace listed in a spago.lock file

Usage

In a Nix flake, use the provided overlay when importing nixpkgs to get access to tools like purs and spago and functions like buildSpagoLock. For example, the below flake creates a development shell with recent versions of the PureScript compiler and Spago package manager:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
    purescript-overlay = {
      url = "github:thomashoneyman/purescript-overlay";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, ... }@input:
    let
      supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];

      forAllSystems = nixpkgs.lib.genAttrs supportedSystems;

      nixpkgsFor = forAllSystems (system: import nixpkgs {
        inherit system;
        config = { };
        overlays = builtins.attrValues self.overlays.default;
      });
    in {
      overlays = {
        purescript = inputs.purescript-overlay;
      };

      packages = forAllSystems (system:
        let pkgs = nixpkgsFor.${system}; in {
          default = pkgs.hello; # your package here
        });

      devShells = forAllSystems (system:
        # pkgs now has access to the standard PureScript toolchain
        let pkgs = nixpkgsFor.${system}; in {
          default = pkgs.mkShell {
            name = "my-purescript-project";
            inputsFrom = builtins.attrValues self.packages.${system};
            buildInputs = with pkgs; [
              purs
              spago-unstable
              purs-tidy-bin.purs-tidy-0_10_0
              purs-backend-es
            ];
          };
        });
    };
  };
}

You can also run individual packages from the flake, e.g. to format your src directory:

nix run github:thomashoneyman/purescript-overlay#purs-tidy format-in-place src

Tests

You can run the repository tests using a combination of nix eval .#lib (to run the unit tests in Nix) and nix flake check (to run the derivation-based tests). Both are executed in CI.

purescript-overlay's People

Contributors

thomashoneyman avatar robo-trh avatar deemp avatar bakhtiyarneyman avatar f-f avatar pete-murphy avatar toastal avatar

Watchers

 avatar

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.