Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.
/ nix-elm-tools Public archive

[now part of NixOS/nixpkgs] Elm lang community tooling for Nix and NixOS users.

Notifications You must be signed in to change notification settings

turboMaCk/nix-elm-tools

Repository files navigation

Nix Elm Tools

Build Status

This project is now merged to nixpkgs!. This repository remains maitained till nixpkgs stable relase will include this change.

Elm lang community tooling for the Nix package manager and NixOS operating system.

Motivation

Getting all the existing community tooling for the Elm language running with Nix is painful. This is mostly due to the usage of binary wrappers to make Haskell binaries and Node.js work together. For instance, nodePackages.elm-test provided by Nixpkgs as of today isn't working. I believe the situation can be improved though! Generally there are two ways to do so:

  1. Remove all the hacks in upstream packages to make them Nix-compatible out of the box.
  2. Implement custom Nix-specific builds for Elm tooling with Nix-specific patches.

I've decided to start with 2nd. This project thus introduces expressions which allow fully working builds using Nix, including all the patches. As a next step I'm going to identify pieces which seem to make sense to upstream in order to simplify the build. My goal is to end up with easy to maintain builds which can be merged into Nixpkgs.

Rules

These are the rules followed:

  1. Builds on NixOS
  2. Builds are reasonably fast (eg. we avoid usage of stack2nix and large rebuilds of Haskell packages)
  3. Easy to pull from remote
  4. Nixpkgs-like conventions
  5. Linux and MacOS portability
  6. Utilizing existing Nix tooling

Components

Tooling provided so far:

If you miss your favorite tool, feel free to open an issue or submit a PR.

Usage

nix-env from source:

# clone project
$ git clone https://github.com/turboMaCk/nix-elm-tools.git
$ cd nix-elm-tools

# install elm-test
$ nix-env -f default.nix -iA elm-test
installing 'node-elm-test-0.19.0-rev6'
building '/nix/store/bf69nj0mzfqajgip1bpxwg05y1zh7191-user-environment.drv'...
created 21 symlinks in user environment

remote install:

let
  pkgs = import <nixpkgs> {};

  elmTools = import (pkgs.fetchFromGitHub {
    owner = "turboMaCk";
    repo = "nix-elm-tools";
    rev = "45f5db65fc2453e757c60ae54c611d1d8baa20cf";
    sha256 = "1gc3p5xivb2k9jm22anzm6xy1cnzw2ab6jq8ifws92pvfnvx0lxv";
  }) { inherit pkgs; };
in
{
  inherit (elmTools) elm-test elm-verify-examples;
}

nix-shell remote install:

{ pkgs ? import <nixpkgs> {} }:
let
  elmTools = import (pkgs.fetchFromGitHub {
    owner = "turboMaCk";
    repo = "nix-elm-tools";
    rev = "45f5db65fc2453e757c60ae54c611d1d8baa20cf";
    sha256 = "1gc3p5xivb2k9jm22anzm6xy1cnzw2ab6jq8ifws92pvfnvx0lxv";
  }) { inherit pkgs; };
in
  with pkgs;
  mkShell {
    buildInputs = with elmTools; [ elm-test elm-verify-examples ];
  }

NixOS configuration remote install:

{ pkgs, ... }:
let
  elmTools = import (pkgs.fetchFromGitHub {
    owner = "turboMaCk";
    repo = "nix-elm-tools";
    rev = "45f5db65fc2453e757c60ae54c611d1d8baa20cf";
    sha256 = "1gc3p5xivb2k9jm22anzm6xy1cnzw2ab6jq8ifws92pvfnvx0lxv";
  }) { inherit pkgs; };
in {
  environment.systemPackages = with pkgs.elmPackages; [
    elm
    elm-format
    pkgs.elm2nix
    elmTools.elm-test
    elmTools.elm-verify-examples
    elmTools.elm-analyse
    elmTools.elm-doc-preview
  ];
}

Compiling Haskell

By default, instead of compiling elmi-to-json from source, the binary blob is downloaded from github releases.

If you prefer to compile everything from source, you can set compileHS option to true.

nix-env from command line:

$ nix-build -A elm-test --arg compileHS true

or with remote install via Nix

let
  pkgs = import <nixpkgs> {};
in
import (pkgs.fetchFromGitHub {
  owner = "turboMaCk";
  repo = "nix-elm-tools";
  rev = "45f5db65fc2453e757c60ae54c611d1d8baa20cf";
  sha256 = "1gc3p5xivb2k9jm22anzm6xy1cnzw2ab6jq8ifws92pvfnvx0lxv";
}) { inherit pkgs; compileHS = true; }

Development

All contributions are welcome. If you want to add a tool available via npm, add it to packages.json, and generete new nix files using generate.sh.

$ ./generate.sh

In order to make the tool exposed to the end user, edit the default.nix file, and add it to the set it defines. Some tools depend on elmi-to-json binary (usually installed via npm with binwrap). binwrap installation is not compatible with Nix out of the box. See elm-test as an example of how such a package can be patched by expressions provided as part of this repository.

Get More!

If you're a Nix user, you should definitely try the awesome elm2nix. Big shouts to @domenkozar and the whole hercules-ci for their work.

About

[now part of NixOS/nixpkgs] Elm lang community tooling for Nix and NixOS users.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages