No description
Find a file
github-actions 88b3923af3
Some checks failed
CI / run-tests (push) Has been cancelled
[ghactions] Update elm-hashes, elm-failures and all-packages JSONs
2025-01-26 01:22:54 +00:00
.github/workflows Add CI tests 2024-01-12 19:30:48 +00:00
external Update wiki external 2024-01-11 19:50:42 +00:00
mkElmDerivation [ghactions] Update elm-hashes, elm-failures and all-packages JSONs 2025-01-26 01:22:54 +00:00
nix Move project towards a more general mkElmDerivation function 2024-01-27 14:31:46 +00:00
src Move elm snapshot back into this repository 2024-01-27 14:42:57 +00:00
tests Move project towards a more general mkElmDerivation function 2024-01-27 14:31:46 +00:00
.dir-locals.el Add elm-optimize-level-2 test 2024-01-12 19:24:28 +00:00
.envrc Initial Commit 2022-12-18 23:14:17 +00:00
.gitignore Initial Commit 2022-12-18 23:14:17 +00:00
.gitmodules Add wiki submodule 2023-04-11 19:33:45 +01:00
CHANGELOG.md Update changelog and version to v0.5.1 2024-01-27 14:49:17 +00:00
flake.lock Move elm snapshot back into this repository 2024-01-27 14:42:57 +00:00
flake.nix Move elm snapshot back into this repository 2024-01-27 14:42:57 +00:00
LICENSE Fill paragraph on the license 2023-03-17 20:27:23 +00:00
README.org Move project towards a more general mkElmDerivation function 2024-01-27 14:31:46 +00:00

mkElmDerivation

https://img.shields.io/badge/built%20with-Haskell-8f4e8b.svg https://img.shields.io/badge/built%20for-Elm-60b6cd.svg https://img.shields.io/github/license/jeslie0/mkelmderivation.svg https://img.shields.io/github/actions/workflow/status/jeslie0/mkElmDerivation/CI.yml.svg

This repository provides an unopinionated, general approach to packaging Elm projects. An overlay is provided, giving a function mkElmDerivation which is an overloaded version of nixpkgs's mkDerivation, but with all of your elm dependencies downloaded and stored in the right place. This allows you to package normal Elm projects, but also things like elm-spa and elm-watch apps. All of this is done by using your project's elm.json file, and requires no updating of nix files when you update your dependencies.

Examples

The following is the content of a flake.nix file, which can be used to build a normal elm project.

{
  description = "An example flake for building elm projects.";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    mkElmDerivation.url = "github:jeslie0/mkElmDerivation";
  };

  outputs = { self, nixpkgs, mkElmDerivation }:
    let
      system =
        "x86_64-linux";

      pkgs = import nixpkgs {
        overlays = [ mkElmDerivation.overlay ];
        inherit system;
      };
      in
        {
          packages = {
            default = pkgs.mkElmDerivation {
              name = "elm-example";
              src = ./.;
              elmJson = ./elm.json; # This defaults to ${src}/elm.json
              nativeBuildInputs =
                [ pkgs.elmPackages.elm ];
              buildPhase =
                ''
                elm make src/Main.elm --output Main.js --optimize
                '';
              installPhase =
                ''
                mkdir $out
                cp Main.js $out
                '';
            };
          };
        };
}

We aren't restricted to just using Elm, however. Since this is just wrapper around mkDerivation, you can use whatever build inputs and build commands you want. See the tests directory for some more examples.

Versions

This project currently supports version 0.19.1 of Elm.

Deprecations

This project currently provides the functions mkElmSpaDerivation and mkElmWatchDerivation. The existence of these functions made sense when mkElmDerivation was more opinionated and less customizable; however, now that mkElmDerivation is more generic they aren't as useful. They will be kept in this project until the next major release, but I recommend not using them and instead using mkElmDerivation with a custom buildPhase and installPhase.

Updates

Currently, a GitHub action is set to run at 0000 every Sunday. This will update the three JSON files stored in the mkElmDerivation directory.