Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeslie0/mkelmderivation
A nix flake for simplifiying the packaging of elm projects, inspired by elm2nix.
https://github.com/jeslie0/mkelmderivation
elm flake haskell nix
Last synced: about 1 month ago
JSON representation
A nix flake for simplifiying the packaging of elm projects, inspired by elm2nix.
- Host: GitHub
- URL: https://github.com/jeslie0/mkelmderivation
- Owner: jeslie0
- License: mit
- Created: 2022-12-22T21:05:14.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-10T01:25:38.000Z (about 1 month ago)
- Last Synced: 2024-11-10T02:23:20.013Z (about 1 month ago)
- Topics: elm, flake, haskell, nix
- Language: Haskell
- Homepage: https://github.com/jeslie0/mkElmDerivation/
- Size: 2.76 MB
- Stars: 27
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.org
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
#+title: 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.
#+begin_src nix
{
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
'';
};
};
};
}
#+end_srcWe 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][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 [[file:mkElmDerivation/][mkElmDerivation directory]].