cachix/elm2nix

Convert Elm project into Nix expressions

Haskell

126

134 commits

updated Sep 9, 2025

See the code

README

elm2nix

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: Reads packages from elm.json and writes them to binary cache file registry.dat used by elm-compiler.
  • elm2nix init: Generates default.nix that glues everything together

Assumptions

Supports Elm 0.19.1

Installation

It's already included in devenv when using Elm:

{
  langauges.elm.enable = true;

  tasks = {
    "frontend:elm2nix" = {
      exec = "cd frontend && elm2nix convert > elm-srcs.nix && elm2nix snapshot";
      execIfModified = [ "frontend/elm.json" ];
      before = [ "devenv:enterShell" ];
    };
  };

}

Running tests (as per CI)

$ ./scripts/tests.sh

FAQ

Why is mkDerivation inlined into default.nix?

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

How do I use elm2nix with ParcelJS and Yarn?

Instead of running elm2nix init, create a default.nix with the following derivation:

https://github.com/cachix/elm2nix/issues/49#issuecomment-1696082884

elm
elm-lang
haskell
nix

Contributors

domenkozar

78 commits

sandydoo

18 commits

gpampara

9 commits

bmillwood

9 commits

cachix/elm2nix

Convert Elm project into Nix expressions

Haskell

126

134 commits

updated Sep 9, 2025

See the code

README

elm2nix

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: Reads packages from elm.json and writes them to binary cache file registry.dat used by elm-compiler.
  • elm2nix init: Generates default.nix that glues everything together

Assumptions

Supports Elm 0.19.1

Installation

It's already included in devenv when using Elm:

{
  langauges.elm.enable = true;

  tasks = {
    "frontend:elm2nix" = {
      exec = "cd frontend && elm2nix convert > elm-srcs.nix && elm2nix snapshot";
      execIfModified = [ "frontend/elm.json" ];
      before = [ "devenv:enterShell" ];
    };
  };

}

Running tests (as per CI)

$ ./scripts/tests.sh

FAQ

Why is mkDerivation inlined into default.nix?

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

How do I use elm2nix with ParcelJS and Yarn?

Instead of running elm2nix init, create a default.nix with the following derivation:

https://github.com/cachix/elm2nix/issues/49#issuecomment-1696082884

elm
elm-lang
haskell
nix

Contributors

domenkozar

78 commits

sandydoo

18 commits

gpampara

9 commits

bmillwood

9 commits

Languages

Haskell

85.0%

Nix

11.1%

Shell

3.9%