From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id SBqrGm83hWLl+QAAbAwnHQ (envelope-from ) for ; Wed, 18 May 2022 20:14:07 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id IIeTGm83hWIVHwEAauVa8A (envelope-from ) for ; Wed, 18 May 2022 20:14:07 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CA9E91A50D for ; Wed, 18 May 2022 20:14:06 +0200 (CEST) Received: from localhost ([::1]:36206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrOBR-0007qh-Mb for larch@yhetil.org; Wed, 18 May 2022 14:14:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrOAR-0007iE-9j for guix-patches@gnu.org; Wed, 18 May 2022 14:13:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39618) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nrOAQ-0005DE-TX for guix-patches@gnu.org; Wed, 18 May 2022 14:13:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nrOAQ-0006LJ-OK for guix-patches@gnu.org; Wed, 18 May 2022 14:13:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55030] [PATCH v2 01/34] gnu: elm-compiler: Update to 0.19.1. Resent-From: Philip McGrath Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 18 May 2022 18:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55030 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55030@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Philip McGrath Received: via spool by 55030-submit@debbugs.gnu.org id=B55030.165289754224151 (code B ref 55030); Wed, 18 May 2022 18:13:02 +0000 Received: (at 55030) by debbugs.gnu.org; 18 May 2022 18:12:22 +0000 Received: from localhost ([127.0.0.1]:33469 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nrO9e-0006HA-Cf for submit@debbugs.gnu.org; Wed, 18 May 2022 14:12:22 -0400 Received: from mail-vs1-f43.google.com ([209.85.217.43]:38428) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nrO9b-0006Gq-Rm for 55030@debbugs.gnu.org; Wed, 18 May 2022 14:12:12 -0400 Received: by mail-vs1-f43.google.com with SMTP id a12so903240vsp.5 for <55030@debbugs.gnu.org>; Wed, 18 May 2022 11:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philipmcgrath.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1DnHWxQ4L60DHlXhZD76navw/O+m2vUd+RzGv4NMZw8=; b=Rc8cIZcBXowYcY8dx0BuBQQSGwcZpgSUKzEHItvuWSr7t+/IECpZfWEv28HLIwDFs0 72WE44yuaJmEIZAxu2t99H1dsyGHoOIgdItMQ+tVDMlBxZfNf9v/+eP94Rq2tz0vN5GA G5dz4Dqm9zzlrKmzqUiVKjAr9Qon5wUsGnTdKaIs7b1sxBFNK8zgs7VwgjoSJeMbiK5S NRpimIqyJunPpdfXBPKcAnZVxUstii5Np23/lpCiksDCVagiLT+kwF170/TMub57R2JJ 6ek8Wr41rS8x66NO05Dj2OTexnLm6yxANq3Vs177Oo/nM1EpTPhW1wfOcgwrfbilW00w N/aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1DnHWxQ4L60DHlXhZD76navw/O+m2vUd+RzGv4NMZw8=; b=gcwwAcijEXRLMPjaH5HgCkb3X+Flwqc4KPNnHG2LU6Wg+XsJWvSrCrKZ3vOTug2FvY LthwCSfR7DBppo4aeMb/PCZa/PatUEq0EbRr8fSbDKKDlGkHHCoeC3JuDfDUcwsXGlqt wY22RjA3WN//s9dBeK+XJZRok3cQSiMc6QqNiVFMUbwCdrqp6YcvsgFiPeunmPbfUR2t H5qMa5zG9o64GLcCCDNNmdmhMdml0gQtYFlSmd5kcl1kX4Uw0lZBMoGVTKeNa1e76Vxa nNr04U0/c+lUS5O0cQZLsxinM1HG5Y3DzJHo66sfQ5Y6i/WvNkIiWZiXyqfL50xOwTwd mvFw== X-Gm-Message-State: AOAM53155CLgDsNxLkpe1Isv8KpIN0Q/EbR9hvKzFKefnOaJp0u7zdDu xvdjLRLGdKiQtd7Klywq9CVupc11fwhVcymg X-Google-Smtp-Source: ABdhPJxNIFEgvEDE40UwAWtWL96/wBW0HqjpMyKXKMCAVmJUxu8zkpHHywVi6441ijVzCXH4ppFejA== X-Received: by 2002:a05:6102:f96:b0:333:c566:df27 with SMTP id e22-20020a0561020f9600b00333c566df27mr685346vsv.44.1652897526169; Wed, 18 May 2022 11:12:06 -0700 (PDT) Received: from localhost (c-73-125-98-51.hsd1.fl.comcast.net. [73.125.98.51]) by smtp.gmail.com with UTF8SMTPSA id j65-20020a1fa044000000b0034e98f6f2d8sm246038vke.55.2022.05.18.11.12.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 May 2022 11:12:05 -0700 (PDT) From: Philip McGrath Date: Wed, 18 May 2022 14:10:48 -0400 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: <20220419232736.272970-1-philip@philipmcgrath.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1652897647; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=1DnHWxQ4L60DHlXhZD76navw/O+m2vUd+RzGv4NMZw8=; b=JYlWr4rZBRy8nWdR8sT5FB/oFqufe6OMUJ8kyIR17E2NllBG+NyLn0sS9LbXpDUHHnJMEf +g/5aKxthPyF93iTBObnVl1imEf/nHNlCOjk9syHdVikpQr9UQHny8LvLJ/BKvibOk5o2O pfpqb6pO1sePJ7pEG+GmgNGQeqyBnivM6VcA6V5ATYSB7afeBM231xmWNYPrkF10/rtRON M5FAWvjAOlCp3npQd0Hc3x+Eg2bqbLVTkhAkMug973CoWg2RwnwrCyRUTllHSUuqZjOKbt KLUNtCppQmVPWV3vHcwIk4XrGfdzTQLhV5qcvZOIiuuG2jg9EHZHYGrgsHG/EA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1652897647; a=rsa-sha256; cv=none; b=j7oIJFgKhUjmf6jbVy6aHkZjstFyV7NYP+Qm2qi8KDESUFJaTshUqH1zXJXflV+zuCSeX/ OD1Neo+bRXd0GqDOmWhdTkM7U5x1n9fKRVUDEb0KZLvnNVLz86ReWC3Ay/m/JoijmdMwzx vQ0WIslBnvwqtiIaAKNfB7zJeNPTyPRmhJfM1+Uyzb67kjEk3brrwW1FNla/eZy6L9nJ57 KWXoId3IHQMAP9h7OV1SexUkwr5rXhtVOeVbwn6c4goDn/SaAg0iCm6CFqH99J539+pVI5 JXoLSrykZHtPXC9xpMcMopGPJFNU8JEYp4NzJf1LAPnWh+IFb1fy+MhP/5lqvw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=Rc8cIZcB; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 2.96 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=google header.b=Rc8cIZcB; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: CA9E91A50D X-Spam-Score: 2.96 X-Migadu-Scanner: scn0.migadu.com X-TUID: uQl2l07kndYL * gnu/packages/patches/elm-compiler-disable-reactor.patch, gnu/packages/patches/elm-compiler-fix-map-key.patch: Delete files. * gnu/packages/patches/elm-reactor-static-files.patch: New file. * gnu/local.mk (dist_patch_DATA): Update accordingly. * gnu/packages/elm.scm (elm-compiler): Update to 0.19.1. [origin]: Remove stale patches. Add new patch. [arguments]: Use G-expressions. Add #:configure-flags for new patch. [inputs]: Remove ghc-file-embed. Add ghc-filelock. --- gnu/local.mk | 3 +- gnu/packages/elm.scm | 44 +-- .../elm-compiler-disable-reactor.patch | 71 ----- .../patches/elm-compiler-fix-map-key.patch | 38 --- .../patches/elm-reactor-static-files.patch | 251 ++++++++++++++++++ 5 files changed, 280 insertions(+), 127 deletions(-) delete mode 100644 gnu/packages/patches/elm-compiler-disable-reactor.patch delete mode 100644 gnu/packages/patches/elm-compiler-fix-map-key.patch create mode 100644 gnu/packages/patches/elm-reactor-static-files.patch diff --git a/gnu/local.mk b/gnu/local.mk index 79019e8564..de044bdbff 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1024,8 +1024,7 @@ dist_patch_DATA = \ %D%/packages/patches/einstein-build.patch \ %D%/packages/patches/elfutils-tests-ptrace.patch \ %D%/packages/patches/elixir-path-length.patch \ - %D%/packages/patches/elm-compiler-disable-reactor.patch \ - %D%/packages/patches/elm-compiler-fix-map-key.patch \ + %D%/packages/patches/elm-reactor-static-files.patch \ %D%/packages/patches/elogind-revert-polkit-detection.patch \ %D%/packages/patches/emacs-exec-path.patch \ %D%/packages/patches/emacs-git-email-missing-parens.patch \ diff --git a/gnu/packages/elm.scm b/gnu/packages/elm.scm index ca7c61041b..988cc02de1 100644 --- a/gnu/packages/elm.scm +++ b/gnu/packages/elm.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Robert Vollmert +;;; Copyright © 2022 Philip McGrath ;;; ;;; This file is part of GNU Guix. ;;; @@ -24,18 +25,24 @@ (define-module (gnu packages elm) #:use-module (gnu packages haskell-xyz) #:use-module (gnu packages haskell-web) #:use-module (guix build-system haskell) + #:use-module (guix gexp) #:use-module (guix git-download) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages)) -;; The full elm build calls out to itself via Template Haskell to -;; compile the elm reactor web app. elm reactor isn't required to -;; compile elm applications, so we take this part out of this -;; bootstrap package. +;; The `elm` build usually calls out to itself via Template Haskell to compile +;; the `elm reactor` web app (which depends on additional Elm packages) and +;; embeds the static files into itself. The reactor isn't required to compile +;; Elm applications, so we want to skip it for the bootstrap package, but we +;; also want to be able to enable it once we can build it. We patch Elm to +;; instead look for the files on disk relative to the executable and to have +;; `elm reactor` exit with a useful error message if they aren't there. +(define %reactor-root-base + "share/elm/reactor-") (define-public elm-compiler (package (name "elm-compiler") - (version "0.19.0") + (version "0.19.1") (source (origin (method git-fetch) @@ -44,24 +51,29 @@ (define-public elm-compiler (url "https://github.com/elm/compiler/") (commit version))) (sha256 - (base32 "0s93z9vr0vp5w894ghc5s34nsq09sg1msf59zfiba87sid5vgjqy")) + (base32 "1rdg3xp3js9xadclk3cdypkscm5wahgsfmm4ldcw3xswzhw6ri8w")) (patches - (search-patches "elm-compiler-disable-reactor.patch" - "elm-compiler-fix-map-key.patch")))) + (search-patches "elm-reactor-static-files.patch")))) (build-system haskell-build-system) (arguments - `(#:phases - (modify-phases %standard-phases - (add-before 'configure 'update-constraints - (lambda _ - (substitute* "elm.cabal" - (("(ansi-terminal|containers|network|http-client|language-glsl)\\s+[^,]+" all dep) - dep))))))) + (list + #:configure-flags + #~(list (string-append "--ghc-option=-DGUIX_REACTOR_STATIC_REL_ROOT=" + "\"../" #$%reactor-root-base + #$(package-version this-package) + "\"")) + #:phases + #~(modify-phases %standard-phases + (add-before 'configure 'update-constraints + (lambda _ + (substitute* "elm.cabal" + (("(ansi-terminal|containers|network|http-client|language-glsl)\\s+[^,]+" all dep) + dep))))))) (inputs (list ghc-ansi-terminal ghc-ansi-wl-pprint ghc-edit-distance - ghc-file-embed + ghc-filelock ghc-http ghc-http-client ghc-http-client-tls diff --git a/gnu/packages/patches/elm-compiler-disable-reactor.patch b/gnu/packages/patches/elm-compiler-disable-reactor.patch deleted file mode 100644 index 9871b55e8d..0000000000 --- a/gnu/packages/patches/elm-compiler-disable-reactor.patch +++ /dev/null @@ -1,71 +0,0 @@ -commit 20d80e2323b565a36751c9455e535d8f73fa32f7 -Author: Robert Vollmert -Date: Fri Jun 14 16:05:47 2019 +0200 - - disable reactor - -diff --git a/elm.cabal b/elm.cabal -index c75f9689..ece63c46 100644 ---- a/elm.cabal -+++ b/elm.cabal -@@ -45,9 +45,6 @@ Executable elm - builder/src - ui/terminal/src - -- other-extensions: -- TemplateHaskell -- - Main-Is: - Main.hs - -@@ -56,8 +53,6 @@ Executable elm - Develop - Develop.Generate.Help - Develop.Generate.Index -- Develop.StaticFiles -- Develop.StaticFiles.Build - Diff - Init - Install -diff --git a/ui/terminal/src/Develop.hs b/ui/terminal/src/Develop.hs -index 4b2252e1..7ed7716e 100644 ---- a/ui/terminal/src/Develop.hs -+++ b/ui/terminal/src/Develop.hs -@@ -23,7 +23,6 @@ import Snap.Util.FileServe - import qualified Elm.Project as Project - import qualified Develop.Generate.Help as Generate - import qualified Develop.Generate.Index as Index --import qualified Develop.StaticFiles as StaticFiles - import qualified Generate.Output as Output - import qualified Json.Encode as Encode - import qualified Reporting.Exit as Exit -@@ -219,16 +218,7 @@ compileToHtmlBuilder mode file = - - - serveAssets :: Snap () --serveAssets = -- do file <- getSafePath -- case StaticFiles.lookup file of -- Nothing -> -- pass -- -- Just (content, mimeType) -> -- do modifyResponse (setContentType (mimeType <> ";charset=utf-8")) -- writeBS content -- -+serveAssets = pass - - - -- MIME TYPES -diff --git a/ui/terminal/src/Main.hs b/terminal/src/Main.hs -index 7000f3ca..2c76965a 100644 ---- a/ui/terminal/src/Main.hs -+++ b/ui/terminal/src/Main.hs -@@ -39,7 +39,6 @@ main = - complex intro outro - [ repl - , init -- , reactor - , make - , install - , bump diff --git a/gnu/packages/patches/elm-compiler-fix-map-key.patch b/gnu/packages/patches/elm-compiler-fix-map-key.patch deleted file mode 100644 index 4f05ded530..0000000000 --- a/gnu/packages/patches/elm-compiler-fix-map-key.patch +++ /dev/null @@ -1,38 +0,0 @@ -commit e3512d887df41a8162c3e361171c04beca08415b -Author: Tom Stejskal -Date: Mon Nov 19 20:09:43 2018 +0100 - - Fix Map.!: given key is not an element in the map - -diff --git a/compiler/src/Elm/Compiler/Type/Extract.hs b/compiler/src/Elm/Compiler/Type/Extract.hs -index 1aafe1d4..99763392 100644 ---- a/compiler/src/Elm/Compiler/Type/Extract.hs -+++ b/compiler/src/Elm/Compiler/Type/Extract.hs -@@ -10,6 +10,7 @@ module Elm.Compiler.Type.Extract - - - import Data.Map ((!)) -+import qualified Data.Map as Map - import qualified Data.Maybe as Maybe - import qualified Data.Set as Set - -@@ -134,11 +135,15 @@ extractUnion interfaces (Opt.Global home name) = - else - let - pname = toPublicName home name -- unions = I._unions (interfaces ! home) -+ maybeUnions = I._unions <$> Map.lookup home interfaces - in -- case I.toUnionInternals (unions ! name) of -- Can.Union vars ctors _ _ -> -- T.Union pname vars <$> traverse extractCtor ctors -+ case Map.lookup name =<< maybeUnions of -+ Just union -> -+ case I.toUnionInternals union of -+ Can.Union vars ctors _ _ -> -+ T.Union pname vars <$> traverse extractCtor ctors -+ Nothing -> -+ return $ T.Union pname [] [] - - - extractCtor :: Can.Ctor -> Extractor (N.Name, [T.Type]) diff --git a/gnu/packages/patches/elm-reactor-static-files.patch b/gnu/packages/patches/elm-reactor-static-files.patch new file mode 100644 index 0000000000..94c4aa0cd1 --- /dev/null +++ b/gnu/packages/patches/elm-reactor-static-files.patch @@ -0,0 +1,251 @@ +From 41d219a29b03f3114af7a0521c8b2dbbb487c3e1 Mon Sep 17 00:00:00 2001 +From: Philip McGrath +Date: Wed, 13 Apr 2022 18:45:58 -0400 +Subject: [PATCH] reactor: look for static files relative to executable + +Must built with `-DGUIX_REACTOR_STATIC_REL_ROOT="../path/to/reactor"`. + +This lets us build a version of Elm without the `elm reactor` for +bootstrapping, then simply put the files in place in the final package. +--- + elm.cabal | 2 +- + terminal/src/Develop.hs | 32 +++++++++++---- + terminal/src/Develop/StaticFiles.hs | 37 ++++++++++------- + terminal/src/Develop/StaticFiles/Build.hs | 50 ++++++++++++++--------- + 4 files changed, 79 insertions(+), 42 deletions(-) + +diff --git a/elm.cabal b/elm.cabal +index bf1cfcf0..93161072 100644 +--- a/elm.cabal ++++ b/elm.cabal +@@ -50,6 +50,7 @@ Executable elm + + other-extensions: + TemplateHaskell ++ CPP + + Main-Is: + Main.hs +@@ -211,7 +212,6 @@ Executable elm + containers >= 0.5.8.2 && < 0.6, + directory >= 1.2.3.0 && < 2.0, + edit-distance >= 0.2 && < 0.3, +- file-embed, + filelock, + filepath >= 1 && < 2.0, + ghc-prim >= 0.5.2, +diff --git a/terminal/src/Develop.hs b/terminal/src/Develop.hs +index 00339364..6855b03e 100644 +--- a/terminal/src/Develop.hs ++++ b/terminal/src/Develop.hs +@@ -33,6 +33,7 @@ import qualified Reporting.Exit as Exit + import qualified Reporting.Task as Task + import qualified Stuff + ++import System.Exit as SysExit + + + -- RUN THE DEV SERVER +@@ -45,13 +46,29 @@ data Flags = + + + run :: () -> Flags -> IO () +-run () (Flags maybePort) = ++run () flags = do ++ frontEnd <- StaticFiles.prepare ++ case frontEnd of ++ Right lookup -> ++ reallyRun lookup flags ++ Left missing -> ++ SysExit.die $ unlines ++ [ "The `reactor` command is not available." ++ , "" ++ , "On Guix, these files are needed for `elm reactor` to work," ++ , "but they are missing:" ++ , "" ++ , unlines (map (\pth -> " " ++ (show pth)) missing) ++ ] ++ ++reallyRun :: StaticFiles.Lookup -> Flags -> IO () ++reallyRun lookup (Flags maybePort) = + do let port = maybe 8000 id maybePort + putStrLn $ "Go to http://localhost:" ++ show port ++ " to see your project dashboard." + httpServe (config port) $ + serveFiles + <|> serveDirectoryWith directoryConfig "." +- <|> serveAssets ++ <|> serveAssets lookup + <|> error404 + + +@@ -169,16 +186,15 @@ compile path = + -- SERVE STATIC ASSETS + + +-serveAssets :: Snap () +-serveAssets = ++serveAssets :: StaticFiles.Lookup -> Snap () ++serveAssets lookup = + do path <- getSafePath +- case StaticFiles.lookup path of ++ case lookup path of + Nothing -> + pass + +- Just (content, mimeType) -> +- do modifyResponse (setContentType (mimeType <> ";charset=utf-8")) +- writeBS content ++ Just (fsPath, mimeType) -> ++ serveFileAs (mimeType <> ";charset=utf-8") fsPath + + + +diff --git a/terminal/src/Develop/StaticFiles.hs b/terminal/src/Develop/StaticFiles.hs +index 94ee72dc..3227d617 100644 +--- a/terminal/src/Develop/StaticFiles.hs ++++ b/terminal/src/Develop/StaticFiles.hs +@@ -2,7 +2,8 @@ + {-# LANGUAGE OverloadedStrings #-} + {-# LANGUAGE TemplateHaskell #-} + module Develop.StaticFiles +- ( lookup ++ ( prepare ++ , Lookup + , cssPath + , elmPath + , waitingPath +@@ -11,9 +12,7 @@ module Develop.StaticFiles + + import Prelude hiding (lookup) + import qualified Data.ByteString as BS +-import Data.FileEmbed (bsToExp) + import qualified Data.HashMap.Strict as HM +-import Language.Haskell.TH (runIO) + import System.FilePath (()) + + import qualified Develop.StaticFiles.Build as Build +@@ -26,20 +25,29 @@ import qualified Develop.StaticFiles.Build as Build + type MimeType = + BS.ByteString + ++type Lookup = FilePath -> Maybe (FilePath, MimeType) + +-lookup :: FilePath -> Maybe (BS.ByteString, MimeType) +-lookup path = ++prepare :: IO (Either [FilePath] Lookup) ++prepare = do ++ found <- Build.findReactorFrontEnd expectedFiles ++ return $ case found of ++ Left missing -> ++ Left missing ++ Right resolved -> ++ Right (mkLookup (HM.fromList resolved)) ++ ++mkLookup :: HM.HashMap FilePath (FilePath, MimeType) -> Lookup ++mkLookup dict path = + HM.lookup path dict + + +-dict :: HM.HashMap FilePath (BS.ByteString, MimeType) +-dict = +- HM.fromList +- [ faviconPath ==> (favicon , "image/x-icon") +- , elmPath ==> (elm , "application/javascript") +- , cssPath ==> (css , "text/css") +- , codeFontPath ==> (codeFont, "font/ttf") +- , sansFontPath ==> (sansFont, "font/ttf") ++expectedFiles :: [(FilePath, MimeType)] ++expectedFiles = ++ [ faviconPath ==> "image/x-icon" ++ , elmPath ==> "application/javascript" ++ , cssPath ==> "text/css" ++ , codeFontPath ==> "font/ttf" ++ , sansFontPath ==> "font/ttf" + ] + + +@@ -82,7 +90,7 @@ sansFontPath = + "_elm" "source-sans-pro.ttf" + + +- ++{- + -- ELM + + +@@ -121,3 +129,4 @@ sansFont = + favicon :: BS.ByteString + favicon = + $(bsToExp =<< runIO (Build.readAsset "favicon.ico")) ++-} +diff --git a/terminal/src/Develop/StaticFiles/Build.hs b/terminal/src/Develop/StaticFiles/Build.hs +index c61fae57..c39b08b0 100644 +--- a/terminal/src/Develop/StaticFiles/Build.hs ++++ b/terminal/src/Develop/StaticFiles/Build.hs +@@ -1,28 +1,39 @@ + {-# LANGUAGE OverloadedStrings #-} ++{-# LANGUAGE CPP #-} + module Develop.StaticFiles.Build +- ( readAsset +- , buildReactorFrontEnd ++ ( findReactorFrontEnd + ) + where + +- +-import qualified Data.ByteString as BS +-import qualified Data.ByteString.Builder as B +-import qualified Data.ByteString.Lazy as LBS +-import qualified Data.NonEmptyList as NE + import qualified System.Directory as Dir +-import System.FilePath (()) +- +-import qualified BackgroundWriter as BW +-import qualified Build +-import qualified Elm.Details as Details +-import qualified Generate +-import qualified Reporting +-import qualified Reporting.Exit as Exit +-import qualified Reporting.Task as Task +- +- +- ++import System.FilePath ((), takeDirectory) ++import System.Environment (getExecutablePath) ++import Data.Either as Either ++ ++reactorStaticRelRoot :: FilePath ++reactorStaticRelRoot = GUIX_REACTOR_STATIC_REL_ROOT ++ ++type Resolved a = (FilePath, (FilePath, a)) ++ ++findReactorFrontEnd :: [(FilePath, a)] -> IO (Either [FilePath] [Resolved a]) ++findReactorFrontEnd specs = do ++ exe <- getExecutablePath ++ let dir = takeDirectory exe reactorStaticRelRoot ++ dirExists <- Dir.doesDirectoryExist dir ++ files <- sequence (map (findFile dir) specs) ++ return $ case Either.lefts files of ++ [] -> ++ Right (Either.rights files) ++ missing -> ++ Left $ if dirExists then missing else [dir] ++ ++findFile :: FilePath -> (FilePath, a) -> IO (Either FilePath (Resolved a)) ++findFile dir (rel, rhs) = do ++ let abs = dir rel ++ exists <- Dir.doesFileExist abs ++ return $ if not exists then Left abs else Right (rel, (abs, rhs)) ++ ++{- + -- ASSETS + + +@@ -71,3 +82,4 @@ runTaskUnsafe task = + \\nCompile with `elm make` directly to figure it out faster\ + \\n--------------------------------------------------------\ + \\n" ++-} +-- +2.32.0 + -- 2.32.0