Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to use spago bundle-app in nix derivation since 0.20.8 #888

Closed
yuanwang-wf opened this issue May 22, 2022 · 14 comments
Closed

unable to use spago bundle-app in nix derivation since 0.20.8 #888

yuanwang-wf opened this issue May 22, 2022 · 14 comments
Labels

Comments

@yuanwang-wf
Copy link

before spago 0.20.8. One can bundle a purescript app using spago2nix and spago in a nix derivation

in stdenv.mkDerivation rec {
  pname = "my-frontend";
  src = lib.cleanSource ./.;
  version = "0.1";

  buildInputs = [
    spagoPkgs.installSpagoStyle
    spagoPkgs.buildSpagoStyle
    spagoPkgs.buildFromNixStore
    purescript
    spago
  ];

  unpackPhase = ''
    cp $src/{packages,spago}.dhall .
    cp -r $src/src .
    install-spago-style
  '';

  buildPhase = ''
    build-spago-style ./src/*.purs
    ${pkgs.spago}/bin/spago bundle-app --no-install --main Main --no-build --global-cache skip
  '';

  installPhase = ''
    install -D -m644 ./index.js $out/srv/hu-frontend.js
  '';
}

Referece
https://discourse.purescript.org/t/spago2nix-any-complete-example-to-look-at/2532/4

But with spago 0.20.8 or later. It seems build and bundle-app is kicking out a process which doesn't work in a nix (flake) derivation

       last 10 log lines:
       > Warning: Could not get or create the default cache directory:
       >
       > ↳ /homeless-shelter/.cache/dhall
       >
       > You can enable caching by creating it if needed and setting read,
       > write and search permissions on it or providing another cache base
       > directory by setting the $XDG_CACHE_HOME environment variable.
       >
       >
       > spago: security: createProcess: posix_spawnp: permission denied (Read-only file system)
       For full logs, run 'nix log /nix/store/za33rjxhv56rpp7lpa9mjr1d4i7zc8mk-frontendJs.drv'.

I wonder is possible to get bundle-app work in a derivation ?

one workaround is using esbuild directly

  frontendJs = pkgs.stdenv.mkDerivation {
    name = "frontendJs";
    buildInputs = [ spagoPkgs.installSpagoStyle spagoPkgs.buildSpagoStyle ];
    nativeBuildInputs = with pkgs; [ purs spago esbuild ];
    src = ./.;
    unpackPhase = ''
      cp $src/spago.dhall .
      cp $src/packages.dhall .
      cp -r $src/src .
      install-spago-style
    '';
    buildPhase = ''
      build-spago-style "./src/**/*.purs"
      esbuild --bundle ./output/Frontend/index.js --platform=browser --minify --outfile="frontend.js"
    '';
    installPhase = ''
      mkdir $out
      mv frontend.js $out/
    '';
  };

Referece:
https://github.com/yuanw/blog/blob/2f1b50df9c301b56fba300b0d24e97dc2a62634b/purescript/default.nix#L19

@f-f
Copy link
Member

f-f commented May 24, 2022

Thanks for reporting @yuanwang-wf! This is a bug, and I suspect it's due to us changing the way we invoke programs.
Could you provide a complete log of what happens when running Spago with -V? I.e. spago -V bundle-app. This will help point us in the right direction.

@f-f f-f added the bug label May 24, 2022
@yuanwang-wf
Copy link
Author

hey @f-f, thank you for looking into it. I am afraid the nix log from spago -V bundle-app is not very helpful

https://github.com/yuanw/blog/blob/master/purescript/default.nix#L20

@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
installing dependencies...
Installing .spago/arrays/v7.0.0.
Installing .spago/bifunctors/v6.0.0.
Installing .spago/console/v6.0.0.
Installing .spago/const/v6.0.0.
Installing .spago/contravariant/v6.0.0.
Installing .spago/control/v6.0.0.
Installing .spago/datetime/v6.0.0.
Installing .spago/distributive/v6.0.0.
Installing .spago/effect/v4.0.0.
Installing .spago/either/v6.0.0.
Installing .spago/enums/v6.0.0.
Installing .spago/exceptions/v6.0.0.
Installing .spago/exists/v6.0.0.
Installing .spago/foldable-traversable/v6.0.0.
Installing .spago/foreign/v7.0.0.
Installing .spago/functions/v6.0.0.
Installing .spago/functors/v5.0.0.
Installing .spago/gen/v4.0.0.
Installing .spago/identity/v6.0.0.
Installing .spago/integers/v6.0.0.
Installing .spago/invariant/v6.0.0.
Installing .spago/js-date/v8.0.0.
Installing .spago/lazy/v6.0.0.
Installing .spago/lists/v7.0.0.
Installing .spago/maybe/v6.0.0.
Installing .spago/media-types/v6.0.0.
Installing .spago/newtype/v5.0.0.
Installing .spago/nonempty/v7.0.0.
Installing .spago/now/v6.0.0.
Installing .spago/nullable/v6.0.0.
Installing .spago/numbers/v9.0.0.
Installing .spago/ordered-collections/v3.0.0.
Installing .spago/orders/v6.0.0.
Installing .spago/partial/v4.0.0.
Installing .spago/prelude/v6.0.0.
Installing .spago/profunctor/v6.0.0.
Installing .spago/psci-support/v6.0.0.
Installing .spago/refs/v6.0.0.
Installing .spago/safe-coerce/v2.0.0.
Installing .spago/st/v6.0.0.
Installing .spago/strings/v6.0.0.
Installing .spago/tailrec/v6.0.0.
Installing .spago/transformers/v6.0.0.
Installing .spago/tuples/v7.0.0.
Installing .spago/type-equality/v4.0.1.
Installing .spago/unfoldable/v6.0.0.
Installing .spago/unsafe-coerce/v6.0.0.
Installing .spago/web-dom/v6.0.0.
Installing .spago/web-events/v4.0.0.
Installing .spago/web-file/v4.0.0.
Installing .spago/web-html/v4.0.0.
Installing .spago/web-storage/v5.0.0.
echo done.
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
building project...
[  4 of 385] Compiling Type.Equality
[  1 of 385] Compiling Web.Event.Internal.Types
[  3 of 385] Compiling Unsafe.Coerce
[  2 of 385] Compiling Web.DOM.Internal.Types
[  5 of 385] Compiling Record.Unsafe
[  6 of 385] Compiling Type.Proxy
[  7 of 385] Compiling Data.String.Unsafe
[  8 of 385] Compiling Data.Traversable.Accum
[  9 of 385] Compiling Partial
[ 10 of 385] Compiling Data.Int.Bits
[ 11 of 385] Compiling Data.NaturalTransformation
[ 12 of 385] Compiling Data.Boolean
[ 13 of 385] Compiling Control.Semigroupoid
[ 14 of 385] Compiling Partial.Unsafe
[ 15 of 385] Compiling Data.Symbol
[ 16 of 385] Compiling Safe.Coerce
[ 17 of 385] Compiling Control.Category
[ 18 of 385] Compiling Data.Exists
[ 19 of 385] Compiling Data.Show
[ 20 of 385] Compiling Data.Void
[ 21 of 385] Compiling Data.Unit
[ 22 of 385] Compiling Data.Function.Uncurried
[ 23 of 385] Compiling Data.Semiring
[ 24 of 385] Compiling Control.Lazy
[ 25 of 385] Compiling Data.HeytingAlgebra
[ 26 of 385] Compiling Data.Semigroup
[ 27 of 385] Compiling Data.Generic.Rep
[ 28 of 385] Compiling Data.Ring
[ 29 of 385] Compiling Data.BooleanAlgebra
[ 30 of 385] Compiling Data.Eq
[ 31 of 385] Compiling Data.CommutativeRing
[ 32 of 385] Compiling Data.Ordering
[ 33 of 385] Compiling Data.EuclideanRing
[ 34 of 385] Compiling Data.Ord
[ 35 of 385] Compiling Data.DivisionRing
[ 36 of 385] Compiling Data.Field
[ 37 of 385] Compiling Data.Function
[ 39 of 385] Compiling Data.Bounded
[ 38 of 385] Compiling Data.Reflectable
[ 40 of 385] Compiling Data.Monoid
[ 41 of 385] Compiling Data.Functor
[ 42 of 385] Compiling Control.Alt
[ 44 of 385] Compiling Control.Extend
[ 43 of 385] Compiling Control.Apply
[ 45 of 385] Compiling Control.Plus
[ 46 of 385] Compiling Data.Monoid.Generic
[ 47 of 385] Compiling Data.Bounded.Generic
[ 48 of 385] Compiling Control.Comonad
[ 49 of 385] Compiling Control.Comonad.Trans.Class
[ 50 of 385] Compiling Control.Applicative
[ 51 of 385] Compiling Control.Bind
[ 52 of 385] Compiling Control.Alternative
[ 53 of 385] Compiling Control.Monad
[ 54 of 385] Compiling Prelude
[ 55 of 385] Compiling Control.MonadPlus
[ 56 of 385] Compiling Control.Monad.Reader.Class
[ 57 of 385] Compiling Data.Semiring.Generic
[ 58 of 385] Compiling Data.Monoid.Disj
[ 59 of 385] Compiling Data.Semigroup.First
[ 60 of 385] Compiling Data.Monoid.Dual
[ 61 of 385] Compiling Data.Eq.Generic
[ 62 of 385] Compiling Data.Ring.Generic
[ 63 of 385] Compiling Data.HeytingAlgebra.Generic
[ 64 of 385] Compiling Data.Semigroup.Last
[ 65 of 385] Compiling Data.Show.Generic
[ 66 of 385] Compiling Data.Number.Format
[ 67 of 385] Compiling Control.Monad.Gen.Class
[ 68 of 385] Compiling Data.Traversable.Accum.Internal
[ 69 of 385] Compiling Data.Monoid.Endo
[ 70 of 385] Compiling Data.Ord.Generic
[ 71 of 385] Compiling Control.Monad.Trans.Class
[ 72 of 385] Compiling Effect
[ 73 of 385] Compiling Data.Monoid.Additive
[ 74 of 385] Compiling Data.Semigroup.Generic
[ 75 of 385] Compiling Control.Monad.Cont.Class
[ 76 of 385] Compiling Data.Monoid.Conj
[ 77 of 385] Compiling Data.Monoid.Multiplicative
[ 78 of 385] Compiling Effect.Unsafe
[ 79 of 385] Compiling Effect.Ref
[ 81 of 385] Compiling Web.HTML.Location
[ 80 of 385] Compiling Web.HTML.Navigator
[ 82 of 385] Compiling Web.HTML.HTMLHyperlinkElementUtils
[ 83 of 385] Compiling Effect.Console
[ 84 of 385] Compiling Web.DOM.ChildNode
[ 85 of 385] Compiling Effect.Class
[ 86 of 385] Compiling Effect.Uncurried
[ 87 of 385] Compiling PSCI.Support
[ 88 of 385] Compiling Effect.Class.Console
[ 89 of 385] Compiling Data.Newtype
[ 90 of 385] Compiling Web.HTML.Common
[ 91 of 385] Compiling Data.Ord.Min
[ 92 of 385] Compiling Data.MediaType

[ 93 of 385] Compiling Data.Profunctor
[ 94 of 385] Compiling Data.Time.Duration
[ 95 of 385] Compiling Data.Functor.App
[ 96 of 385] Compiling Data.Monoid.Alternate
[ 97 of 385] Compiling Data.Ord.Down
[ 98 of 385] Compiling Data.String.Pattern
[ 99 of 385] Compiling Control.Comonad.Traced.Trans
[100 of 385] Compiling Data.Ord.Max
[101 of 385] Compiling Data.MediaType.Common
[102 of 385] Compiling Data.String.Common
[103 of 385] Compiling Data.Profunctor.Closed
[104 of 385] Compiling Data.Functor.Invariant
[105 of 385] Compiling Data.Functor.Compose
[106 of 385] Compiling Data.Identity
[107 of 385] Compiling Data.Const
[108 of 385] Compiling Data.Profunctor.Join
[109 of 385] Compiling Data.Maybe
[110 of 385] Compiling Data.Tuple
[111 of 385] Compiling Data.Profunctor.Split
[112 of 385] Compiling Web.HTML.ValidityState
[113 of 385] Compiling Data.Functor.Contravariant
[114 of 385] Compiling Data.Op
[115 of 385] Compiling Data.Predicate
[116 of 385] Compiling Data.Comparison
[117 of 385] Compiling Data.Equivalence
[118 of 385] Compiling Data.Either
[119 of 385] Compiling Web.HTML.HTMLMediaElement.CanPlayType
[120 of 385] Compiling Web.Internal.FFI
[121 of 385] Compiling Web.HTML.HTMLImageElement.DecodingHint
[122 of 385] Compiling Data.Maybe.Last
[123 of 385] Compiling Data.Maybe.First
[124 of 385] Compiling Web.HTML.SelectionMode
[125 of 385] Compiling Web.DOM.ShadowRoot
[126 of 385] Compiling Data.Number
[127 of 385] Compiling Web.HTML.HTMLImageElement.CORSMode
[128 of 385] Compiling Web.HTML.HTMLDocument.ReadyState
[129 of 385] Compiling Data.Nullable
[130 of 385] Compiling Web.HTML.HTMLImageElement.Laziness
[131 of 385] Compiling Data.String.CodeUnits
[132 of 385] Compiling Data.Number.Approximate
[133 of 385] Compiling Data.Int
[134 of 385] Compiling Web.DOM.DOMTokenList
[135 of 385] Compiling Web.DOM.NonDocumentTypeChildNode
[136 of 385] Compiling Web.DOM.NodeList
[137 of 385] Compiling Web.Storage.Storage
[138 of 385] Compiling Web.HTML.Event.DataTransfer.DataTransferItem
[139 of 385] Compiling Web.DOM.HTMLCollection
[140 of 385] Compiling Data.Divide
[141 of 385] Compiling Control.Comonad.Store.Trans
[142 of 385] Compiling Control.Monad.State.Class
[143 of 385] Compiling Web.DOM.ParentNode
[145 of 385] Compiling Control.Comonad.Traced.Class
[146 of 385] Compiling Data.Profunctor.Costrong
[144 of 385] Compiling Data.Tuple.Nested
[147 of 385] Compiling Control.Monad.Writer.Class
[148 of 385] Compiling Data.Profunctor.Strong
[149 of 385] Compiling Data.Distributive
[150 of 385] Compiling Control.Monad.Cont.Trans
[151 of 385] Compiling Web.File.Blob
[152 of 385] Compiling Control.Comonad.Traced
[153 of 385] Compiling Data.Divisible
[154 of 385] Compiling Web.File.Url
[155 of 385] Compiling Data.Decide
[157 of 385] Compiling Data.Bifunctor
[158 of 385] Compiling Effect.Exception
[159 of 385] Compiling Data.Profunctor.Cochoice
[160 of 385] Compiling Data.Either.Inject
[161 of 385] Compiling Data.Profunctor.Choice
[156 of 385] Compiling Data.Either.Nested
[162 of 385] Compiling Effect.Exception.Unsafe
[163 of 385] Compiling Control.Monad.Error.Class
[164 of 385] Compiling Data.Functor.Product
[165 of 385] Compiling Data.Functor.Coproduct
[166 of 385] Compiling Data.Functor.Costar
[167 of 385] Compiling Control.Biapply
[168 of 385] Compiling Data.Profunctor.Star
[169 of 385] Compiling Control.Monad.Rec.Class
[170 of 385] Compiling Data.Decidable
[171 of 385] Compiling Control.Monad.Cont
[172 of 385] Compiling Control.Biapplicative
[173 of 385] Compiling Data.Bifunctor.Join
[174 of 385] Compiling Data.Functor.Clown
[175 of 385] Compiling Data.Functor.Joker
[176 of 385] Compiling Data.Functor.Product2
[177 of 385] Compiling Data.Functor.Flip
[178 of 385] Compiling Data.Functor.Product.Nested
[179 of 385] Compiling Data.Functor.Coproduct.Nested
[180 of 385] Compiling Data.FunctorWithIndex
[181 of 385] Compiling Data.Foldable
[182 of 385] Compiling Control.Monad.RWS.Trans
[183 of 385] Compiling Control.Monad.State.Trans
[184 of 385] Compiling Control.Monad.Writer.Trans
[185 of 385] Compiling Data.Functor.Coproduct.Inject
[186 of 385] Compiling Control.Monad.Maybe.Trans
[187 of 385] Compiling Control.Monad.Reader.Trans
[188 of 385] Compiling Control.Monad.ST.Internal
[189 of 385] Compiling Control.Monad.Except.Trans
[190 of 385] Compiling Control.Monad.ST.Ref
[191 of 385] Compiling Control.Monad.ST
[192 of 385] Compiling Data.Array.ST
[193 of 385] Compiling Control.Monad.ST.Global
[194 of 385] Compiling Control.Monad.ST.Class
[195 of 385] Compiling Data.Array.ST.Iterator
[196 of 385] Compiling Data.Array.ST.Partial
[197 of 385] Compiling Control.Monad.Reader
[198 of 385] Compiling Control.Monad.Writer
[199 of 385] Compiling Control.Monad.Except
[200 of 385] Compiling Control.Monad.State
[201 of 385] Compiling Control.Monad.RWS
[202 of 385] Compiling Data.FoldableWithIndex
[203 of 385] Compiling Data.Traversable
[204 of 385] Compiling Data.Semigroup.Foldable
[205 of 385] Compiling Data.Bifoldable
[206 of 385] Compiling Data.Bitraversable
[207 of 385] Compiling Control.Monad.Identity.Trans
[208 of 385] Compiling Data.Semigroup.Traversable
[209 of 385] Compiling Data.Unfoldable1
[210 of 385] Compiling Data.TraversableWithIndex
[211 of 385] Compiling Data.Unfoldable
[212 of 385] Compiling Control.Monad.Gen
[213 of 385] Compiling Data.Enum
[214 of 385] Compiling Data.Time.Duration.Gen
[216 of 385] Compiling Data.Lazy
[215 of 385] Compiling Control.Comonad.Env.Trans
[217 of 385] Compiling Data.Array.NonEmpty.Internal
[218 of 385] Compiling Data.NonEmpty
[219 of 385] Compiling Data.Array
[220 of 385] Compiling Data.Char
[221 of 385] Compiling Web.HTML.HTMLMediaElement.ReadyState
[222 of 385] Compiling Data.Enum.Generic
[223 of 385] Compiling Data.Date.Component
[224 of 385] Compiling Web.Event.EventPhase
[226 of 385] Compiling Web.HTML.HTMLTrackElement.ReadyState
[225 of 385] Compiling Web.HTML.HTMLMediaElement.NetworkState
[227 of 385] Compiling Web.DOM.NodeType
[229 of 385] Compiling Data.Time.Component
[228 of 385] Compiling Web.File.FileReader.ReadyState
[231 of 385] Compiling Control.Comonad.Store.Class
[230 of 385] Compiling Control.Comonad.Env.Class
[232 of 385] Compiling Control.Monad.List.Trans
[233 of 385] Compiling Data.List.Types
[234 of 385] Compiling Data.List.Lazy.Types
[235 of 385] Compiling Data.Char.Gen
[236 of 385] Compiling Data.Enum.Gen
[237 of 385] Compiling Control.Monad.Gen.Common
[238 of 385] Compiling Control.Comonad.Env
[239 of 385] Compiling Control.Comonad.Store
[240 of 385] Compiling Data.String.Gen
[241 of 385] Compiling Data.Time.Component.Gen
[242 of 385] Compiling Data.Time
[243 of 385] Compiling Data.Date.Component.Gen
[244 of 385] Compiling Data.Date
[245 of 385] Compiling Data.Time.Gen
[248 of 385] Compiling Data.Array.Partial
[246 of 385] Compiling Data.String.CodePoints
[247 of 385] Compiling Data.Array.NonEmpty
[250 of 385] Compiling Data.Date.Gen
[249 of 385] Compiling Data.DateTime
[252 of 385] Compiling Data.DateTime.Gen
[251 of 385] Compiling Data.DateTime.Instant
[253 of 385] Compiling Data.List.Internal
[254 of 385] Compiling Web.Event.Event
[255 of 385] Compiling Web.File.File
[256 of 385] Compiling Effect.Now
[257 of 385] Compiling Web.File.FileList
[258 of 385] Compiling Web.HTML.Event.BeforeUnloadEvent
[259 of 385] Compiling Web.HTML.Event.DragEvent.EventTypes
[260 of 385] Compiling Web.HTML.Event.HashChangeEvent
[261 of 385] Compiling Web.Storage.Event.StorageEvent
[262 of 385] Compiling Web.HTML.Event.HashChangeEvent.EventTypes
[263 of 385] Compiling Web.HTML.Event.PageTransitionEvent
[264 of 385] Compiling Web.HTML.Event.PageTransitionEvent.EventTypes
[265 of 385] Compiling Web.Event.EventTarget
[266 of 385] Compiling Web.HTML.Event.EventTypes
[267 of 385] Compiling Web.HTML.Event.TrackEvent
[268 of 385] Compiling Web.HTML.Event.ErrorEvent
[269 of 385] Compiling Web.HTML.Event.BeforeUnloadEvent.EventTypes
[270 of 385] Compiling Web.HTML.Event.TrackEvent.EventTypes
[272 of 385] Compiling Data.String
[271 of 385] Compiling Web.HTML.Event.PopStateEvent.EventTypes
[273 of 385] Compiling Web.DOM.CharacterData
[274 of 385] Compiling Web.DOM.Element
[275 of 385] Compiling Data.String.Regex.Flags
[276 of 385] Compiling Web.DOM.DocumentType
[277 of 385] Compiling Data.String.NonEmpty.Internal
[278 of 385] Compiling Data.String.CaseInsensitive
[279 of 385] Compiling Web.DOM.Comment
[280 of 385] Compiling Web.DOM.ProcessingInstruction
[281 of 385] Compiling Web.DOM.Text
[282 of 385] Compiling Data.List
[283 of 385] Compiling Data.List.Lazy
[285 of 385] Compiling Web.DOM.NonElementParentNode
[284 of 385] Compiling Web.HTML.Event.DataTransfer
[286 of 385] Compiling Web.DOM.DocumentFragment
[287 of 385] Compiling Web.DOM.Document
[288 of 385] Compiling Web.HTML.Event.DragEvent
[289 of 385] Compiling Web.DOM.Node
[290 of 385] Compiling Data.String.Regex
[291 of 385] Compiling Data.String.NonEmpty.CodePoints
[292 of 385] Compiling Data.String.NonEmpty.CodeUnits
[293 of 385] Compiling Data.String.Regex.Unsafe
[295 of 385] Compiling Web.DOM
[294 of 385] Compiling Web.DOM.MutationRecord
[296 of 385] Compiling Web.HTML.HTMLElement
[297 of 385] Compiling Data.String.NonEmpty
[298 of 385] Compiling Web.DOM.MutationObserver
[299 of 385] Compiling Data.String.NonEmpty.CaseInsensitive
[300 of 385] Compiling Web.HTML.HTMLHeadingElement
[301 of 385] Compiling Web.HTML.HTMLDListElement
[302 of 385] Compiling Web.HTML.HTMLTableColElement
[303 of 385] Compiling Web.HTML.HTMLOptGroupElement
[304 of 385] Compiling Web.HTML.HTMLBRElement
[305 of 385] Compiling Web.HTML.HTMLBaseElement
[306 of 385] Compiling Web.HTML.HTMLSpanElement
[307 of 385] Compiling Web.HTML.HTMLLinkElement
[308 of 385] Compiling Web.HTML.HTMLMetaElement
[309 of 385] Compiling Web.HTML.HTMLPreElement
[310 of 385] Compiling Web.HTML.HTMLAreaElement
[311 of 385] Compiling Web.HTML.HTMLEmbedElement
[312 of 385] Compiling Web.HTML.HTMLMeterElement
[313 of 385] Compiling Web.HTML.HTMLAnchorElement
[314 of 385] Compiling Web.HTML.HTMLImageElement
[315 of 385] Compiling Web.HTML.HTMLScriptElement
[316 of 385] Compiling Web.HTML.HTMLDataListElement
[317 of 385] Compiling Web.HTML.HTMLHeadElement
[318 of 385] Compiling Web.HTML.HTMLLIElement
[319 of 385] Compiling Web.HTML.HTMLTitleElement
[320 of 385] Compiling Web.HTML.HTMLTableCellElement
[321 of 385] Compiling Web.HTML.HTMLBodyElement
[322 of 385] Compiling Web.HTML.HTMLUListElement
[323 of 385] Compiling Web.HTML.HTMLTableRowElement
[324 of 385] Compiling Web.HTML.HTMLStyleElement
[325 of 385] Compiling Web.HTML.HTMLProgressElement
[326 of 385] Compiling Web.HTML.HTMLQuoteElement
[327 of 385] Compiling Web.HTML.HTMLCanvasElement
[328 of 385] Compiling Web.HTML.HTMLDivElement
[329 of 385] Compiling Web.HTML.HTMLHtmlElement
[330 of 385] Compiling Web.HTML.HTMLParagraphElement
[331 of 385] Compiling Web.HTML.HTMLDataElement
[332 of 385] Compiling Web.HTML.HTMLTableCaptionElement
[333 of 385] Compiling Web.HTML.HTMLParamElement
[334 of 385] Compiling Web.HTML.HTMLFormElement
[336 of 385] Compiling Web.HTML.HTMLTemplateElement
[337 of 385] Compiling Web.HTML.HTMLModElement
[335 of 385] Compiling Web.HTML.HTMLHRElement
[338 of 385] Compiling Web.HTML.HTMLTableSectionElement
[339 of 385] Compiling Web.HTML.HTMLSourceElement
[340 of 385] Compiling Web.HTML.HTMLTrackElement
[342 of 385] Compiling Web.HTML.HTMLTimeElement
[341 of 385] Compiling Web.HTML.HTMLOListElement
[343 of 385] Compiling Web.HTML.HTMLMapElement
[344 of 385] Compiling Web.HTML.HTMLTableDataCellElement
[345 of 385] Compiling Web.HTML.HTMLTableHeaderCellElement
[346 of 385] Compiling Web.HTML.HTMLDocument
[347 of 385] Compiling Web.HTML.HTMLButtonElement
[348 of 385] Compiling Web.HTML.HTMLOptionElement
[349 of 385] Compiling Web.HTML.HTMLOutputElement
[350 of 385] Compiling Web.HTML.HTMLFieldSetElement
[351 of 385] Compiling Web.HTML.HTMLLegendElement
[352 of 385] Compiling Web.HTML.HTMLTextAreaElement
[353 of 385] Compiling Web.HTML.HTMLSelectElement
[354 of 385] Compiling Web.HTML.HTMLKeygenElement
[355 of 385] Compiling Web.HTML.HTMLTableElement
[356 of 385] Compiling Web.HTML.HTMLLabelElement
[357 of 385] Compiling Web.HTML.HTMLObjectElement
[358 of 385] Compiling Data.List.ZipList
[359 of 385] Compiling Data.List.Lazy.NonEmpty
[361 of 385] Compiling Data.List.Partial
[360 of 385] Compiling Data.Map.Internal
[362 of 385] Compiling Data.List.NonEmpty
[363 of 385] Compiling Foreign
[364 of 385] Compiling Web.File.FileReader
[365 of 385] Compiling Data.JSDate
[366 of 385] Compiling Foreign.Index
[367 of 385] Compiling Web.Event.CustomEvent
[368 of 385] Compiling Foreign.Keys
[369 of 385] Compiling Web.HTML.Event.PopStateEvent
[370 of 385] Compiling Web.HTML.History
[371 of 385] Compiling Web.HTML.Window
[372 of 385] Compiling Web.HTML.HTMLIFrameElement
[373 of 385] Compiling Web.HTML.HTMLInputElement
[374 of 385] Compiling Web.HTML.HTMLMediaElement
[376 of 385] Compiling Web.HTML.HTMLVideoElement
[375 of 385] Compiling Web.HTML.HTMLAudioElement
[377 of 385] Compiling Web.HTML
[378 of 385] Compiling Frontend
[379 of 385] Compiling Data.Set
[380 of 385] Compiling Data.Map
[381 of 385] Compiling Data.Set.NonEmpty
[383 of 385] Compiling Data.Interval.Duration
[382 of 385] Compiling Data.Map.Gen
[384 of 385] Compiling Data.Interval
[385 of 385] Compiling Data.Interval.Duration.Iso

Warning 1 of 2:

  in module Frontend
  at ./src/Frontend.purs:43:7 - 43:12 (line 43, column 7 - line 43, column 12)

    Name cList was introduced but not used.

  in value declaration updateClss

  See https://github.com/purescript/documentation/blob/master/errors/UnusedName.md for more informatio
n,
  or to contribute content related to this warning.

Warning 2 of 2:

  in module Frontend
  at ./src/Frontend.purs:13:1 - 13:57 (line 13, column 1 - line 13, column 57)

    The qualified import of Web.DOM.DOMTokenList as DOMTokenList is redundant


  See https://github.com/purescript/documentation/blob/master/errors/UnusedImport.md for more informat
ion,
  or to contribute content related to this warning.


done.
2022-05-24 19:34:20.597360: [debug] Transformed config is the same as the read one, not overwriting it
@(src/Spago/Prelude.hs:310:20)

Warning: Could not get or create the default cache directory:

↳ /homeless-shelter/.cache/dhall

You can enable caching by creating it if needed and setting read,
write and search permissions on it or providing another cache base
directory by setting the $XDG_CACHE_HOME environment variable.


spago: security: createProcess: posix_spawnp: permission denied (Read-only file system)

let me know if there any additional information i can provide

@paulyoung
Copy link

I found this issue after filing justinwoo/spago2nix#52. Not sure if they're related.

@yuanwang-wf you can get past that error by setting HOME=$TMP before invoking spago.

@paulyoung
Copy link

@yuanwang-wf sorry, I misread, setting HOME will only help with:

Warning: Could not get or create the default cache directory:

↳ /homeless-shelter/.cache/dhall

@paulyoung
Copy link

Could there be a regression with the --no-install and/or --no-build flags?

In justinwoo/spago2nix#52 I'm trying to run spago test --no-install was encountering the error that passing those flags is supposed to prevent (according to the spago2nix README)

After upgrading to 0.20.9 I get the same posix_spawnp error.

@yuanwang-wf
Copy link
Author

yuanwang-wf commented Jun 22, 2022

i guess this correct workaround is

 frontendJs = pkgs.stdenv.mkDerivation {
    name = "frontendJs";
    buildInputs = [ spagoPkgs.installSpagoStyle spagoPkgs.buildSpagoStyle ];
    nativeBuildInputs = with pkgs; [ purs spago esbuild ];
    src = ./.;
    unpackPhase = ''
      cp $src/spago.dhall .
      cp $src/packages.dhall .
      cp -r $src/src .
      install-spago-style
    '';
    # https://github.com/purescript/spago/blob/310a7096b0d3e86f6464c667aa2339045d85d505/src/Spago/Build.hs#L422
    # https://esbuild.github.io/api/#transform-api
    buildPhase = ''
      build-spago-style "./src/**/*.purs"
      echo 'import {main} from "./output/Main/index.js"; main();' | esbuild --platform=browser --format=iife --bundle  --outfile="frontend.js"
    '';
    installPhase = ''
      mkdir $out
      mv frontend.js $out/
    '';
  };

we need echo esbuild transform-api to invoke main method.

i think the issue caused from here

Turtle.proc command arguments (Turtle.select input) >>= \case

do we have to use Turtle.shell https://hackage.haskell.org/package/turtle-1.6.1/docs/Turtle-Prelude.html#v:shell for nix derivation ?

@f-f
Copy link
Member

f-f commented Jun 23, 2022

@yuanwang-wf we used to have a mix of shell and proc before, so this is a good candidate for a regression. Have you tried patching in shell in place for proc and seeing if it improves?

@yuanwang-wf
Copy link
Author

yuanwang-wf commented Jun 23, 2022

thanks for the confirmation , i can give a try

@yuanwang-wf
Copy link
Author

yuanwang-wf commented Jun 23, 2022

hey @f-f

patching shell for proc seems fix this particular issue on my machine

this is the patching diff

master...yuanwang-wf:debug

and i pulled this patched spago in another nix flake repo

https://github.com/yuanwang-wf/nix-haskell-devshell-template/blob/debug-spago/servant-halogen/flake.nix#L18

with this patched spago, i was able to bundle the js in a nix derivation locally (had to pull git as build input)

https://github.com/yuanwang-wf/nix-haskell-devshell-template/blob/debug-spago/servant-halogen/frontends/default.nix#L23

i verified there is no difference between the spago bundle results and direct esbuild bundle result in this repo.

is there anything else i can help with ? i am not sure how to fix the issue: introduce a new command line flag ? or invoke Turtle.shell in no-install mode ?

@f-f
Copy link
Member

f-f commented Jun 24, 2022

Can you open a pull request with the patch? So that we can have CI run for all OSs and we can see if there are any regressions anywhere

@yuanwang-wf yuanwang-wf mentioned this issue Jun 24, 2022
3 tasks
@yuanwang-wf
Copy link
Author

@f-f hey, i opened #891, it seems there are some approval needed to kick out the CI runs

@f-f
Copy link
Member

f-f commented Jun 27, 2022

I approved the workflow and CI passes so I think the patch is good - I now wonder if we're able to write a test that fails with the current code but passes with the patch?

@yuanwang-wf
Copy link
Author

since the failure was due to a failure on posix_spawn on a read only path , to add a haskell test to verify that we need to do chmod using turtle and clean up chmod change once test finish? I can give a try, let me know if you have any suggestion or idea on the test implementation

@f-f
Copy link
Member

f-f commented Sep 20, 2023

Spago was rewritten in PureScript so I expect that the nix machinery will be very different this time around - closing for now

@f-f f-f closed this as completed Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants