about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-08-17 01:31:29 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-08-17 01:31:29 +0200
commitdd8f119332149a4e3b02dfce79f221f585ca73e1 (patch)
tree6111a5dbe3d5a6622293503bd206c286d9ca57d9
parentAdd gitignore (diff)
downloadisspass-dd8f119332149a4e3b02dfce79f221f585ca73e1.tar.gz
isspass-dd8f119332149a4e3b02dfce79f221f585ca73e1.tar.bz2
isspass-dd8f119332149a4e3b02dfce79f221f585ca73e1.zip
Setup nix declarative elm project
-rw-r--r--elm-project-derivation.nix53
-rw-r--r--elm-srcs.nix37
-rw-r--r--elm.json24
-rw-r--r--registry.datbin0 -> 122217 bytes
-rw-r--r--shell.nix4
-rw-r--r--src/Main.elm7
6 files changed, 125 insertions, 0 deletions
diff --git a/elm-project-derivation.nix b/elm-project-derivation.nix
new file mode 100644
index 0000000..15fce40
--- /dev/null
+++ b/elm-project-derivation.nix
@@ -0,0 +1,53 @@
+{ nixpkgs ? <nixpkgs>
+, config ? {}
+}:
+
+with (import nixpkgs config);
+
+let
+  mkDerivation =
+    { srcs ? ./elm-srcs.nix
+    , src
+    , name
+    , srcdir ? "./src"
+    , targets ? []
+    , registryDat ? ./registry.dat
+    , outputJavaScript ? false
+    }:
+    stdenv.mkDerivation {
+      inherit name src;
+
+      buildInputs = [ elmPackages.elm ]
+        ++ lib.optional outputJavaScript nodePackages.uglify-js;
+
+      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} --docs $out/share/doc/${module}.json
+          ${lib.optionalString outputJavaScript ''
+            echo "minifying ${elmfile module}"
+            uglifyjs $out/${module}.${extension} --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters,keep_fargs=false,unsafe_comps,unsafe' \
+                | uglifyjs --mangle --output $out/${module}.min.${extension}
+          ''}
+        '') targets)}
+      '';
+    };
+in mkDerivation {
+  name = "elm-app-0.1.0";
+  srcs = ./elm-srcs.nix;
+  src = ./.;
+  targets = ["Main"];
+  srcdir = "./src";
+  outputJavaScript = false;
+}
+
diff --git a/elm-srcs.nix b/elm-srcs.nix
new file mode 100644
index 0000000..0d2319b
--- /dev/null
+++ b/elm-srcs.nix
@@ -0,0 +1,37 @@
+{
+
+      "elm/browser" = {
+        sha256 = "0nagb9ajacxbbg985r4k9h0jadqpp0gp84nm94kcgbr5sf8i9x13";
+        version = "1.0.2";
+      };
+
+      "elm/core" = {
+        sha256 = "19w0iisdd66ywjayyga4kv2p1v9rxzqjaxhckp8ni6n8i0fb2dvf";
+        version = "1.0.5";
+      };
+
+      "elm/html" = {
+        sha256 = "1n3gpzmpqqdsldys4ipgyl1zacn0kbpc3g4v3hdpiyfjlgh8bf3k";
+        version = "1.0.0";
+      };
+
+      "elm/json" = {
+        sha256 = "0kjwrz195z84kwywaxhhlnpl3p251qlbm5iz6byd6jky2crmyqyh";
+        version = "1.1.3";
+      };
+
+      "elm/time" = {
+        sha256 = "0vch7i86vn0x8b850w1p69vplll1bnbkp8s383z7pinyg94cm2z1";
+        version = "1.0.0";
+      };
+
+      "elm/url" = {
+        sha256 = "0av8x5syid40sgpl5vd7pry2rq0q4pga28b4yykn9gd9v12rs3l4";
+        version = "1.0.0";
+      };
+
+      "elm/virtual-dom" = {
+        sha256 = "1yvb8px2z62xd578ag2q0r5hd1vkz9y7dfkx05355iiy1d7jwq4v";
+        version = "1.0.3";
+      };
+}
diff --git a/elm.json b/elm.json
new file mode 100644
index 0000000..ce2a08d
--- /dev/null
+++ b/elm.json
@@ -0,0 +1,24 @@
+{
+    "type": "application",
+    "source-directories": [
+        "src"
+    ],
+    "elm-version": "0.19.1",
+    "dependencies": {
+        "direct": {
+            "elm/browser": "1.0.2",
+            "elm/core": "1.0.5",
+            "elm/html": "1.0.0"
+        },
+        "indirect": {
+            "elm/json": "1.1.3",
+            "elm/time": "1.0.0",
+            "elm/url": "1.0.0",
+            "elm/virtual-dom": "1.0.3"
+        }
+    },
+    "test-dependencies": {
+        "direct": {},
+        "indirect": {}
+    }
+}
diff --git a/registry.dat b/registry.dat
new file mode 100644
index 0000000..acfd118
--- /dev/null
+++ b/registry.dat
Binary files differdiff --git a/shell.nix b/shell.nix
index 9518e69..ea1c5bb 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,7 +1,11 @@
 { pkgs ? import <nixpkgs> { } }:
+let
+  elmProject = pkgs.callPackage ./elm-project-derivation.nix { };
+in
 pkgs.mkShell {
   nativeBuildInputs = with pkgs; [
     elmPackages.elm
     elm2nix
+    elmProject
   ];
 }
diff --git a/src/Main.elm b/src/Main.elm
new file mode 100644
index 0000000..f493a54
--- /dev/null
+++ b/src/Main.elm
@@ -0,0 +1,7 @@
+module Main exposing (..)
+
+import Html exposing (text)
+
+-- create main method
+main = 
+        text "Hello Elm from TutorialsPoint"