aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuebinm2021-02-19 00:50:11 +0100
committerstuebinm2021-02-19 00:51:22 +0100
commit0aaa2a1738b61b056b3e58f473d85e9eb5702402 (patch)
treec41cc241eae258ad6537eface78e8e095163ca5f
parent56ef5217cc03408b8d2b09809880e2cfda7a5855 (diff)
nix derivation with elm2nix
(modified, to make it work again — elm2nix generates somewhat obstuse and occasionally useless code)
-rw-r--r--.gitignore1
-rw-r--r--default.nix50
-rw-r--r--elm-srcs.nix37
-rw-r--r--index.html2
-rw-r--r--registry.datbin0 -> 106150 bytes
5 files changed, 89 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 2bc193d..f628ce3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
elm-stuff/*
app.js
+result
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..54ebd67
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,50 @@
+{ nixpkgs ? <nixpkgs>
+, config ? {}
+}:
+
+with (import nixpkgs config);
+
+let
+ mkDerivation =
+ { srcs ? ./elm-srcs.nix
+ , src
+ , name
+ , srcdir ? "./src"
+ , targets ? []
+ , registryDat ? ./registry.dat
+ , outputJavaScript ? true
+ }:
+ stdenv.mkDerivation {
+ inherit name src;
+
+ buildInputs = [ elmPackages.elm ];
+
+ buildPhase = pkgs.elmPackages.fetchElmDeps {
+ elmPackages = import srcs;
+ elmVersion = "0.19.1";
+ inherit registryDat;
+ };
+
+ installPhase = let
+ elmfile = module: "${srcdir}/${builtins.replaceStrings ["."] ["/"] module}.elm";
+ extension = if outputJavaScript then "js" else "html";
+ in ''
+ mkdir -p $out/share/doc
+ ${lib.concatStrings (map (module: ''
+ echo "compiling ${elmfile module}"
+ elm make ${elmfile module} --output $out/${module}.${extension}
+ '') targets)}
+ cp *.html $out
+ cp *.css $out
+ '';
+ };
+in mkDerivation {
+ name = "picarones";
+
+ srcs = ./elm-srcs.nix;
+ src = ./.;
+ targets = ["Main"];
+ srcdir = "./src";
+ outputJavaScript = true;
+}
+
diff --git a/elm-srcs.nix b/elm-srcs.nix
new file mode 100644
index 0000000..becbc8c
--- /dev/null
+++ b/elm-srcs.nix
@@ -0,0 +1,37 @@
+{
+
+ "elm/json" = {
+ sha256 = "0kjwrz195z84kwywaxhhlnpl3p251qlbm5iz6byd6jky2crmyqyh";
+ version = "1.1.3";
+ };
+
+ "elm/html" = {
+ sha256 = "1n3gpzmpqqdsldys4ipgyl1zacn0kbpc3g4v3hdpiyfjlgh8bf3k";
+ version = "1.0.0";
+ };
+
+ "elm/browser" = {
+ sha256 = "0nagb9ajacxbbg985r4k9h0jadqpp0gp84nm94kcgbr5sf8i9x13";
+ version = "1.0.2";
+ };
+
+ "elm/core" = {
+ sha256 = "19w0iisdd66ywjayyga4kv2p1v9rxzqjaxhckp8ni6n8i0fb2dvf";
+ version = "1.0.5";
+ };
+
+ "elm/url" = {
+ sha256 = "0av8x5syid40sgpl5vd7pry2rq0q4pga28b4yykn9gd9v12rs3l4";
+ version = "1.0.0";
+ };
+
+ "elm/time" = {
+ sha256 = "0vch7i86vn0x8b850w1p69vplll1bnbkp8s383z7pinyg94cm2z1";
+ version = "1.0.0";
+ };
+
+ "elm/virtual-dom" = {
+ sha256 = "0q1v5gi4g336bzz1lgwpn5b1639lrn63d8y6k6pimcyismp2i1yg";
+ version = "1.0.2";
+ };
+}
diff --git a/index.html b/index.html
index 32c90e2..66fe158 100644
--- a/index.html
+++ b/index.html
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>Main</title>
- <script src="app.js"></script>
+ <script src="Main.js"></script>
<link rel="stylesheet" type="text/css" href="document.css" />
</head>
diff --git a/registry.dat b/registry.dat
new file mode 100644
index 0000000..53c3803
--- /dev/null
+++ b/registry.dat
Binary files differ