From 2cc29082ef35d10568482ec32843775616f6b731 Mon Sep 17 00:00:00 2001 From: zeme Date: Mon, 23 Oct 2023 15:53:17 +0200 Subject: [PATCH 1/5] Bump IOGX v4 --- doc/default.nix | 23 -- flake.lock | 252 +++++++++++------- flake.nix | 38 ++- nix/cabal-project.nix | 11 - nix/ci.nix | 12 - .../easy-purescript-nix.nix | 2 +- nix/formatters.nix | 10 - nix/generated-purescript.nix | 15 ++ nix/haskell.nix | 6 - nix/marlowe-playground-client.nix | 73 +++++ .../generated-purescript.nix | 15 -- .../marlowe-playground-client.nix | 55 ---- nix/npm-deps-hash.nix | 2 + nix/{marlowe-playground => }/oci-images.nix | 10 +- nix/{marlowe-playground => }/operables.nix | 18 +- nix/outputs.nix | 26 ++ nix/per-system-outputs.nix | 18 -- nix/{marlowe-playground => }/playwright.nix | 2 +- nix/project.nix | 36 +++ nix/{marlowe-playground => }/scripts.nix | 20 +- nix/shell.nix | 47 ++-- .../spago-packages.nix | 0 package-lock.json | 6 + 23 files changed, 398 insertions(+), 299 deletions(-) delete mode 100644 doc/default.nix delete mode 100644 nix/cabal-project.nix delete mode 100644 nix/ci.nix rename nix/{marlowe-playground => }/easy-purescript-nix.nix (79%) delete mode 100644 nix/formatters.nix create mode 100644 nix/generated-purescript.nix delete mode 100644 nix/haskell.nix create mode 100644 nix/marlowe-playground-client.nix delete mode 100644 nix/marlowe-playground/generated-purescript.nix delete mode 100644 nix/marlowe-playground/marlowe-playground-client.nix create mode 100644 nix/npm-deps-hash.nix rename nix/{marlowe-playground => }/oci-images.nix (73%) rename nix/{marlowe-playground => }/operables.nix (67%) create mode 100644 nix/outputs.nix delete mode 100644 nix/per-system-outputs.nix rename nix/{marlowe-playground => }/playwright.nix (91%) create mode 100644 nix/project.nix rename nix/{marlowe-playground => }/scripts.nix (58%) rename {marlowe-playground-client => nix}/spago-packages.nix (100%) create mode 100644 package-lock.json diff --git a/doc/default.nix b/doc/default.nix deleted file mode 100644 index 3a278421a0..0000000000 --- a/doc/default.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ stdenv, lib, pythonPackages, sphinxcontrib-domaintools, sphinxcontrib-haddock, sphinx-markdown-tables, sphinxemoji, combined-haddock, ... }: -stdenv.mkDerivation { - name = "plutus-docs"; - src = lib.sourceFilesBySuffices ./. [ ".py" ".rst" ".hs" ".png" ".svg" ".bib" ".csv" ".css" ]; - buildInputs = with pythonPackages; [ - sphinx - sphinx_rtd_theme - sphinxcontrib-domaintools - sphinxcontrib-haddock - sphinx-markdown-tables - sphinxcontrib_plantuml - sphinxcontrib-bibtex - sphinxemoji - recommonmark - ]; - buildPhase = '' - cp -aR ${combined-haddock}/share/doc haddock - # -n gives warnings on missing link targets, -W makes warnings into errors - SPHINX_HADDOCK_DIR=haddock sphinx-build -n -W . $out - cp -aR haddock $out - ''; - dontInstall = true; -} diff --git a/flake.lock b/flake.lock index f22ff80cb4..d5f5f47bb9 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1692114433, - "narHash": "sha256-l6UoBkt1SUUBga/u0qpQeuNTN2YgtdZMBJSw29Wb0xU=", + "lastModified": 1698052958, + "narHash": "sha256-n77qAwa5ys02NOaLsexr3Vzk/9zBX2fbXRNyIUajY4c=", "owner": "input-output-hk", "repo": "cardano-haskell-packages", - "rev": "73093fde5e26b9f7594a2219d339175005256475", + "rev": "91265f62467228f8a8e58bfdfe3a683f5a24cee9", "type": "github" }, "original": { @@ -183,11 +183,11 @@ "flake-utils": "flake-utils" }, "locked": { - "lastModified": 1689933391, - "narHash": "sha256-jUuy2OzmxegEn0KT3u1uf87eGGA33+of9HodIqS3PLY=", + "lastModified": 1696584097, + "narHash": "sha256-a9Hhqf/Fi0FkjRTcQr3pYDhrO9A9tdOkaeVgD23Cdrk=", "owner": "justinwoo", "repo": "easy-purescript-nix", - "rev": "5dcea83eecb56241ed72e3631d47e87bb11e45b9", + "rev": "d5fe5f4b210a0e4bac42ae0c159596a49c5eb016", "type": "github" }, "original": { @@ -252,11 +252,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "owner": "numtide", "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "type": "github" }, "original": { @@ -266,22 +266,6 @@ } }, "flake-utils_3": { - "locked": { - "lastModified": 1679360468, - "narHash": "sha256-LGnza3cfXF10Biw3ZTg0u9o9t7s680Ww200t5KkHTh8=", - "owner": "hamishmack", - "repo": "flake-utils", - "rev": "e1ea268ff47ad475443dbabcd54744b4e5b9d4f5", - "type": "github" - }, - "original": { - "owner": "hamishmack", - "ref": "hkm/nested-hydraJobs", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_4": { "inputs": { "systems": "systems_3" }, @@ -299,7 +283,7 @@ "type": "github" } }, - "flake-utils_5": { + "flake-utils_4": { "locked": { "lastModified": 1653893745, "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", @@ -331,6 +315,43 @@ "type": "github" } }, + "ghc98X": { + "flake": false, + "locked": { + "lastModified": 1696643148, + "narHash": "sha256-E02DfgISH7EvvNAu0BHiPvl1E5FGMDi0pWdNZtIBC9I=", + "ref": "ghc-9.8", + "rev": "443e870d977b1ab6fc05f47a9a17bc49296adbd6", + "revCount": 61642, + "submodules": true, + "type": "git", + "url": "https://gitlab.haskell.org/ghc/ghc" + }, + "original": { + "ref": "ghc-9.8", + "submodules": true, + "type": "git", + "url": "https://gitlab.haskell.org/ghc/ghc" + } + }, + "ghc99": { + "flake": false, + "locked": { + "lastModified": 1697054644, + "narHash": "sha256-kKarOuXUaAH3QWv7ASx+gGFMHaHKe0pK5Zu37ky2AL4=", + "ref": "refs/heads/master", + "rev": "f383a242c76f90bcca8a4d7ee001dcb49c172a9a", + "revCount": 62040, + "submodules": true, + "type": "git", + "url": "https://gitlab.haskell.org/ghc/ghc" + }, + "original": { + "submodules": true, + "type": "git", + "url": "https://gitlab.haskell.org/ghc/ghc" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -356,11 +377,11 @@ "hackage": { "flake": false, "locked": { - "lastModified": 1692318155, - "narHash": "sha256-e4npK3xeIIIzq1MDFYhpT3cR37DtEttOdGE7uFi71PQ=", + "lastModified": 1698020746, + "narHash": "sha256-/eFVtqLu4sGfjJiwmelfH2qK0ZGFOmyCxBTJ1ncOeSI=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "0a259b13134e5ac7f9ca408365fd240bd4b42645", + "rev": "dc3cf3bbc0b1e9780e008f9cd6af4a9aeb344ad7", "type": "github" }, "original": { @@ -369,40 +390,6 @@ "type": "github" } }, - "haskell-language-server-1_8_0_0": { - "flake": false, - "locked": { - "lastModified": 1663402129, - "narHash": "sha256-El5wZDn0br/My7cxstRzUyO7VUf1q5V44T55NEQONnI=", - "owner": "haskell", - "repo": "haskell-language-server", - "rev": "855a88238279b795634fa6144a4c0e8acc7e9644", - "type": "github" - }, - "original": { - "owner": "haskell", - "repo": "haskell-language-server", - "rev": "855a88238279b795634fa6144a4c0e8acc7e9644", - "type": "github" - } - }, - "haskell-language-server-1_9_0_0": { - "flake": false, - "locked": { - "lastModified": 1672051165, - "narHash": "sha256-j3XRQTWa7jsVlimaxFZNnlE9IzWII9Prj1/+otks5FQ=", - "owner": "haskell", - "repo": "haskell-language-server", - "rev": "1916b5782d9f3204d25a1d8f94da4cfd83ae2607", - "type": "github" - }, - "original": { - "owner": "haskell", - "repo": "haskell-language-server", - "rev": "1916b5782d9f3204d25a1d8f94da4cfd83ae2607", - "type": "github" - } - }, "haskell-nix": { "inputs": { "HTTP": "HTTP", @@ -411,19 +398,21 @@ "cabal-36": "cabal-36", "cardano-shell": "cardano-shell", "flake-compat": "flake-compat", - "flake-utils": "flake-utils_3", "ghc-8.6.5-iohk": "ghc-8.6.5-iohk", + "ghc98X": "ghc98X", + "ghc99": "ghc99", "hackage": [ - "iogx", "hackage" ], "hls-1.10": "hls-1.10", "hls-2.0": "hls-2.0", + "hls-2.2": "hls-2.2", + "hls-2.3": "hls-2.3", + "hls-2.4": "hls-2.4", "hpc-coveralls": "hpc-coveralls", "hydra": "hydra", "iserv-proxy": "iserv-proxy", "nixpkgs": [ - "iogx", "haskell-nix", "nixpkgs-unstable" ], @@ -438,11 +427,11 @@ "stackage": "stackage" }, "locked": { - "lastModified": 1692319830, - "narHash": "sha256-KD5SPPtJETa83lWr5WwhWWRbSelGhGSkeZ7cqweJfoc=", + "lastModified": 1698022192, + "narHash": "sha256-qf8o096ErY5hJPdWqk8fmJqtXB5qsm35f2kOEmvQM3o=", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "90e45988f1ad35d55e890cef16d7b1a5de5e6196", + "rev": "c390991becb2a45a0963274e7924d3deaefcea29", "type": "github" }, "original": { @@ -504,6 +493,57 @@ "type": "github" } }, + "hls-2.2": { + "flake": false, + "locked": { + "lastModified": 1693064058, + "narHash": "sha256-8DGIyz5GjuCFmohY6Fa79hHA/p1iIqubfJUTGQElbNk=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "b30f4b6cf5822f3112c35d14a0cba51f3fe23b85", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.2.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.3": { + "flake": false, + "locked": { + "lastModified": 1695910642, + "narHash": "sha256-tR58doOs3DncFehHwCLczJgntyG/zlsSd7DgDgMPOkI=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "458ccdb55c9ea22cd5d13ec3051aaefb295321be", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.3.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, + "hls-2.4": { + "flake": false, + "locked": { + "lastModified": 1696939266, + "narHash": "sha256-VOMf5+kyOeOmfXTHlv4LNFJuDGa7G3pDnOxtzYR40IU=", + "owner": "haskell", + "repo": "haskell-language-server", + "rev": "362fdd1293efb4b82410b676ab1273479f6d17ee", + "type": "github" + }, + "original": { + "owner": "haskell", + "ref": "2.4.0.0", + "repo": "haskell-language-server", + "type": "github" + } + }, "hpc-coveralls": { "flake": false, "locked": { @@ -524,7 +564,6 @@ "inputs": { "nix": "nix", "nixpkgs": [ - "iogx", "haskell-nix", "hydra", "nix", @@ -568,28 +607,30 @@ }, "iogx": { "inputs": { - "CHaP": "CHaP", + "CHaP": [ + "CHaP" + ], "easy-purescript-nix": "easy-purescript-nix", "flake-utils": "flake-utils_2", - "hackage": "hackage", - "haskell-language-server-1_8_0_0": "haskell-language-server-1_8_0_0", - "haskell-language-server-1_9_0_0": "haskell-language-server-1_9_0_0", - "haskell-nix": "haskell-nix", + "hackage": [ + "hackage" + ], + "haskell-nix": [ + "haskell-nix" + ], "iohk-nix": "iohk-nix", "nixpkgs": [ - "iogx", - "haskell-nix", - "nixpkgs-2305" + "nixpkgs" ], "pre-commit-hooks-nix": "pre-commit-hooks-nix", "sphinxcontrib-haddock": "sphinxcontrib-haddock" }, "locked": { - "lastModified": 1693312063, - "narHash": "sha256-YHbFsI809plXJVJdC3spTggAuizeJaMKM+xiPJZ0qRs=", + "lastModified": 1698065888, + "narHash": "sha256-5MC+MsarxLwlJsI+Rwm29OfNL/ph4aqiNRWBZ9sB1wM=", "owner": "input-output-hk", "repo": "iogx", - "rev": "2e851fb87acd46e67643019db6f8a2bb669e95fb", + "rev": "81476eb708f525324050f03cd1cf064ba80e02fc", "type": "github" }, "original": { @@ -609,11 +650,11 @@ "sodium": "sodium" }, "locked": { - "lastModified": 1691469905, - "narHash": "sha256-TV0p1dFGYAMl1dLJEfe/tNFjxvV2H7VgHU1I43q+b84=", + "lastModified": 1696445248, + "narHash": "sha256-2B/fqwyaRAaHVmkf15tKwkFbL5O46TmMw+Rc2viUPEY=", "owner": "input-output-hk", "repo": "iohk-nix", - "rev": "2f3760f135616ebc477d3ed74eba9b63c22f83a0", + "rev": "e32040e84180b3c27c0f13587025f6a17a4da520", "type": "github" }, "original": { @@ -625,11 +666,11 @@ "iserv-proxy": { "flake": false, "locked": { - "lastModified": 1688517130, - "narHash": "sha256-hUqfxSlo+ffqVdkSZ1EDoB7/ILCL25eYkcCXW9/P3Wc=", + "lastModified": 1691634696, + "narHash": "sha256-MZH2NznKC/gbgBu8NgIibtSUZeJ00HTLJ0PlWKCBHb0=", "ref": "hkm/remote-iserv", - "rev": "9151db2a9a61d7f5fe52ff8836f18bbd0fd8933c", - "revCount": 13, + "rev": "43a979272d9addc29fbffc2e8542c5d96e993d73", + "revCount": 14, "type": "git", "url": "https://gitlab.haskell.org/hamishmack/iserv-proxy.git" }, @@ -657,7 +698,7 @@ }, "n2c": { "inputs": { - "flake-utils": "flake-utils_5", + "flake-utils": "flake-utils_4", "nixpkgs": "nixpkgs_3" }, "locked": { @@ -793,11 +834,11 @@ }, "nixpkgs-2305": { "locked": { - "lastModified": 1690680713, - "narHash": "sha256-NXCWA8N+GfSQyoN7ZNiOgq/nDJKOp5/BHEpiZP8sUZw=", + "lastModified": 1695416179, + "narHash": "sha256-610o1+pwbSu+QuF3GE0NU5xQdTHM3t9wyYhB9l94Cd8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b81af66deb21f73a70c67e5ea189568af53b1e8c", + "rev": "715d72e967ec1dd5ecc71290ee072bcaf5181ed6", "type": "github" }, "original": { @@ -841,11 +882,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1690720142, - "narHash": "sha256-GywuiZjBKfFkntQwpNQfL+Ksa2iGjPprBGL0/psgRZM=", + "lastModified": 1695318763, + "narHash": "sha256-FHVPDRP2AfvsxAdc+AsgFJevMz5VBmnZglFUMlxBkcY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3acb5c4264c490e7714d503c7166a3fde0c51324", + "rev": "e12483116b3b51a185a33a272bf351e357ba9a99", "type": "github" }, "original": { @@ -1012,17 +1053,17 @@ "pre-commit-hooks-nix": { "inputs": { "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_4", + "flake-utils": "flake-utils_3", "gitignore": "gitignore", "nixpkgs": "nixpkgs_2", "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1692274144, - "narHash": "sha256-BxTQuRUANQ81u8DJznQyPmRsg63t4Yc+0kcyq6OLz8s=", + "lastModified": 1696846637, + "narHash": "sha256-0hv4kbXxci2+pxhuXlVgftj/Jq79VSmtAyvfabCCtYk=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "7e3517c03d46159fdbf8c0e5c97f82d5d4b0c8fa", + "rev": "42e1b6095ef80a51f79595d9951eb38e91c4e6ca", "type": "github" }, "original": { @@ -1033,8 +1074,15 @@ }, "root": { "inputs": { + "CHaP": "CHaP", + "hackage": "hackage", + "haskell-nix": "haskell-nix", "iogx": "iogx", "n2c": "n2c", + "nixpkgs": [ + "haskell-nix", + "nixpkgs" + ], "npmlock2nix": "npmlock2nix", "std": "std" } @@ -1092,11 +1140,11 @@ "stackage": { "flake": false, "locked": { - "lastModified": 1692317324, - "narHash": "sha256-AofEuurJHrfMljrCAkMKTWBC5xGluhBZiAfHQ73224Y=", + "lastModified": 1698019774, + "narHash": "sha256-MXoKr4WS/wG/RA9VOiHH26dYOraZ1q8QayeA0rpfQUU=", "owner": "input-output-hk", "repo": "stackage.nix", - "rev": "4812a420235589a74f9278cca81f6dbf74ffb42f", + "rev": "87572456de828c621db6fc4082a93e34413e1d5d", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 60e0b754c5..100a93c6b4 100644 --- a/flake.nix +++ b/flake.nix @@ -1,13 +1,33 @@ -# This file is part of the IOGX template and is documented at the link below: -# https://www.github.com/input-output-hk/iogx#31-flakenix - { description = "Marlowe Playground"; inputs = { - iogx.url = "github:input-output-hk/iogx"; + iogx = { + url = "github:input-output-hk/iogx"; + inputs.hackage.follows = "hackage"; + inputs.CHaP.follows = "CHaP"; + inputs.haskell-nix.follows = "haskell-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + nixpkgs.follows = "haskell-nix/nixpkgs"; + + hackage = { + url = "github:input-output-hk/hackage.nix"; + flake = false; + }; + + CHaP = { + url = "github:input-output-hk/cardano-haskell-packages?ref=repo"; + flake = false; + }; + + haskell-nix = { + url = "github:input-output-hk/haskell.nix"; + inputs.hackage.follows = "hackage"; + }; n2c.url = "github:nlewo/nix2container"; @@ -24,14 +44,8 @@ outputs = inputs: inputs.iogx.lib.mkFlake { inherit inputs; repoRoot = ./.; - nixpkgsConfig = { - permittedInsecurePackages = [ - # These is required by SASS, which we should move away from! - "python-2.7.18.6" - "nodejs-14.21.3" - "openssl-1.1.1u" - ]; - }; + systems = [ "x86_64-linux" "x86_64-darwin" ]; + outputs = import ./nix/outputs.nix; }; diff --git a/nix/cabal-project.nix b/nix/cabal-project.nix deleted file mode 100644 index a5990a7923..0000000000 --- a/nix/cabal-project.nix +++ /dev/null @@ -1,11 +0,0 @@ -# This file is part of the IOGX template and is documented at the link below: -# https://www.github.com/input-output-hk/iogx#33-nixcabal-projectnix - -{ - modules = [{ - packages.marlowe-symbolic.ghcOptions = [ "-Werror" ]; - packages.marlowe-playground-server.ghcOptions = [ "-Werror" ]; - packages.plutus-script-utils.ghcOptions = [ "-Wwarn" "-Wno-unused-packages" ]; - }]; -} - diff --git a/nix/ci.nix b/nix/ci.nix deleted file mode 100644 index 9ccc46e8a9..0000000000 --- a/nix/ci.nix +++ /dev/null @@ -1,12 +0,0 @@ -# This file is part of the IOGX template and is documented at the link below: -# https://www.github.com/input-output-hk/iogx#39-nixcinix - -{ pkgs, lib, ... }: - -{ - includedPaths = lib.optionals pkgs.stdenv.hostPlatform.isLinux [ - "oci-images" - "operables" - "playwright" - ]; -} diff --git a/nix/marlowe-playground/easy-purescript-nix.nix b/nix/easy-purescript-nix.nix similarity index 79% rename from nix/marlowe-playground/easy-purescript-nix.nix rename to nix/easy-purescript-nix.nix index f93151e075..f2aee797e9 100644 --- a/nix/marlowe-playground/easy-purescript-nix.nix +++ b/nix/easy-purescript-nix.nix @@ -1,4 +1,4 @@ -{ inputs, pkgs, system, ... }: +{ repoRoot, inputs, pkgs, system, lib }: let easy-purescript-nix = pkgs.callPackage inputs.iogx.inputs.easy-purescript-nix { }; in diff --git a/nix/formatters.nix b/nix/formatters.nix deleted file mode 100644 index dfefb7a4d5..0000000000 --- a/nix/formatters.nix +++ /dev/null @@ -1,10 +0,0 @@ -# This file is part of the IOGX template and is documented at the link below: -# https://www.github.com/input-output-hk/iogx#38-nixformattersnix - -{ - shellcheck.enable = true; - stylish-haskell.enable = false; - nixpkgs-fmt.enable = true; - prettier.enable = true; - purs-tidy.enable = true; -} diff --git a/nix/generated-purescript.nix b/nix/generated-purescript.nix new file mode 100644 index 0000000000..d0f45a5fe0 --- /dev/null +++ b/nix/generated-purescript.nix @@ -0,0 +1,15 @@ +{ repoRoot, inputs, pkgs, system, lib }: + +# Output containing the purescript bridge code +pkgs.runCommand "generated-purescript" { } '' + mkdir $out + ${inputs.self.packages.marlowe-playground-server}/bin/marlowe-playground-server psgenerator $out + cp ${builtins.path { name = "tidyrc.json"; path = inputs.self + "/.tidyrc.json"; } } $out/.tidyrc.json + cp ${builtins.path { name = "tidyoperators"; path = inputs.self + "/.tidyoperators"; } } $out/.tidyoperators + cd $out + ${repoRoot.nix.easy-purescript-nix.purs-tidy}/bin/purs-tidy format-in-place * + ${pkgs.nodePackages.prettier}/bin/prettier -w . + rm -f $out/.tidyrc.json + rm -f $out/.tidyoperators +'' + diff --git a/nix/haskell.nix b/nix/haskell.nix deleted file mode 100644 index e515595dca..0000000000 --- a/nix/haskell.nix +++ /dev/null @@ -1,6 +0,0 @@ -# This file is part of the IOGX template and is documented at the link below: -# https://www.github.com/input-output-hk/iogx#32-nixhaskellnix - -{ - supportedCompilers = [ "ghc8107" ]; -} diff --git a/nix/marlowe-playground-client.nix b/nix/marlowe-playground-client.nix new file mode 100644 index 0000000000..e0c7aba6e7 --- /dev/null +++ b/nix/marlowe-playground-client.nix @@ -0,0 +1,73 @@ +{ repoRoot, inputs, pkgs, system, lib }: + +let + spago-pkgs = import ./spago-packages.nix { inherit pkgs; }; +in + +pkgs.buildNpmPackage { + + pname = "marlowe-playground-client"; + + version = "0.1.0"; + + src = lib.sourceByRegex (inputs.self + /marlowe-playground-client) [ + "^prototype.*" + "^generated.*" + "^src.*" + "^static.*" + "^test.*" + "^entry.*" + "^grammar.ne$" + "^package.*" + "^postcss.*" + "^spago.*" + "^tailwind.*" + "^tsconfig.*" + "^webpack.*" + ]; + + dontNpmBuild = true; + dontNpmInstall = true; + + # buildNpmPackage is able to make a pure nix build by using npmDepsHash. + # That is the hash of package-lock.json. + # Its value is generated using the prefetch-npm-deps command (see shell.nix). + # We set dontNpmBuild and dontNpmInstall to true to significantly speed up the + # build: this works because we have a custom buildPhase that invokes webpack-cli + # explicitely. + npmDepsHash = import ./npm-deps-hash.nix; + + nativeBuildInputs = [ + spago-pkgs.installSpagoStyle + spago-pkgs.buildSpagoStyle + repoRoot.nix.easy-purescript-nix.purs + repoRoot.nix.easy-purescript-nix.spago2nix + pkgs.nodejs_18 + pkgs.nodejs_18.pkgs.webpack + pkgs.nodejs_18.pkgs.webpack-cli + ]; + + buildPhase = '' + mkdir -p {marlowe-playground-client,web-common-marlowe,web-common} + + cp -r $src/* marlowe-playground-client + cp -r ${inputs.self + "/web-common-marlowe"}/* web-common-marlowe + cp -r ${inputs.self + "/web-common"}/* web-common + + cd marlowe-playground-client + + install-spago-style + + build-spago-style \ + "./src/**/*.purs" \ + "./generated/**/*.purs" \ + "../web-common-marlowe/src/**/*.purs" \ + "../web-common/src/**/*.purs" + + npm run build:webpack:prod + + mkdir -p $out/share/marlowe-playground-client/static + + cp -r dist $out/share/marlowe-playground-client/static + ''; +} diff --git a/nix/marlowe-playground/generated-purescript.nix b/nix/marlowe-playground/generated-purescript.nix deleted file mode 100644 index 7922dd50fd..0000000000 --- a/nix/marlowe-playground/generated-purescript.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ repoRoot, pkgs, inputs', ... }: - -# Output containing the purescript bridge code -pkgs.runCommand "generated-purescript" { } '' - mkdir $out - ${inputs'.self.packages.marlowe-playground-server}/bin/marlowe-playground-server psgenerator $out - cp ${builtins.path { name = "tidyrc.json"; path = inputs'.self + "/.tidyrc.json"; } } $out/.tidyrc.json - cp ${builtins.path { name = "tidyoperators"; path = inputs'.self + "/.tidyoperators"; } } $out/.tidyoperators - cd $out - ${repoRoot.nix.marlowe-playground.easy-purescript-nix.purs-tidy}/bin/purs-tidy format-in-place * - ${pkgs.nodePackages.prettier}/bin/prettier -w . - rm -f $out/.tidyrc.json - rm -f $out/.tidyoperators -'' - diff --git a/nix/marlowe-playground/marlowe-playground-client.nix b/nix/marlowe-playground/marlowe-playground-client.nix deleted file mode 100644 index 99140232ac..0000000000 --- a/nix/marlowe-playground/marlowe-playground-client.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ repoRoot, inputs, pkgs, ... }: - -let - npmlock2nix = import inputs.npmlock2nix { inherit pkgs; }; - - spagoPkgs = import (inputs.self + "/marlowe-playground-client/spago-packages.nix") { inherit pkgs; }; -in - -npmlock2nix.v1.build { - src = inputs.self + "/marlowe-playground-client"; - installPhase = '' - mkdir -p $out/share/marlowe-playground-client/ - cp -r dist $out/share/marlowe-playground-client/static - ''; - node_modules_attrs = { - githubSourceHashMap = { - shmish111.nearley-webpack-loader."939360f9d1bafa9019b6ff8739495c6c9101c4a1" = "1brx669dgsryakf7my00m25xdv7a02snbwzhzgc9ylmys4p8c10x"; - ankitrohatgi.tarballjs."64ea5eb78f7fc018a223207e67f4f863fcc5d3c5" = "04r9yap0ka4y3yirg0g7xb63mq7jzc2qbgswbixxj8s60k6zdqsm"; - }; - buildInputs = [ pkgs.python ]; - }; - buildInputs = [ - spagoPkgs.installSpagoStyle - spagoPkgs.buildSpagoStyle - pkgs.nodejs-14_x - repoRoot.nix.marlowe-playground.easy-purescript-nix.purs - repoRoot.nix.marlowe-playground.easy-purescript-nix.spago2nix - ]; - unpackPhase = '' - mkdir -p marlowe-playground-client - cp -r $src/* marlowe-playground-client - - mkdir -p web-common-marlowe - cp -r ${inputs.self + "/web-common-marlowe"}/* web-common-marlowe - - mkdir -p web-common - cp -r ${inputs.self + "/web-common"}/* web-common - - cd marlowe-playground-client - install-spago-style - cd .. - ''; - buildCommands = [ - '' - cd marlowe-playground-client - build-spago-style \ - "./src/**/*.purs" \ - "./generated/**/*.purs" \ - "../web-common-marlowe/src/**/*.purs" \ - "../web-common/src/**/*.purs" - rm -rf ./dist - npm run build:webpack:prod - '' - ]; -} diff --git a/nix/npm-deps-hash.nix b/nix/npm-deps-hash.nix new file mode 100644 index 0000000000..21835d3630 --- /dev/null +++ b/nix/npm-deps-hash.nix @@ -0,0 +1,2 @@ +# This file was generated by prefetch-npm-deps +"" diff --git a/nix/marlowe-playground/oci-images.nix b/nix/oci-images.nix similarity index 73% rename from nix/marlowe-playground/oci-images.nix rename to nix/oci-images.nix index 24bda7ee4d..0f7237d7d6 100644 --- a/nix/marlowe-playground/oci-images.nix +++ b/nix/oci-images.nix @@ -1,12 +1,12 @@ -{ inputs', pkgs, lib, ... }: +{ repoRoot, inputs, pkgs, system, lib }: let - inherit (inputs'.std.lib.ops) mkStandardOCI; + inherit (inputs.std.lib.ops) mkStandardOCI; mkImage = { name, description }: mkStandardOCI { inherit name; # meta.tags = [ "latest" ]; - operable = inputs'.self.operables.${name}; + operable = inputs.self.operables.${name}; uid = "0"; gid = "0"; labels = { @@ -32,10 +32,10 @@ let in images // { all = { - copyToDockerDaemon = inputs'.std.lib.ops.writeScript { + copyToDockerDaemon = inputs.std.lib.ops.writeScript { name = "copy-to-docker-daemon"; text = forAllImages (name: img: - "${inputs'.n2c.packages.skopeo-nix2container}/bin/skopeo --insecure-policy copy nix:${img} docker-daemon:${name}:latest" + "${inputs.n2c.packages.skopeo-nix2container}/bin/skopeo --insecure-policy copy nix:${img} docker-daemon:${name}:latest" ); }; }; diff --git a/nix/marlowe-playground/operables.nix b/nix/operables.nix similarity index 67% rename from nix/marlowe-playground/operables.nix rename to nix/operables.nix index 2728a56fac..ef97399d93 100644 --- a/nix/marlowe-playground/operables.nix +++ b/nix/operables.nix @@ -1,26 +1,22 @@ -{ inputs', pkgs, ... }: - -project: +{ repoRoot, inputs, pkgs, system, lib }: let inherit (pkgs) darkhttpd lib mailcap coreutils cacert z3; - inherit (inputs'.std.lib.ops) mkOperable; - - ghc-with-marlowe = project.ghcWithPackages (pkgs: [ pkgs.marlowe-cardano ]); + inherit (inputs.std.lib.ops) mkOperable; in { marlowe-playground-client = mkOperable { - package = inputs'.self.packages.marlowe-playground-client; + package = inputs.self.packages.marlowe-playground-client; runtimeInputs = [ darkhttpd ]; runtimeScript = '' - exec darkhttpd "''${CONFIG_HTML_ROOT:-${inputs'.self.packages.marlowe-playground-client}}" --port 8080 --mimetypes ${mailcap}/etc/mime.types + exec darkhttpd "''${CONFIG_HTML_ROOT:-${inputs.self.packages.marlowe-playground-client}}" --port 8080 --mimetypes ${mailcap}/etc/mime.types ''; }; marlowe-playground-server = mkOperable { - package = inputs'.self.packages.marlowe-playground-server; - runtimeInputs = [ ghc-with-marlowe coreutils cacert z3 ]; + package = inputs.self.packages.marlowe-playground-server; + runtimeInputs = [ inputs.self.packages.ghc-with-marlowe coreutils cacert z3 ]; runtimeScript = '' ################# # REQUIRED VARS # @@ -46,7 +42,7 @@ in mkdir -p /tmp - ${inputs'.self.packages.marlowe-playground-server}/bin/marlowe-playground-server webserver + ${inputs.self.packages.marlowe-playground-server}/bin/marlowe-playground-server webserver ''; }; } diff --git a/nix/outputs.nix b/nix/outputs.nix new file mode 100644 index 0000000000..9cb11c5e70 --- /dev/null +++ b/nix/outputs.nix @@ -0,0 +1,26 @@ +{ repoRoot, inputs, pkgs, system, lib }: +let + project = repoRoot.nix.project; +in +[ + ( + project.flake + ) + + { + packages.generated-purescript = repoRoot.nix.generated-purescript; + packages.marlowe-playground-client = repoRoot.nix.marlowe-playground-client; + packages.ghc-with-marlowe = project.cabalProject.ghcWithPackages (pkgs: [ pkgs.marlowe-cardano ]); + + playwright = repoRoot.nix.playwright; + operables = repoRoot.nix.operables; + oci-images = repoRoot.nix.oci-images; + + hydraJobs.operables = repoRoot.nix.operables; + hydraJobs.oci-images = repoRoot.nix.oci-images; + } + + (lib.optionalAttrs (system == "x86_64-linux") { + hydraJobs.playwright = repoRoot.nix.playwright; + }) +] diff --git a/nix/per-system-outputs.nix b/nix/per-system-outputs.nix deleted file mode 100644 index 20bb0634ec..0000000000 --- a/nix/per-system-outputs.nix +++ /dev/null @@ -1,18 +0,0 @@ -# This file is part of the IOGX template and is documented at the link below: -# https://www.github.com/input-output-hk/iogx#35-nixper-system-outputsnix - -{ repoRoot, haskellProjects, system, lib, ... }: - -{ - packages.generated-purescript = repoRoot.nix.marlowe-playground.generated-purescript; - - packages.marlowe-playground-client = repoRoot.nix.marlowe-playground.marlowe-playground-client; - - packages.ghc-with-marlowe = haskellProjects.default.ghcWithPackages (pkgs: [ pkgs.marlowe-cardano ]); - - playwright = lib.optionalAttrs (system == "x86_64-linux") repoRoot.nix.marlowe-playground.playwright; - - operables = repoRoot.nix.marlowe-playground.operables haskellProjects.default; - - oci-images = repoRoot.nix.marlowe-playground.oci-images; -} diff --git a/nix/marlowe-playground/playwright.nix b/nix/playwright.nix similarity index 91% rename from nix/marlowe-playground/playwright.nix rename to nix/playwright.nix index 21463a312b..ddf540126b 100644 --- a/nix/marlowe-playground/playwright.nix +++ b/nix/playwright.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ repoRoot, inputs, pkgs, system, lib }: let # extracted from "node_modules/playwright-core/browsers.json" diff --git a/nix/project.nix b/nix/project.nix new file mode 100644 index 0000000000..20f54d18c6 --- /dev/null +++ b/nix/project.nix @@ -0,0 +1,36 @@ +{ repoRoot, inputs, pkgs, system, lib }: + +let + + cabalProject = pkgs.haskell-nix.cabalProject' ({ config, pkgs, ... }: { + name = "marlowe-playground"; + + src = ../.; + + compiler-nix-name = "ghc8107"; + + shell.withHoogle = false; + + inputMap = { + "https://input-output-hk.github.io/cardano-haskell-packages" = inputs.iogx.inputs.CHaP; + }; + + modules = [{ + packages.marlowe-symbolic.ghcOptions = [ "-Werror" ]; + packages.marlowe-playground-server.ghcOptions = [ "-Werror" ]; + packages.plutus-script-utils.ghcOptions = [ "-Wwarn" "-Wno-unused-packages" ]; + }]; + }); + + + project = lib.iogx.mkHaskellProject { + inherit cabalProject; + shellArgs = repoRoot.nix.shell; + readTheDocs = { + enable = true; + siteFolder = "docs"; + }; + }; + +in +project diff --git a/nix/marlowe-playground/scripts.nix b/nix/scripts.nix similarity index 58% rename from nix/marlowe-playground/scripts.nix rename to nix/scripts.nix index 5e61a91e67..3ebe301d66 100644 --- a/nix/marlowe-playground/scripts.nix +++ b/nix/scripts.nix @@ -1,4 +1,4 @@ -{ repoRoot, ... }: +{ repoRoot, inputs, pkgs, system, lib }: { @@ -31,7 +31,23 @@ cd marlowe-playground-client - ${repoRoot.nix.marlowe-playground.easy-purescript-nix.spago2nix}/bin/spago2nix generate + ${repoRoot.nix.easy-purescript-nix.spago2nix}/bin/spago2nix generate + ''; + + + gen-nix-lockfiles = '' + repo_root="$(git rev-parse --show-toplevel)" + + nix_dir="$repo_root/nix" + mpc_dir="$repo_root/marlowe-playground-client" + + (cd "$mpc_dir" && spago2nix generate) + mv "$mpc_dir/spago-packages.nix" "$nix_dir" + + echo "# This file was generated by prefetch-npm-deps" > "$nix_dir/npm-deps-hash.nix" + echo "\"$(prefetch-npm-deps "$mpc_dir/package-lock.json")\"" >> $nix_dir/npm-deps-hash.nix + + nixpkgs-fmt "$nix_dir" ''; } diff --git a/nix/shell.nix b/nix/shell.nix index 0e52e3ef40..7c1086e32f 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -1,7 +1,6 @@ -# This file is part of the IOGX template and is documented at the link below: -# https://www.github.com/input-output-hk/iogx#34-nixshellnix +{ repoRoot, inputs, pkgs, system, lib }: -{ repoRoot, inputs', pkgs, lib, system, ... }: +_cabalProject: { name = "marlowe-playground"; @@ -10,39 +9,45 @@ env = { PLAYWRIGHT_BROWSERS_PATH = lib.optionalString (system == "x86_64-linux") - "${repoRoot.nix.marlowe-playground.playwright}"; + "${repoRoot.nix.playwright}"; PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "true"; }; scripts.generate-purescript = { - exec = repoRoot.nix.marlowe-playground.scripts.generate-purescript; + exec = repoRoot.nix.scripts.generate-purescript; description = "Generate all PureScript Bridge code"; group = "marlowe-playground"; }; scripts.update-client-deps = { - exec = repoRoot.nix.marlowe-playground.scripts.update-client-deps; + exec = repoRoot.nix.scripts.update-client-deps; description = "Run spago2nix in marlowe-playground-client"; group = "marlowe-playground"; }; scripts.start-backend = { - exec = repoRoot.nix.marlowe-playground.scripts.start-backend; + exec = repoRoot.nix.scripts.start-backend; description = "Start the Marlowe Playground server"; group = "marlowe-playground"; }; + scripts.gen-nix-lockfiles = { + exec = repoRoot.nix.scripts.gen-nix-lockfiles; + group = "marlowe-playground"; + description = "Run this whenever package-json.lock or packages.dhall change"; + }; + packages = [ - repoRoot.nix.marlowe-playground.easy-purescript-nix.purs-tidy - repoRoot.nix.marlowe-playground.easy-purescript-nix.purs - repoRoot.nix.marlowe-playground.easy-purescript-nix.spago - repoRoot.nix.marlowe-playground.easy-purescript-nix.spago2nix - repoRoot.nix.marlowe-playground.easy-purescript-nix.psa - repoRoot.nix.marlowe-playground.easy-purescript-nix.purescript-language-server - repoRoot.nix.marlowe-playground.easy-purescript-nix.pscid + repoRoot.nix.easy-purescript-nix.purs-tidy + repoRoot.nix.easy-purescript-nix.purs + repoRoot.nix.easy-purescript-nix.spago + repoRoot.nix.easy-purescript-nix.spago2nix + repoRoot.nix.easy-purescript-nix.psa + repoRoot.nix.easy-purescript-nix.purescript-language-server + repoRoot.nix.easy-purescript-nix.pscid pkgs.jq pkgs.yq @@ -51,7 +56,19 @@ pkgs.gawk pkgs.nil pkgs.z3 - pkgs.nodejs-14_x + pkgs.which + pkgs.python38 + pkgs.prefetch-npm-deps + pkgs.nodejs-18_x + pkgs.nodejs-18_x.pkgs.webpack + pkgs.nodejs-18_x.pkgs.webpack-cli ]; + preCommit = { + shellcheck.enable = true; + stylish-haskell.enable = false; + nixpkgs-fmt.enable = true; + prettier.enable = true; + purs-tidy.enable = true; + }; } diff --git a/marlowe-playground-client/spago-packages.nix b/nix/spago-packages.nix similarity index 100% rename from marlowe-playground-client/spago-packages.nix rename to nix/spago-packages.nix diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000000..c2b7a08ccd --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "marlowe-playground", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} From 5b9c3780d3c23850d87bd2de776a2da64d3db766 Mon Sep 17 00:00:00 2001 From: zeme Date: Fri, 27 Oct 2023 14:38:01 +0200 Subject: [PATCH 2/5] WIP --- flake.lock | 23 ++++++++++++++++++++--- flake.nix | 4 ++++ nix/marlowe-playground-client.nix | 6 +++--- nix/project.nix | 2 +- nix/scripts.nix | 9 --------- nix/shell.nix | 13 +++---------- 6 files changed, 31 insertions(+), 26 deletions(-) diff --git a/flake.lock b/flake.lock index d5f5f47bb9..af14f2f1b6 100644 --- a/flake.lock +++ b/flake.lock @@ -622,15 +622,16 @@ "nixpkgs": [ "nixpkgs" ], + "nixpkgs-with-working-prefetch-npm-deps": "nixpkgs-with-working-prefetch-npm-deps", "pre-commit-hooks-nix": "pre-commit-hooks-nix", "sphinxcontrib-haddock": "sphinxcontrib-haddock" }, "locked": { - "lastModified": 1698065888, - "narHash": "sha256-5MC+MsarxLwlJsI+Rwm29OfNL/ph4aqiNRWBZ9sB1wM=", + "lastModified": 1698409584, + "narHash": "sha256-zqY9WIjs6ELYbyRwDx2w0hAgsV27b6TiAlMkCAQzSJ4=", "owner": "input-output-hk", "repo": "iogx", - "rev": "81476eb708f525324050f03cd1cf064ba80e02fc", + "rev": "da8ab3dc6d1500d4fe0aefe8fb7331edb3d49231", "type": "github" }, "original": { @@ -896,6 +897,22 @@ "type": "github" } }, + "nixpkgs-with-working-prefetch-npm-deps": { + "locked": { + "lastModified": 1690680713, + "narHash": "sha256-NXCWA8N+GfSQyoN7ZNiOgq/nDJKOp5/BHEpiZP8sUZw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b81af66deb21f73a70c67e5ea189568af53b1e8c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b81af66deb21f73a70c67e5ea189568af53b1e8c", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1689261696, diff --git a/flake.nix b/flake.nix index 100a93c6b4..62151afb65 100644 --- a/flake.nix +++ b/flake.nix @@ -46,6 +46,10 @@ repoRoot = ./.; systems = [ "x86_64-linux" "x86_64-darwin" ]; outputs = import ./nix/outputs.nix; + nixpkgsArgs.config.permittedInsecurePackages = [ + "nodejs-14.21.3" + "openssl-1.1.1w" + ]; }; diff --git a/nix/marlowe-playground-client.nix b/nix/marlowe-playground-client.nix index e0c7aba6e7..bcab672928 100644 --- a/nix/marlowe-playground-client.nix +++ b/nix/marlowe-playground-client.nix @@ -42,9 +42,9 @@ pkgs.buildNpmPackage { spago-pkgs.buildSpagoStyle repoRoot.nix.easy-purescript-nix.purs repoRoot.nix.easy-purescript-nix.spago2nix - pkgs.nodejs_18 - pkgs.nodejs_18.pkgs.webpack - pkgs.nodejs_18.pkgs.webpack-cli + pkgs.nodejs_14 + pkgs.nodejs_14.pkgs.webpack + pkgs.nodejs_14.pkgs.webpack-cli ]; buildPhase = '' diff --git a/nix/project.nix b/nix/project.nix index 20f54d18c6..1aa1489dfa 100644 --- a/nix/project.nix +++ b/nix/project.nix @@ -28,7 +28,7 @@ let shellArgs = repoRoot.nix.shell; readTheDocs = { enable = true; - siteFolder = "docs"; + siteFolder = "doc"; }; }; diff --git a/nix/scripts.nix b/nix/scripts.nix index 3ebe301d66..56f7586454 100644 --- a/nix/scripts.nix +++ b/nix/scripts.nix @@ -26,15 +26,6 @@ ''; - update-client-deps = '' - cd "$(git rev-parse --show-toplevel)" - - cd marlowe-playground-client - - ${repoRoot.nix.easy-purescript-nix.spago2nix}/bin/spago2nix generate - ''; - - gen-nix-lockfiles = '' repo_root="$(git rev-parse --show-toplevel)" diff --git a/nix/shell.nix b/nix/shell.nix index 7c1086e32f..b120809a9a 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -21,12 +21,6 @@ _cabalProject: group = "marlowe-playground"; }; - scripts.update-client-deps = { - exec = repoRoot.nix.scripts.update-client-deps; - description = "Run spago2nix in marlowe-playground-client"; - group = "marlowe-playground"; - }; - scripts.start-backend = { exec = repoRoot.nix.scripts.start-backend; description = "Start the Marlowe Playground server"; @@ -57,11 +51,10 @@ _cabalProject: pkgs.nil pkgs.z3 pkgs.which - pkgs.python38 pkgs.prefetch-npm-deps - pkgs.nodejs-18_x - pkgs.nodejs-18_x.pkgs.webpack - pkgs.nodejs-18_x.pkgs.webpack-cli + pkgs.nodejs-14_x + pkgs.nodejs-14_x.pkgs.webpack + pkgs.nodejs-14_x.pkgs.webpack-cli ]; preCommit = { From a741d896f31ce926758f4c8cc678cf7d306f8a36 Mon Sep 17 00:00:00 2001 From: zeme Date: Fri, 27 Oct 2023 14:41:38 +0200 Subject: [PATCH 3/5] WIP --- nix/npm-deps-hash.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/npm-deps-hash.nix b/nix/npm-deps-hash.nix index 21835d3630..fab770acb8 100644 --- a/nix/npm-deps-hash.nix +++ b/nix/npm-deps-hash.nix @@ -1,2 +1,2 @@ # This file was generated by prefetch-npm-deps -"" +"sha256-SiGvaf/j6GhvZ/MUYpDm6qsTGCRxHFg0J+llPTU429E=" From 0e770c403c051cc9f4b24acfbf98b003321bd662 Mon Sep 17 00:00:00 2001 From: zeme Date: Thu, 2 Nov 2023 17:08:28 +0100 Subject: [PATCH 4/5] wip --- flake.nix | 1 + nix/marlowe-playground-client.nix | 100 ++++++++++++------------------ 2 files changed, 42 insertions(+), 59 deletions(-) diff --git a/flake.nix b/flake.nix index 62151afb65..e607cca539 100644 --- a/flake.nix +++ b/flake.nix @@ -49,6 +49,7 @@ nixpkgsArgs.config.permittedInsecurePackages = [ "nodejs-14.21.3" "openssl-1.1.1w" + "python-2.7.18.7" ]; }; diff --git a/nix/marlowe-playground-client.nix b/nix/marlowe-playground-client.nix index bcab672928..cccfcaec44 100644 --- a/nix/marlowe-playground-client.nix +++ b/nix/marlowe-playground-client.nix @@ -1,73 +1,55 @@ -{ repoRoot, inputs, pkgs, system, lib }: +{ repoRoot, inputs, pkgs, ... }: let - spago-pkgs = import ./spago-packages.nix { inherit pkgs; }; -in - -pkgs.buildNpmPackage { - - pname = "marlowe-playground-client"; - - version = "0.1.0"; - - src = lib.sourceByRegex (inputs.self + /marlowe-playground-client) [ - "^prototype.*" - "^generated.*" - "^src.*" - "^static.*" - "^test.*" - "^entry.*" - "^grammar.ne$" - "^package.*" - "^postcss.*" - "^spago.*" - "^tailwind.*" - "^tsconfig.*" - "^webpack.*" - ]; - - dontNpmBuild = true; - dontNpmInstall = true; + npmlock2nix = import inputs.npmlock2nix { inherit pkgs; }; - # buildNpmPackage is able to make a pure nix build by using npmDepsHash. - # That is the hash of package-lock.json. - # Its value is generated using the prefetch-npm-deps command (see shell.nix). - # We set dontNpmBuild and dontNpmInstall to true to significantly speed up the - # build: this works because we have a custom buildPhase that invokes webpack-cli - # explicitely. - npmDepsHash = import ./npm-deps-hash.nix; + spagoPkgs = import ./spago-packages.nix { inherit pkgs; }; +in - nativeBuildInputs = [ - spago-pkgs.installSpagoStyle - spago-pkgs.buildSpagoStyle +npmlock2nix.v1.build { + src = inputs.self + "/marlowe-playground-client"; + installPhase = '' + mkdir -p $out/share/marlowe-playground-client/ + cp -r dist $out/share/marlowe-playground-client/static + ''; + node_modules_attrs = { + githubSourceHashMap = { + shmish111.nearley-webpack-loader."939360f9d1bafa9019b6ff8739495c6c9101c4a1" = "1brx669dgsryakf7my00m25xdv7a02snbwzhzgc9ylmys4p8c10x"; + ankitrohatgi.tarballjs."64ea5eb78f7fc018a223207e67f4f863fcc5d3c5" = "04r9yap0ka4y3yirg0g7xb63mq7jzc2qbgswbixxj8s60k6zdqsm"; + }; + buildInputs = [ pkgs.python ]; + }; + buildInputs = [ + spagoPkgs.installSpagoStyle + spagoPkgs.buildSpagoStyle + pkgs.nodejs-14_x repoRoot.nix.easy-purescript-nix.purs repoRoot.nix.easy-purescript-nix.spago2nix - pkgs.nodejs_14 - pkgs.nodejs_14.pkgs.webpack - pkgs.nodejs_14.pkgs.webpack-cli ]; - - buildPhase = '' - mkdir -p {marlowe-playground-client,web-common-marlowe,web-common} - + unpackPhase = '' + mkdir -p marlowe-playground-client cp -r $src/* marlowe-playground-client + + mkdir -p web-common-marlowe cp -r ${inputs.self + "/web-common-marlowe"}/* web-common-marlowe + + mkdir -p web-common cp -r ${inputs.self + "/web-common"}/* web-common - cd marlowe-playground-client - + cd marlowe-playground-client install-spago-style - - build-spago-style \ - "./src/**/*.purs" \ - "./generated/**/*.purs" \ - "../web-common-marlowe/src/**/*.purs" \ - "../web-common/src/**/*.purs" - - npm run build:webpack:prod - - mkdir -p $out/share/marlowe-playground-client/static - - cp -r dist $out/share/marlowe-playground-client/static + cd .. ''; + buildCommands = [ + '' + cd marlowe-playground-client + build-spago-style \ + "./src/**/*.purs" \ + "./generated/**/*.purs" \ + "../web-common-marlowe/src/**/*.purs" \ + "../web-common/src/**/*.purs" + rm -rf ./dist + npm run build:webpack:prod + '' + ]; } From 17a49a42ced2a22df2ced54ae10c0510e70cf854 Mon Sep 17 00:00:00 2001 From: Hernan Rajchert Date: Wed, 8 Nov 2023 19:42:49 +0400 Subject: [PATCH 5/5] Update client readme --- marlowe-playground-client/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/marlowe-playground-client/README.md b/marlowe-playground-client/README.md index 21a8b26d8f..454c53a761 100644 --- a/marlowe-playground-client/README.md +++ b/marlowe-playground-client/README.md @@ -3,13 +3,15 @@ ## Getting started Make sure you have a local backend server running first: + ```bash -[nix-shell] $ marlowe-playground-server +[nix-shell] $ start-backend ``` Check the [backend documentation](../marlowe-playground-server/README.md) for more information on how to setup the Github OAuth application. Now we will build and run the front end: + ```bash [nix-shell] $ cd marlowe-playground-client # Generate the purescript bridge files @@ -26,8 +28,8 @@ Now we will build and run the front end: ## Adding dependencies -* Javascript dependencies are managed with npm, so add them to [package.json](./package.json) -* purescript uses package sets managed by spago so if the package set doesn't contain a dependency you can add it to [../packages.dhall](../packages.dhall) +- Javascript dependencies are managed with npm, so add them to [package.json](./package.json) +- purescript uses package sets managed by spago so if the package set doesn't contain a dependency you can add it to [../packages.dhall](../packages.dhall) Whenever you change `packages.dhall` you need to make sure that all dependencies can still properly be resolved and built. You can do so using the `update-client-deps` script: @@ -37,7 +39,6 @@ You can do so using the `update-client-deps` script: The `update-client-deps` script will generate/update `.nix` files which have to be committed and are required for a successful CI run. - ## Code formatting The code is formatted using [purs-tidy](https://github.com/natefaubion/purescript-tidy), and there is a CI task that will fail if the code is not properly formatted. You can apply purs-tidy to the project by calling: