diff --git a/.github/workflows/ci.yml b/.github/workflows/Cabal.yml similarity index 99% rename from .github/workflows/ci.yml rename to .github/workflows/Cabal.yml index 106b8adc8..1cf8e6a95 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/Cabal.yml @@ -1,5 +1,5 @@ # modified from https://github.com/jgm/pandoc/blob/master/.github/workflows/ci.yml -name: CI +name: Cabal on: push: diff --git a/.github/workflows/Nix.yml b/.github/workflows/Nix.yml new file mode 100644 index 000000000..8bc382119 --- /dev/null +++ b/.github/workflows/Nix.yml @@ -0,0 +1,27 @@ +name: Nix + +on: + push: + branches: + - '**' + paths-ignore: [] + pull_request: + paths-ignore: [] + +jobs: + linux: + + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v2 + + # https://github.com/marketplace/actions/install-nix + - name: Install Nix + uses: cachix/install-nix-action@v14 + with: + extra_nix_config: | + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + substituters = https://hydra.iohk.io https://cache.nixos.org/ + - run: nix build --extra-experimental-features nix-command -f default.nix diff --git a/README.md b/README.md index c127b74f7..b24c33101 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ CodeWorld ========= [![Build Status](https://travis-ci.org/google/codeworld.svg?branch=master)](https://travis-ci.org/google/codeworld) -[![Build status](https://github.com/google/codeworld/actions/workflows/ci.yml/badge.svg)](https://github.com/google/codeworld/actions/workflows/ci.yml) +[![Build status](https://github.com/google/codeworld/actions/workflows/Cabal.yml/badge.svg)](https://github.com/google/codeworld/actions/workflows/Cabal.yml) +[![Build status](https://github.com/google/codeworld/actions/workflows/Nix.yml/badge.svg)](https://github.com/google/codeworld/actions/workflows/Nix.yml) CodeWorld is an educational environment using Haskell. It provides a simple mathematical model for geometric figures, animations, and interactive and diff --git a/cabal.project b/cabal.project index 9466eccf8..0764876ae 100644 --- a/cabal.project +++ b/cabal.project @@ -1,12 +1,32 @@ +profiling: false packages: codeworld-account/ codeworld-api/ codeworld-auth/ + -- codeworld-available-pkgs/ + codeworld-base/ codeworld-compiler/ codeworld-error-sanitizer/ codeworld-game-api/ codeworld-game-server/ codeworld-prediction/ codeworld-server/ - codeworld-base/ funblocks-client/ + +source-repository-package + type: git + location: https://github.com/peterbecich/hgeometry.git + tag: f898c5580c609320f0c7cc776e80f609711d19c5 + subdir: hgeometry + --sha256: 0bmcb3dh1sfz6k7i30czcqqvarm1mzn55xdnimpnp19kj8v5g8nj + +source-repository-package + type: git + location: https://github.com/peterbecich/hgeometry.git + tag: f898c5580c609320f0c7cc776e80f609711d19c5 + subdir: hgeometry-combinatorial + --sha256: 0bmcb3dh1sfz6k7i30czcqqvarm1mzn55xdnimpnp19kj8v5g8nj + +allow-newer: + reflex:witherable + , patch:witherable \ No newline at end of file diff --git a/codeworld-api/codeworld-api.cabal b/codeworld-api/codeworld-api.cabal index a7f731030..2de3b8cbf 100644 --- a/codeworld-api/codeworld-api.cabal +++ b/codeworld-api/codeworld-api.cabal @@ -61,11 +61,11 @@ Library mtl >= 2.2.1 && < 2.3, random >= 1.1 && < 1.2, ref-tf >= 0.4 && < 0.5, - reflex >= 0.6.3 && < 0.7, + reflex >= 0.6.3, template-haskell >= 2.8 && < 2.18, text >= 1.2.2 && < 1.3, time >= 1.8 && < 2.0, - witherable >= 0.3 && < 0.4 + witherable >= 0.3 if impl(ghcjs) Js-sources: jsbits/sim_fp.js @@ -73,7 +73,7 @@ Library ghcjs-prim, codeworld-game-api, codeworld-prediction, - ghcjs-dom >= 0.9 && < 0.9.4, + ghcjs-dom >= 0.9, transformers else Build-depends: blank-canvas >= 0.6 && < 0.8, @@ -122,11 +122,11 @@ Test-suite unit-tests mtl >= 2.2.1 && < 2.3, random >= 1.1 && < 1.2, ref-tf >= 0.4 && < 0.5, - reflex >= 0.6.3 && < 0.7, + reflex >= 0.6.3, template-haskell >= 2.8 && < 2.18, text >= 1.2.2 && < 1.3, time >= 1.8 && < 2.0, - witherable >= 0.3 && < 0.4 + witherable >= 0.3 if impl(ghcjs) Js-sources: jsbits/sim_fp.js @@ -134,7 +134,7 @@ Test-suite unit-tests ghcjs-prim, codeworld-game-api, codeworld-prediction, - ghcjs-dom >= 0.9 && < 0.9.4, + ghcjs-dom >= 0.9, transformers else Build-depends: blank-canvas >= 0.6 && < 0.8, diff --git a/codeworld-available-pkgs/codeworld-available-pkgs.cabal b/codeworld-available-pkgs/codeworld-available-pkgs.cabal index bf9c4fca3..9a1593736 100644 --- a/codeworld-available-pkgs/codeworld-available-pkgs.cabal +++ b/codeworld-available-pkgs/codeworld-available-pkgs.cabal @@ -10,317 +10,630 @@ Copyright: (c) 2020, The CodeWorld Authors Bug-reports: https://github.com/google/codeworld/issues Library - Build-depends: - Boolean, - Decimal, - Earley, - HUnit, - ListLike, - MemoTrie, - MonadRandom, - NumInstances, - Only, - QuickCheck, - SHA, - StateVar, - Yampa, - active, - ad, - adjunctions, - -- accelerate, (does not build with GHCJS) - aeson, - algebraic-graphs, - apportionment, - array, - assoc, - async, - attoparsec, - attoparsec-iso8601, - auto, - -- axiom, (depends on transient, which fails to build) - backprop, - base, - base-compat-batteries, - base-orphans, - base64-bytestring, - basement, - bifunctors, - bimap, - binary, - binary-orphans, - blaze-builder, - blaze-html, - blaze-markup, - -- board-games, (depends on network) - bool8, - bytes, - bytestring, - bytestring-builder, - call-stack, - capability, - case-insensitive, - cereal, - cereal-text, - charset, - checksum, - circle-packing, - clock, - colour, - combinatorial, - comonad, - comonad-transformers, - concur-core, - concurrency, - concurrent-output, - conduit, - constraints, - constraints-extras, - containers, - contravariant, - cookie, - cryptonite, - cubicbezier, - data-accessor, - data-accessor-transformers, - data-default, - data-default-class, - data-default-instances-containers, - data-default-instances-dlist, - data-default-instances-old-locale, - data-reify, - dec, - deepseq, - dejafu, - dense-linear-algebra, - dependent-map, - dependent-sum, - diagrams, - diagrams-contrib, - diagrams-core, - diagrams-lib, - diagrams-solve, - diagrams-svg, - digestive-functors, - distributive, - dlist, - dsp, - dual-tree, - dunai, - either, - enclosed-exceptions, - enummapset, - erf, - event-list, - exception-transformers, - exceptions, - explicit-exception, - extensible-effects, - extra, - fail, - fast-math, - fclabels, - fgl, - fingertree, - finite-typelits, - first-class-families, - fixed-length, - fixed-list, - flow, - foldl, - fmlist, - force-layout, - -- formattable, (time dependency is too old) - -- foundation, (doesn't build for unclear reasons related to ghc-prim) - free, - fused-effects, - generic-deriving, - generic-lens, - generics-sop, - ghc-prim, - ghcjs-base, - ghcjs-dom, - ghcjs-perch, - ghcjs-prim, - gray-code, - groups, - half, - -- hamilton, (depends on hmatrix, which uses native libs) - hashable, - hashtables, - haskell-lexer, - haskell-src-exts, - haskell-src-meta, - hedgehog, - hgeometry >= 0.12, - hspec, - hspec-core, - hspec-expectations, - html, - http-api-data, - http-media, - http-types, - ieee754, - indexed-list-literals, - indexed-profunctors, - integer-gmp, - integer-logarithms, - integration, - interpolation, - intervals, - invariant, - jsaddle, - kan-extensions, - keycode, - latex, - leancheck, - lens, - lifted-async, - lifted-base, - linear, - log-domain, - logict, - loop, - markov-chain, - massiv, - math-functions, - matrix, - megaparsec, - memory, - mersenne-random-pure64, - mfsolve, - microlens, - microlens-mtl, - miso, - mmorph, - monad-bayes, - monad-control, - -- monad-coroutine 0.9.1 broken for old base - monad-coroutine < 0.9.1, - monad-loops, - monad-parallel, - monad-unlift, - mono-traversable, - monoid-extras, - monoid-transformer, - monoidal-containers, - moo, - mtl, - mtl-compat, - mutable-containers, - mwc-probability, - mwc-random, - nats, - natural-transformation, - netwire, - network-uri, - newtype-generics, - non-negative, - numeric-prelude, - old-locale, - optics, - optics-core, - optics-extra, - optparse-applicative, - parallel, - parsec, - parser-combinators, - parsers, - patch, - pipes, - polysemy, - pqueue, - prelude-compat, - pretty, - pretty-simple, - pretty-show, - prettyprinter, - prim-uniq, - primitive, - probability, - profunctors, - protolude, - psqueues, - quickcheck-io, - random, - random-shuffle, - reactive-banana, - -- reanimate, (depends on chiphunk, which depends on native library) - reducers, - ref-tf, - reflection, - reflex, - reflex-dom, - reflex-dom-core, - regex-base, - regex-compat-tdfa, - regex-tdfa, - relude, - resourcet, - rio, - safe, - safe-exceptions, - scheduler, - scientific, - semialign, - semigroupoids, - semigroups, - servant, - set-cover, - singleton-bool, - -- singletons, (build error related to Int/Integer/Uniq) - smallcheck, - sop-core, - split, - splitmix, - statistics, - stm, - storable-complex, - storable-record, - streaming, - string-conversions, - svg-builder, - syb, - tagged, - tasty, - tasty-expected-failure, - tasty-hedgehog, - tasty-hunit, - template-haskell, - text, - tf-random, - tfp, - these, - time, - time-compat, - transformers, - transformers-base, - transformers-compat, - -- transient, (build fails: missing Semigroup instance for TransIO) - trifecta, - type-equality, - typelits-witnesses, - unagi-chan, - unbounded-delays, - unexceptionalio, - unicode, - unique, - unliftio, - unliftio-core, - unordered-containers, - utf8-string, - utility-ht, - uuid-types, - vault, - vector, - vector-algorithms, - vector-binary-instances, - vector-builder, - vector-space, - vinyl, - void, - witherable, - wl-pprint-annotated, - zenc + extra-libraries: m + if impl(ghcjs -any) + Build-depends: + Boolean, + Decimal, + Earley, + HUnit, + ListLike, + MemoTrie, + MonadRandom, + NumInstances, + Only, + QuickCheck, + SHA, + StateVar, + Yampa, + active, + ad, + adjunctions, + -- accelerate, (does not build with GHCJS) + aeson, + algebraic-graphs, + apportionment, + array, + assoc, + async, + attoparsec, + attoparsec-iso8601, + auto, + -- axiom, (depends on transient, which fails to build) + backprop, + base, + base-compat-batteries, + base-orphans, + base64-bytestring, + basement, + bifunctors, + bimap, + binary, + binary-orphans, + blaze-builder, + blaze-html, + blaze-markup, + -- board-games, (depends on network) + bool8, + bytes, + bytestring, + bytestring-builder, + call-stack, + capability, + case-insensitive, + cereal, + cereal-text, + charset, + checksum, + circle-packing, + clock, + colour, + combinatorial, + comonad, + comonad-transformers, + concur-core, + concurrency, + concurrent-output, + conduit, + constraints, + constraints-extras, + containers, + contravariant, + cookie, + cryptonite, + cubicbezier, + data-accessor, + data-accessor-transformers, + data-default, + data-default-class, + data-default-instances-containers, + data-default-instances-dlist, + data-default-instances-old-locale, + data-reify, + dec, + deepseq, + dejafu, + dense-linear-algebra, + dependent-map, + dependent-sum, + diagrams, + diagrams-contrib, + diagrams-core, + diagrams-lib, + diagrams-solve, + diagrams-svg, + digestive-functors, + distributive, + dlist, + dsp, + dual-tree, + dunai, + either, + enclosed-exceptions, + enummapset, + erf, + event-list, + exception-transformers, + exceptions, + explicit-exception, + extensible-effects, + extra, + fail, + fast-math, + fclabels, + fgl, + fingertree, + finite-typelits, + first-class-families, + fixed-length, + fixed-list, + flow, + foldl, + fmlist, + force-layout, + -- formattable, (time dependency is too old) + -- foundation, (doesn't build for unclear reasons related to ghc-prim) + free, + fused-effects, + generic-deriving, + generic-lens, + generics-sop, + ghc-prim, + ghcjs-base, + ghcjs-dom, + ghcjs-perch, + ghcjs-prim, + gray-code, + groups, + half, + -- hamilton, (depends on hmatrix, which uses native libs) + hashable, + hashtables, + haskell-lexer, + haskell-src-exts, + haskell-src-meta, + hedgehog, + hgeometry >= 0.12, + hspec, + hspec-core, + hspec-expectations, + html, + http-api-data, + http-media, + http-types, + ieee754, + indexed-list-literals, + indexed-profunctors, + integer-gmp, + integer-logarithms, + integration, + interpolation, + intervals, + invariant, + jsaddle, + kan-extensions, + keycode, + latex, + leancheck, + lens, + lifted-async, + lifted-base, + linear, + log-domain, + logict, + loop, + markov-chain, + massiv, + math-functions, + matrix, + megaparsec, + memory, + mersenne-random-pure64, + mfsolve, + microlens, + microlens-mtl, + miso, + mmorph, + monad-bayes, + monad-control, + -- monad-coroutine 0.9.1 broken for old base + monad-coroutine < 0.9.1, + monad-loops, + monad-parallel, + monad-unlift, + mono-traversable, + monoid-extras, + monoid-transformer, + monoidal-containers, + moo, + mtl, + mtl-compat, + mutable-containers, + mwc-probability, + mwc-random, + nats, + natural-transformation, + netwire, + network-uri, + newtype-generics, + non-negative, + numeric-prelude, + old-locale, + optics, + optics-core, + optics-extra, + optparse-applicative, + parallel, + parsec, + parser-combinators, + parsers, + patch, + pipes, + polysemy, + pqueue, + prelude-compat, + pretty, + pretty-simple, + pretty-show, + prettyprinter, + prim-uniq, + primitive, + probability, + profunctors, + protolude, + psqueues, + quickcheck-io, + random, + random-shuffle, + reactive-banana, + -- reanimate, (depends on chiphunk, which depends on native library) + reducers, + ref-tf, + reflection, + reflex, + reflex-dom, + reflex-dom-core, + regex-base, + regex-compat-tdfa, + regex-tdfa, + relude, + resourcet, + rio, + safe, + safe-exceptions, + scheduler, + scientific, + semialign, + semigroupoids, + semigroups, + servant, + set-cover, + singleton-bool, + -- singletons, (build error related to Int/Integer/Uniq) + smallcheck, + sop-core, + split, + splitmix, + statistics, + stm, + storable-complex, + storable-record, + streaming, + string-conversions, + svg-builder, + syb, + tagged, + tasty, + tasty-expected-failure, + tasty-hedgehog, + tasty-hunit, + template-haskell, + text, + tf-random, + tfp, + these, + time, + time-compat, + transformers, + transformers-base, + transformers-compat, + -- transient, (build fails: missing Semigroup instance for TransIO) + trifecta, + type-equality, + typelits-witnesses, + unagi-chan, + unbounded-delays, + unexceptionalio, + unicode, + unique, + unliftio, + unliftio-core, + unordered-containers, + utf8-string, + utility-ht, + uuid-types, + vault, + vector, + vector-algorithms, + vector-binary-instances, + vector-builder, + vector-space, + vinyl, + void, + witherable, + wl-pprint-annotated, + zenc + else + -- excludes ghcjs-base and ghcjs-prim + Build-depends: + Boolean, + Decimal, + Earley, + HUnit, + ListLike, + MemoTrie, + MonadRandom, + NumInstances, + Only, + QuickCheck, + SHA, + StateVar, + Yampa, + active, + ad, + adjunctions, + -- accelerate, (does not build with GHCJS) + aeson, + algebraic-graphs, + apportionment, + array, + assoc, + async, + attoparsec, + attoparsec-iso8601, + auto, + -- axiom, (depends on transient, which fails to build) + backprop, + base, + base-compat-batteries, + base-orphans, + base64-bytestring, + basement, + bifunctors, + bimap, + binary, + binary-orphans, + blaze-builder, + blaze-html, + blaze-markup, + -- board-games, (depends on network) + bool8, + bytes, + bytestring, + bytestring-builder, + call-stack, + capability, + case-insensitive, + cereal, + cereal-text, + charset, + checksum, + circle-packing, + clock, + colour, + combinatorial, + comonad, + comonad-transformers, + concur-core, + concurrency, + concurrent-output, + conduit, + constraints, + constraints-extras, + containers, + contravariant, + cookie, + cryptonite, + cubicbezier, + data-accessor, + data-accessor-transformers, + data-default, + data-default-class, + data-default-instances-containers, + data-default-instances-dlist, + data-default-instances-old-locale, + data-reify, + dec, + deepseq, + dejafu, + dense-linear-algebra, + dependent-map, + dependent-sum, + diagrams, + diagrams-contrib, + diagrams-core, + diagrams-lib, + diagrams-solve, + diagrams-svg, + digestive-functors, + distributive, + dlist, + dsp, + dual-tree, + dunai, + either, + enclosed-exceptions, + enummapset, + erf, + event-list, + exception-transformers, + exceptions, + explicit-exception, + extensible-effects, + extra, + fail, + fast-math, + fclabels, + fgl, + fingertree, + finite-typelits, + first-class-families, + fixed-length, + fixed-list, + flow, + foldl, + fmlist, + force-layout, + -- formattable, (time dependency is too old) + -- foundation, (doesn't build for unclear reasons related to ghc-prim) + free, + fused-effects, + generic-deriving, + generic-lens, + generics-sop, + ghc-prim, + ghcjs-dom, + ghcjs-perch, + gray-code, + groups, + half, + -- hamilton, (depends on hmatrix, which uses native libs) + hashable, + hashtables, + haskell-lexer, + haskell-src-exts, + haskell-src-meta, + hedgehog, + hgeometry >= 0.12, + hspec, + hspec-core, + hspec-expectations, + html, + http-api-data, + http-media, + http-types, + ieee754, + indexed-list-literals, + indexed-profunctors, + integer-gmp, + integer-logarithms, + integration, + interpolation, + intervals, + invariant, + jsaddle, + kan-extensions, + keycode, + latex, + leancheck, + lens, + lifted-async, + lifted-base, + linear, + log-domain, + logict, + loop, + markov-chain, + massiv, + math-functions, + matrix, + megaparsec, + memory, + mersenne-random-pure64, + mfsolve, + microlens, + microlens-mtl, + miso, + mmorph, + monad-bayes, + monad-control, + -- monad-coroutine 0.9.1 broken for old base + monad-coroutine < 0.9.1, + monad-loops, + monad-parallel, + monad-unlift, + mono-traversable, + monoid-extras, + monoid-transformer, + monoidal-containers, + moo, + mtl, + mtl-compat, + mutable-containers, + mwc-probability, + mwc-random, + nats, + natural-transformation, + netwire, + network-uri, + newtype-generics, + non-negative, + numeric-prelude, + old-locale, + optics, + optics-core, + optics-extra, + optparse-applicative, + parallel, + parsec, + parser-combinators, + parsers, + patch, + pipes, + polysemy, + pqueue, + prelude-compat, + pretty, + pretty-simple, + pretty-show, + prettyprinter, + prim-uniq, + primitive, + probability, + profunctors, + protolude, + psqueues, + quickcheck-io, + random, + random-shuffle, + reactive-banana, + -- reanimate, (depends on chiphunk, which depends on native library) + reducers, + ref-tf, + reflection, + reflex, + reflex-dom, + reflex-dom-core, + regex-base, + regex-compat-tdfa, + regex-tdfa, + relude, + resourcet, + rio, + safe, + safe-exceptions, + scheduler, + scientific, + semialign, + semigroupoids, + semigroups, + servant, + set-cover, + singleton-bool, + -- singletons, (build error related to Int/Integer/Uniq) + smallcheck, + sop-core, + split, + splitmix, + statistics, + stm, + storable-complex, + storable-record, + streaming, + string-conversions, + svg-builder, + syb, + tagged, + tasty, + tasty-expected-failure, + tasty-hedgehog, + tasty-hunit, + template-haskell, + text, + tf-random, + tfp, + these, + time, + time-compat, + transformers, + transformers-base, + transformers-compat, + -- transient, (build fails: missing Semigroup instance for TransIO) + trifecta, + type-equality, + typelits-witnesses, + unagi-chan, + unbounded-delays, + unexceptionalio, + unicode, + unique, + unliftio, + unliftio-core, + unordered-containers, + utf8-string, + utility-ht, + uuid-types, + vault, + vector, + vector-algorithms, + vector-binary-instances, + vector-builder, + vector-space, + vinyl, + void, + witherable, + wl-pprint-annotated, + zenc Default-language: Haskell2010 diff --git a/codeworld-base/codeworld-base.cabal b/codeworld-base/codeworld-base.cabal index 3f478f405..d9aaeb3ab 100644 --- a/codeworld-base/codeworld-base.cabal +++ b/codeworld-base/codeworld-base.cabal @@ -45,7 +45,7 @@ Library codeworld-api, ghc-prim, ghcjs-base, - ghcjs-dom, + ghcjs-dom >=0.9, mtl, random, random-shuffle, diff --git a/codeworld-compiler/codeworld-compiler.cabal b/codeworld-compiler/codeworld-compiler.cabal index 75ed47614..0033f98b1 100644 --- a/codeworld-compiler/codeworld-compiler.cabal +++ b/codeworld-compiler/codeworld-compiler.cabal @@ -54,16 +54,17 @@ Library directory, exceptions, filepath, - ghc == 8.6.5, - ghc-boot-th == 8.6.5, + ghc, + ghc-boot, + ghc-boot-th, hashable, haskell-src-exts >= 1.20, megaparsec >= 7.0.0 && < 8.0.0, memory, mtl, process, + regex-base, regex-tdfa, - regex-tdfa-text, split, syb, temporary, diff --git a/codeworld-error-sanitizer/codeworld-error-sanitizer.cabal b/codeworld-error-sanitizer/codeworld-error-sanitizer.cabal index 95ad875b1..8940b32f7 100644 --- a/codeworld-error-sanitizer/codeworld-error-sanitizer.cabal +++ b/codeworld-error-sanitizer/codeworld-error-sanitizer.cabal @@ -25,8 +25,7 @@ Library else Build-depends: array, regex-base, - regex-tdfa, - regex-tdfa-text + regex-tdfa Default-language: Haskell2010 Exposed: True @@ -49,7 +48,6 @@ Test-suite unit-tests else Build-depends: array, regex-base, - regex-tdfa, - regex-tdfa-text + regex-tdfa Default-language: Haskell2010 diff --git a/codeworld-requirements/codeworld-requirements.cabal b/codeworld-requirements/codeworld-requirements.cabal index 3337ab1ed..f2c09c324 100644 --- a/codeworld-requirements/codeworld-requirements.cabal +++ b/codeworld-requirements/codeworld-requirements.cabal @@ -36,8 +36,8 @@ library haskell-src-exts >= 1.20, mtl, process, + regex-base, regex-tdfa, - regex-tdfa-text, syb, temporary, text, diff --git a/codeworld-server/codeworld-server.cabal b/codeworld-server/codeworld-server.cabal index 035e6a683..d9cb09fd9 100644 --- a/codeworld-server/codeworld-server.cabal +++ b/codeworld-server/codeworld-server.cabal @@ -39,7 +39,7 @@ Executable codeworld-server fast-logger, filelock, filepath, - haskell-src-exts < 1.21, + haskell-src-exts, http-conduit, lifted-base, memory, diff --git a/default.nix b/default.nix new file mode 100644 index 000000000..b079a9792 --- /dev/null +++ b/default.nix @@ -0,0 +1,34 @@ +# https://input-output-hk.github.io/haskell.nix/tutorials/getting-started/ +{ compiler ? "ghc865", + ghcjsVersion ? "8.6.0.0.10", + ghcVersion ? "8.6.5", + withCoverage ? false +}: + let + sources = import ./nix/sources.nix {}; + haskellNix = import sources.haskellNix {}; + pkgs = import + haskellNix.sources.nixpkgs-unstable + haskellNix.nixpkgsArgs; + overlays = [ + (self: super: + { + m = self.stdenv.mkDerivation { + name = "m"; + unpackPhase = "true"; + installPhase = "mkdir -p $out"; + }; + } + ) + ]; + + in + pkgs.haskell-nix.ghcjsProject { + # projectFileName = "cabal.project"; + ghcjsVersion = "8.6.0.0.10"; + src = pkgs.haskell-nix.haskellLib.cleanGit { + name = "codeworld"; + src = ./.; + }; + compiler-nix-name = compiler; + } diff --git a/funblocks-client/funblocks-client.cabal b/funblocks-client/funblocks-client.cabal index c5f50adea..6c9abb9bf 100644 --- a/funblocks-client/funblocks-client.cabal +++ b/funblocks-client/funblocks-client.cabal @@ -38,11 +38,11 @@ Executable funblocks-client Build-depends: ghcjs-base, text, containers, - ghcjs-dom, + ghcjs-dom >=0.9, mtl else Build-depends: ghcjs-base-stub, text, containers, - ghcjs-dom, + ghcjs-dom >=0.9, mtl diff --git a/nix/sources.json b/nix/sources.json new file mode 100644 index 000000000..e8393e221 --- /dev/null +++ b/nix/sources.json @@ -0,0 +1,38 @@ +{ + "haskellNix": { + "branch": "master", + "description": "Alternative Haskell Infrastructure for Nixpkgs", + "homepage": "https://input-output-hk.github.io/haskell.nix", + "owner": "input-output-hk", + "repo": "haskell.nix", + "rev": "564458fc4080c0fc51e316d74c3dbb68639ea839", + "sha256": "0d7kp3sqw8zhp4sv5awla6ch15mbndmr3640y3pwlvkcb59p8amm", + "type": "tarball", + "url": "https://github.com/input-output-hk/haskell.nix/archive/564458fc4080c0fc51e316d74c3dbb68639ea839.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "niv": { + "branch": "master", + "description": "Easy dependency management for Nix projects", + "homepage": "https://github.com/nmattia/niv", + "owner": "nmattia", + "repo": "niv", + "rev": "65a61b147f307d24bfd0a5cd56ce7d7b7cc61d2e", + "sha256": "17mirpsx5wyw262fpsd6n6m47jcgw8k2bwcp1iwdnrlzy4dhcgqh", + "type": "tarball", + "url": "https://github.com/nmattia/niv/archive/65a61b147f307d24bfd0a5cd56ce7d7b7cc61d2e.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "nixpkgs": { + "branch": "release-20.03", + "description": "Nix Packages collection", + "homepage": "", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "eb73405ecceb1dc505b7cbbd234f8f94165e2696", + "sha256": "06k21wbyhhvq2f1xczszh3c2934p0m02by3l2ixvd6nkwrqklax7", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/eb73405ecceb1dc505b7cbbd234f8f94165e2696.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + } +} diff --git a/nix/sources.nix b/nix/sources.nix new file mode 100644 index 000000000..1938409dd --- /dev/null +++ b/nix/sources.nix @@ -0,0 +1,174 @@ +# This file has been generated by Niv. + +let + + # + # The fetchers. fetch_ fetches specs of type . + # + + fetch_file = pkgs: name: spec: + let + name' = sanitizeName name + "-src"; + in + if spec.builtin or true then + builtins_fetchurl { inherit (spec) url sha256; name = name'; } + else + pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; + + fetch_tarball = pkgs: name: spec: + let + name' = sanitizeName name + "-src"; + in + if spec.builtin or true then + builtins_fetchTarball { name = name'; inherit (spec) url sha256; } + else + pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; + + fetch_git = name: spec: + let + ref = + if spec ? ref then spec.ref else + if spec ? branch then "refs/heads/${spec.branch}" else + if spec ? tag then "refs/tags/${spec.tag}" else + abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; + in + builtins.fetchGit { url = spec.repo; inherit (spec) rev; inherit ref; }; + + fetch_local = spec: spec.path; + + fetch_builtin-tarball = name: throw + ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=tarball -a builtin=true''; + + fetch_builtin-url = name: throw + ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=file -a builtin=true''; + + # + # Various helpers + # + + # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 + sanitizeName = name: + ( + concatMapStrings (s: if builtins.isList s then "-" else s) + ( + builtins.split "[^[:alnum:]+._?=-]+" + ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) + ) + ); + + # The set of packages used when specs are fetched using non-builtins. + mkPkgs = sources: system: + let + sourcesNixpkgs = + import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; + hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; + hasThisAsNixpkgsPath = == ./.; + in + if builtins.hasAttr "nixpkgs" sources + then sourcesNixpkgs + else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then + import {} + else + abort + '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; + + # The actual fetching function. + fetch = pkgs: name: spec: + + if ! builtins.hasAttr "type" spec then + abort "ERROR: niv spec ${name} does not have a 'type' attribute" + else if spec.type == "file" then fetch_file pkgs name spec + else if spec.type == "tarball" then fetch_tarball pkgs name spec + else if spec.type == "git" then fetch_git name spec + else if spec.type == "local" then fetch_local spec + else if spec.type == "builtin-tarball" then fetch_builtin-tarball name + else if spec.type == "builtin-url" then fetch_builtin-url name + else + abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; + + # If the environment variable NIV_OVERRIDE_${name} is set, then use + # the path directly as opposed to the fetched source. + replace = name: drv: + let + saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; + ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; + in + if ersatz == "" then drv else + # this turns the string into an actual Nix path (for both absolute and + # relative paths) + if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; + + # Ports of functions for older nix versions + + # a Nix version of mapAttrs if the built-in doesn't exist + mapAttrs = builtins.mapAttrs or ( + f: set: with builtins; + listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) + ); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 + range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 + stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); + + # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 + stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); + concatMapStrings = f: list: concatStrings (map f list); + concatStrings = builtins.concatStringsSep ""; + + # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 + optionalAttrs = cond: as: if cond then as else {}; + + # fetchTarball version that is compatible between all the versions of Nix + builtins_fetchTarball = { url, name ? null, sha256 }@attrs: + let + inherit (builtins) lessThan nixVersion fetchTarball; + in + if lessThan nixVersion "1.12" then + fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) + else + fetchTarball attrs; + + # fetchurl version that is compatible between all the versions of Nix + builtins_fetchurl = { url, name ? null, sha256 }@attrs: + let + inherit (builtins) lessThan nixVersion fetchurl; + in + if lessThan nixVersion "1.12" then + fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) + else + fetchurl attrs; + + # Create the final "sources" from the config + mkSources = config: + mapAttrs ( + name: spec: + if builtins.hasAttr "outPath" spec + then abort + "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = replace name (fetch config.pkgs name spec); } + ) config.sources; + + # The "config" used by the fetchers + mkConfig = + { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null + , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) + , system ? builtins.currentSystem + , pkgs ? mkPkgs sources system + }: rec { + # The sources, i.e. the attribute set of spec name to spec + inherit sources; + + # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers + inherit pkgs; + }; + +in +mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }