elm2nix: Turn your Elm project into buildable Nix project

[ bsd3, library, program, unclassified ] [ Propose Tags ]

Please see the README on Github at https://github.com/domenkozar/elm2nix#readme

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS] 0.1.0, 0.1.1, 0.1.2, 0.2, 0.2.1, 0.3.0
Change log CHANGELOG.md
Dependencies aeson, ansi-wl-pprint, async, base (>=4.7 && <5), binary, bytestring, containers, data-default, directory, elm2nix, filepath, here, mtl, optparse-applicative, process, req, text, transformers, unordered-containers [details]
License BSD-3-Clause
Copyright 2017-2022 Domen Kozar
Author Domen Kozar
Maintainer domen@dev.si
Home page https://github.com/domenkozar/elm2nix#readme
Bug tracker https://github.com/domenkozar/elm2nix/issues
Source repo head: git clone https://github.com/domenkozar/elm2nix
Uploaded by domenkozar at 2022-09-06T18:45:59Z
Distributions LTSHaskell:0.3.0, NixOS:0.3.0, Stackage:0.3.0
Executables elm2nix
Downloads 1812 total (20 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-09-06 [all 1 reports]

Readme for elm2nix-0.3.0

[back to package description]


Build Status Hackage

Convert an Elm project into Nix expressions.

It consists of multiple commands:

  • elm2nix convert: Given elm.json in current directory, all dependencies are parsed and their sha256sum calculated
  • elm2nix snapshot: Downloads snapshot of http://package.elm-lang.org into versions.dat
  • elm2nix init: Generates default.nix that glues everything together


Supports Elm 0.19.1


Make sure you have up to date stable or unstable nixpkgs channel.

$ nix-env -i elm2nix

From source

$ git clone https://github.com/domenkozar/elm2nix.git
$ cd elm2nix
$ nix-env -if .


$ git clone https://github.com/evancz/elm-todomvc.git
$ cd elm-todomvc
$ elm2nix init > default.nix
$ elm2nix convert > elm-srcs.nix
$ elm2nix snapshot > versions.dat
$ nix-build
$ chromium ./result/Main.html

Running tests (as per CI)

$ ./scripts/tests.sh


Why is mkDerivation inlined into default.nix?

As it's considered experimental, it's generated for now. Might change in the future.

How to use with ParcelJS and Yarn?

Instead of running elm2nix init, use something like:

{ pkgs ? import <nixpkgs> {}

  yarnPkg = pkgs.yarn2nix.mkYarnPackage {
    name = "myproject-node-packages";
    packageJSON = ./package.json;
    unpackPhase = ":";
    src = null;
    yarnLock = ./yarn.lock;
    publishBinsFor = ["parcel-bundler"];
in pkgs.stdenv.mkDerivation {
  name = "myproject-frontend";
  src = pkgs.lib.cleanSource ./.;

  buildInputs = with pkgs.elmPackages; [

  patchPhase = ''
    rm -rf elm-stuff
    ln -sf ${yarnPkg}/node_modules .

  shellHook = ''
    ln -fs ${yarnPkg}/node_modules .

  configurePhase = pkgs.elmPackages.fetchElmDeps {
    elmPackages = import ./elm-srcs.nix;
    versionsDat = ./versions.dat;

  installPhase = ''
    mkdir -p $out
    parcel build -d $out index.html