From 6b9eae2fa38038111802122625b4ef1e5eaaa1a2 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Sun, 13 Dec 2020 13:33:49 +0000 Subject: [PATCH] Productionize habit-screens At some point I should document or write a script for how I package Elm projects with Nix to be deployed on my website. For now, I'm modeling everything after my previous success LearnPianoChords. --- website/default.nix | 2 +- website/habit-screens/default.nix | 30 +++++++++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/website/default.nix b/website/default.nix index 4fd85f260..514b60cec 100644 --- a/website/default.nix +++ b/website/default.nix @@ -8,6 +8,6 @@ pkgs.stdenv.mkDerivation { cp $src/index.html $out mkdir -p $out/habits - cp ${briefcase.website.habits} $out/habits/index.html + cp ${briefcase.website.habit-screens} $out/habits/index.html ''; } diff --git a/website/habit-screens/default.nix b/website/habit-screens/default.nix index 19fd1b37c..c042dc8c8 100644 --- a/website/habit-screens/default.nix +++ b/website/habit-screens/default.nix @@ -1,8 +1,6 @@ -{ nixpkgs ? -, config ? {} -}: +{ pkgs ? , ... }: -with (import nixpkgs config); +with pkgs; let mkDerivation = @@ -42,12 +40,22 @@ let '') targets)} ''; }; -in mkDerivation { - name = "elm-app-0.1.0"; - srcs = ./elm-srcs.nix; - src = ./.; - targets = ["Main"]; - srcdir = "./src"; - outputJavaScript = false; + mainDotElm = mkDerivation { + name = "elm-app-0.1.0"; + srcs = ./elm-srcs.nix; + src = ./.; + targets = ["Main"]; + srcdir = "./src"; + outputJavaScript = true; + }; +in stdenv.mkDerivation { + name = "habit-screens"; + buildInputs = []; + src = builtins.path { path = ./.; name = "habit-screens"; }; + buildPhase = '' + mkdir -p $out + cp index.html output.css ${mainDotElm}/Main.min.js $out + ''; + dontInstall = true; }