From 5a3b4d3e5d101a22a68c4d4dc1f7498612738f1a Mon Sep 17 00:00:00 2001 From: Peter Becich Date: Tue, 14 Sep 2021 00:12:54 -0700 Subject: [PATCH 1/6] work-in-progress Nix support with https://github.com/input-output-hk/haskell.nix --- .github/workflows/{ci.yml => Cabal.yml} | 2 +- .github/workflows/Nix.yml | 27 +++ README.md | 3 +- cabal.project | 7 +- codeworld-api/codeworld-api.cabal | 8 +- .../codeworld-available-pkgs.cabal | 2 +- codeworld-base/codeworld-base.cabal | 2 +- codeworld-compiler/codeworld-compiler.cabal | 8 +- .../codeworld-error-sanitizer.cabal | 6 +- .../codeworld-requirements.cabal | 2 +- codeworld-server/codeworld-server.cabal | 2 +- default.nix | 16 ++ funblocks-client/funblocks-client.cabal | 4 +- nix/sources.json | 38 ++++ nix/sources.nix | 174 ++++++++++++++++++ 15 files changed, 279 insertions(+), 22 deletions(-) rename .github/workflows/{ci.yml => Cabal.yml} (99%) create mode 100644 .github/workflows/Nix.yml create mode 100644 default.nix create mode 100644 nix/sources.json create mode 100644 nix/sources.nix 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..81771d17a --- /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 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..7dc10ad3f 100644 --- a/cabal.project +++ b/cabal.project @@ -2,11 +2,12 @@ packages: codeworld-account/ codeworld-api/ codeworld-auth/ + -- codeworld-available-pkgs/ codeworld-compiler/ codeworld-error-sanitizer/ codeworld-game-api/ - codeworld-game-server/ + -- codeworld-game-server/ codeworld-prediction/ - codeworld-server/ - codeworld-base/ + -- codeworld-server/ + -- codeworld-base/ funblocks-client/ diff --git a/codeworld-api/codeworld-api.cabal b/codeworld-api/codeworld-api.cabal index a7f731030..658c38730 100644 --- a/codeworld-api/codeworld-api.cabal +++ b/codeworld-api/codeworld-api.cabal @@ -61,7 +61,7 @@ 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, @@ -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,7 +122,7 @@ 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, @@ -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..f12c418cd 100644 --- a/codeworld-available-pkgs/codeworld-available-pkgs.cabal +++ b/codeworld-available-pkgs/codeworld-available-pkgs.cabal @@ -138,7 +138,7 @@ Library generics-sop, ghc-prim, ghcjs-base, - ghcjs-dom, + ghcjs-dom >=0.9, ghcjs-perch, ghcjs-prim, gray-code, 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..e6bde84a7 100644 --- a/codeworld-compiler/codeworld-compiler.cabal +++ b/codeworld-compiler/codeworld-compiler.cabal @@ -54,16 +54,18 @@ Library directory, exceptions, filepath, - ghc == 8.6.5, - ghc-boot-th == 8.6.5, + ghc, + ghc-boot, + ghc-boot-th, + ghc-lib-parser, 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..8b57c57c3 --- /dev/null +++ b/default.nix @@ -0,0 +1,16 @@ +# https://input-output-hk.github.io/haskell.nix/tutorials/getting-started/ +let + sources = import ./nix/sources.nix {}; + haskellNix = import sources.haskellNix {}; + pkgs = import + haskellNix.sources.nixpkgs-2105 + haskellNix.nixpkgsArgs; +in pkgs.pkgsCross.ghcjs.haskell-nix.project { +#in pkgs.haskell-nix.project { + projectFileName = "cabal.project"; + src = pkgs.haskell-nix.haskellLib.cleanGit { + name = "haskell-nix-project"; + src = ./.; + }; + compiler-nix-name = "ghc865"; +} 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..8a544d38d --- /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": "f51f24f8d24c1fd3f3a9bc7e93d008ede09baaab", + "sha256": "16shqxlvfa4hpshrn0wbjlwrvmiqg6l6p4fjpsbr882m26jgk2qx", + "type": "tarball", + "url": "https://github.com/input-output-hk/haskell.nix/archive/f51f24f8d24c1fd3f3a9bc7e93d008ede09baaab.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); } From 06de44415c8635c364a467c61709794bace081ae Mon Sep 17 00:00:00 2001 From: Peter Becich Date: Sun, 17 Oct 2021 22:33:16 -0700 Subject: [PATCH 2/6] build subset of packages with ghcjs and Nix --- cabal.project | 19 ++++++------ codeworld-compiler/codeworld-compiler.cabal | 2 +- default.nix | 34 ++++++++++++--------- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/cabal.project b/cabal.project index 7dc10ad3f..9fb3de2a5 100644 --- a/cabal.project +++ b/cabal.project @@ -1,13 +1,14 @@ +profiling: false packages: - codeworld-account/ - codeworld-api/ - codeworld-auth/ - -- codeworld-available-pkgs/ - codeworld-compiler/ - codeworld-error-sanitizer/ +-- codeworld-account/ +-- codeworld-api/ +-- codeworld-auth/ +-- codeworld-available-pkgs/ +-- codeworld-compiler/ +-- codeworld-error-sanitizer/ codeworld-game-api/ - -- codeworld-game-server/ +-- codeworld-game-server/ codeworld-prediction/ - -- codeworld-server/ - -- codeworld-base/ +-- codeworld-server/ +-- codeworld-base/ funblocks-client/ diff --git a/codeworld-compiler/codeworld-compiler.cabal b/codeworld-compiler/codeworld-compiler.cabal index e6bde84a7..decace865 100644 --- a/codeworld-compiler/codeworld-compiler.cabal +++ b/codeworld-compiler/codeworld-compiler.cabal @@ -57,7 +57,7 @@ Library ghc, ghc-boot, ghc-boot-th, - ghc-lib-parser, + ghc-lib-parser ==8.8.*, hashable, haskell-src-exts >= 1.20, megaparsec >= 7.0.0 && < 8.0.0, diff --git a/default.nix b/default.nix index 8b57c57c3..15a68674a 100644 --- a/default.nix +++ b/default.nix @@ -1,16 +1,20 @@ # https://input-output-hk.github.io/haskell.nix/tutorials/getting-started/ -let - sources = import ./nix/sources.nix {}; - haskellNix = import sources.haskellNix {}; - pkgs = import - haskellNix.sources.nixpkgs-2105 - haskellNix.nixpkgsArgs; -in pkgs.pkgsCross.ghcjs.haskell-nix.project { -#in pkgs.haskell-nix.project { - projectFileName = "cabal.project"; - src = pkgs.haskell-nix.haskellLib.cleanGit { - name = "haskell-nix-project"; - src = ./.; - }; - compiler-nix-name = "ghc865"; -} +{ compiler ? "ghc884", + ghcjs ? "ghcjs", + withCoverage ? false +}: + let + sources = import ./nix/sources.nix {}; + haskellNix = import sources.haskellNix {}; + pkgs = import + haskellNix.sources.nixpkgs-2105 + haskellNix.nixpkgsArgs; + in + pkgs.pkgsCross.ghcjs.haskell-nix.project { + projectFileName = "cabal.project"; + src = pkgs.haskell-nix.haskellLib.cleanGit { + name = "codeworld"; + src = ./.; + }; + compiler-nix-name = compiler; + } From e596c2092ff73a5ca97f77aafc706606c5d2db55 Mon Sep 17 00:00:00 2001 From: Peter Becich Date: Sat, 30 Oct 2021 22:59:53 -0700 Subject: [PATCH 3/6] include `codeworld-available-pkgs` in `cabal.project` compilation succeeds without GHCJS --- cabal.project | 3 +- .../codeworld-available-pkgs.cabal | 934 ++++++++++++------ 2 files changed, 625 insertions(+), 312 deletions(-) diff --git a/cabal.project b/cabal.project index 9466eccf8..3dc2fe3e0 100644 --- a/cabal.project +++ b/cabal.project @@ -2,11 +2,12 @@ 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/ diff --git a/codeworld-available-pkgs/codeworld-available-pkgs.cabal b/codeworld-available-pkgs/codeworld-available-pkgs.cabal index bf9c4fca3..07ea950a4 100644 --- a/codeworld-available-pkgs/codeworld-available-pkgs.cabal +++ b/codeworld-available-pkgs/codeworld-available-pkgs.cabal @@ -10,317 +10,629 @@ 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 + 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 From 47082fccfcfcc6aed791dfb3a1cd6d05a772734c Mon Sep 17 00:00:00 2001 From: Peter Becich Date: Sat, 30 Oct 2021 23:09:34 -0700 Subject: [PATCH 4/6] re-enable all packages --- cabal.project | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cabal.project b/cabal.project index 9fb3de2a5..30c31e528 100644 --- a/cabal.project +++ b/cabal.project @@ -1,14 +1,14 @@ profiling: false packages: --- codeworld-account/ --- codeworld-api/ --- codeworld-auth/ --- codeworld-available-pkgs/ --- codeworld-compiler/ --- codeworld-error-sanitizer/ + codeworld-account/ + codeworld-api/ + codeworld-auth/ + codeworld-available-pkgs/ + codeworld-compiler/ + codeworld-error-sanitizer/ codeworld-game-api/ --- codeworld-game-server/ + codeworld-game-server/ codeworld-prediction/ --- codeworld-server/ --- codeworld-base/ + codeworld-server/ + codeworld-base/ funblocks-client/ From b4f03ad67086af881503a29eda704a05cc4f257f Mon Sep 17 00:00:00 2001 From: Peter Becich Date: Sat, 6 Nov 2021 00:58:50 -0700 Subject: [PATCH 5/6] test --- .github/workflows/Nix.yml | 2 +- cabal.project | 20 ++++++++++++++++++- codeworld-api/codeworld-api.cabal | 4 ++-- .../codeworld-available-pkgs.cabal | 1 + default.nix | 15 ++++++++++++-- nix/sources.json | 6 +++--- 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/.github/workflows/Nix.yml b/.github/workflows/Nix.yml index 81771d17a..8bc382119 100644 --- a/.github/workflows/Nix.yml +++ b/.github/workflows/Nix.yml @@ -24,4 +24,4 @@ jobs: 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 + - run: nix build --extra-experimental-features nix-command -f default.nix diff --git a/cabal.project b/cabal.project index f955f1a64..0764876ae 100644 --- a/cabal.project +++ b/cabal.project @@ -3,7 +3,7 @@ packages: codeworld-account/ codeworld-api/ codeworld-auth/ - codeworld-available-pkgs/ + -- codeworld-available-pkgs/ codeworld-base/ codeworld-compiler/ codeworld-error-sanitizer/ @@ -12,3 +12,21 @@ packages: codeworld-prediction/ codeworld-server/ 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 658c38730..2de3b8cbf 100644 --- a/codeworld-api/codeworld-api.cabal +++ b/codeworld-api/codeworld-api.cabal @@ -65,7 +65,7 @@ Library 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 @@ -126,7 +126,7 @@ Test-suite unit-tests 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 diff --git a/codeworld-available-pkgs/codeworld-available-pkgs.cabal b/codeworld-available-pkgs/codeworld-available-pkgs.cabal index 07ea950a4..9a1593736 100644 --- a/codeworld-available-pkgs/codeworld-available-pkgs.cabal +++ b/codeworld-available-pkgs/codeworld-available-pkgs.cabal @@ -10,6 +10,7 @@ Copyright: (c) 2020, The CodeWorld Authors Bug-reports: https://github.com/google/codeworld/issues Library + extra-libraries: m if impl(ghcjs -any) Build-depends: Boolean, diff --git a/default.nix b/default.nix index e26ec6913..e8dc2e63e 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,6 @@ # https://input-output-hk.github.io/haskell.nix/tutorials/getting-started/ { compiler ? "ghc865", - ghcjs ? "ghcjs", + # ghcjs ? "ghcjs", withCoverage ? false }: let @@ -9,8 +9,19 @@ 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.pkgsCross.ghcjs.haskell-nix.project { pkgs.haskell-nix.project { projectFileName = "cabal.project"; src = pkgs.haskell-nix.haskellLib.cleanGit { diff --git a/nix/sources.json b/nix/sources.json index 40cb6d790..e8393e221 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -5,10 +5,10 @@ "homepage": "https://input-output-hk.github.io/haskell.nix", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "166d280952e5f1791ce5aebc995a3525f7174e4b", - "sha256": "0q4xjdck74jp6dhyf0g0flj4fhs59rhcyslklfwmfhbq8afbqprn", + "rev": "564458fc4080c0fc51e316d74c3dbb68639ea839", + "sha256": "0d7kp3sqw8zhp4sv5awla6ch15mbndmr3640y3pwlvkcb59p8amm", "type": "tarball", - "url": "https://github.com/input-output-hk/haskell.nix/archive/166d280952e5f1791ce5aebc995a3525f7174e4b.tar.gz", + "url": "https://github.com/input-output-hk/haskell.nix/archive/564458fc4080c0fc51e316d74c3dbb68639ea839.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "niv": { From 0a2709b7a62c75ab54a001ead2241595a8d51846 Mon Sep 17 00:00:00 2001 From: Peter Becich Date: Sat, 6 Nov 2021 02:05:43 -0700 Subject: [PATCH 6/6] test --- default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/default.nix b/default.nix index e8dc2e63e..b079a9792 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,7 @@ # https://input-output-hk.github.io/haskell.nix/tutorials/getting-started/ { compiler ? "ghc865", - # ghcjs ? "ghcjs", + ghcjsVersion ? "8.6.0.0.10", + ghcVersion ? "8.6.5", withCoverage ? false }: let @@ -22,8 +23,9 @@ ]; in - pkgs.haskell-nix.project { - projectFileName = "cabal.project"; + pkgs.haskell-nix.ghcjsProject { + # projectFileName = "cabal.project"; + ghcjsVersion = "8.6.0.0.10"; src = pkgs.haskell-nix.haskellLib.cleanGit { name = "codeworld"; src = ./.;