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.
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:
- Remove all the hacks in upstream packages to make them Nix-compatible out of the box.
- 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.
These are the rules followed:
- Builds on NixOS
- Builds are reasonably fast (eg. we avoid usage of
stack2nix
and large rebuilds of Haskell packages) - Easy to pull from remote
- Nixpkgs-like conventions
- Linux and MacOS portability
- Utilizing existing Nix tooling
Tooling provided so far:
elm-test
elm-verify-examples
elm-analyse
elm-doc-preview
elmi-to-json
elm-upgrade
elm-live
elm-xref
elm-language-server
If you miss your favorite tool, feel free to open an issue or submit a PR.
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
];
}
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; }
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.
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.