Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copied basic structure from marlowe dashboard
- Loading branch information
Showing
28 changed files
with
12,449 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# FIXME: @michaelpj to remove this in favour of root .giignore file | ||
# once he figures out what's going on with nix-gitignore | ||
generated | ||
generated/ | ||
generated-docs/ | ||
node_modules/ | ||
output/ | ||
yarn-error.log | ||
yarn.lock | ||
.psci_modules/ | ||
.psc-package/ | ||
.psc-package2nix/ | ||
.spago/ | ||
.spago2nix/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
The Marlowe Marketplace is an online application that lets users browse for Marlowe Contracts. | ||
|
||
## Getting started | ||
|
||
The Marlowe Marketplace is written in [PureScript](https://www.purescript.org/) and uses npm and [spago](https://github.com/purescript/spago) for managing dependencies. | ||
|
||
**Note**: _The workflow described here relies heavily on Nix. This means you should either be working inside a nix-shell environment or use tools such as [lorri](https://github.com/target/lorri) or [nix-direnv](https://github.com/nix-community/nix-direnv) or similar to provide a suitable environment._ | ||
|
||
|
||
### Starting the frontend server | ||
|
||
With the backend server running you can get started using the `npm start` script: | ||
|
||
```bash | ||
$ npm run start | ||
``` | ||
|
||
The `start` script will: | ||
|
||
- Install npm dependencies | ||
- Compile the purescript code | ||
- Start the webkpack server | ||
|
||
Once the `start` script completes you can access the frontend via [http://localhost:8009](http://localhost:8009) | ||
|
||
## Development Workflow | ||
|
||
The following outlines some essentials for actually working on the marlowe marketplace code. | ||
|
||
### NPM Scripts | ||
|
||
Apart from the `start` script introduced above there are a couple of scripts for the most frequent tasks during development. In order to run a webpack server in development mode with automatic reloading use **webpack:server**: | ||
|
||
``` | ||
$ npm webpack:server | ||
``` | ||
|
||
Please refer to [package.json](./package.json) for the full set of provided scripts. | ||
|
||
|
||
### Managing Dependencies | ||
|
||
There are two relevant sources of dependencies that have to be handled and integrated with Nix separately: _Javascript(/npm)_ dependencies and _PureScript_ dependencies. | ||
|
||
#### Managing NPM Dependencies | ||
|
||
The Javascript dependencies are handled by npm in [package.json](./package.json) (and [package-lock.json](./package-lock.json) which | ||
is updated by npm automatically). | ||
|
||
The npm dependencies are integrated with Nix via [npmlock2nix](https://github.com/tweag/npmlock2nix) almost completely transparently. Any changes to the lockfile will be picked up npmlock2nix automatically during the nix build. No | ||
additional files have to be generated or maintained. | ||
|
||
##### NodeJS GitHub dependencies | ||
|
||
In general, npm dependencies are handled by npmlock2nix automatically and transparently. The one exception to this rule are | ||
GitHub dependencies. In order for these to work in restricted evaluation mode (which is what hydra uses) you have to specify | ||
the sha256 of the dependency you want to use in your `buildNodeModules`. For example: | ||
|
||
``` | ||
buildNodeModules { | ||
projectDir = ./.; | ||
packageJson = ./package.json; | ||
packageLockJson = ./package-lock.json; | ||
githubSourceHashMap = { | ||
shmish111.nearley-webpack-loader."939360f9d1bafa9019b6ff8739495c6c9101c4a1" = "1brx669dgsryakf7my00m25xdv7a02snbwzhzgc9ylmys4p8c10x"; | ||
}; | ||
} | ||
``` | ||
|
||
You can add new dependencies with the sha256 set to `"0000000000000000000000000000000000000000000000000000"`. This will yield an error | ||
message during the build with the actual hash value. | ||
|
||
#### Managing PureScript Dependencies | ||
|
||
The PureScript dependencies are handled by [spago](https://github.com/purescript/spago) in [packages.dhall](./packages.dhall). | ||
|
||
The Nix integration is done using [spago2nix](https://github.com/justinwoo/spago2nix). Any changes to the PureScript dependencies | ||
require an update of the Nix code generated by spago2nix: | ||
|
||
``` | ||
$ spago2nix generate | ||
``` | ||
|
||
This will parse the spago configuration and will generate an updated `.nix` file. | ||
|
||
**Note**: If the `spago2nix` command is not available make sure you are inside a nix-shell environment or that your lorri session | ||
is up and running. | ||
|
||
|
||
### Nix | ||
|
||
#### Building The Client With Nix | ||
|
||
You can run the following command (from the repository root) to build the client and the | ||
backend server with Nix: | ||
|
||
```sh | ||
$ nix-build \ | ||
--option trusted-public-keys "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" \ | ||
--option substituters https://hydra.iohk.io \ | ||
-A marlowe-dashboard.client -A marlowe-dashboard.server-invoker | ||
``` | ||
|
||
**Note**: When building the client make sure that the generated directory is removed completely or you will get _Duplicate module_ errors. | ||
|
||
#### Building Docker Images With Nix | ||
|
||
```sh | ||
$ nix build -f default.nix marlowe-dashboard.docker | ||
$ docker load < result | ||
# You can see the image name and tag as a result of the previous command and use it below | ||
$ docker run -p 8080:8080 marlowe-dashboard-docker:somecrazytag | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ pkgs, gitignore-nix, webCommon, webCommonMarlowe, buildPursPackage, buildNodeModules, filterNpm, plutus-pab }: | ||
let | ||
cleanSrc = gitignore-nix.gitignoreSource ./.; | ||
|
||
nodeModules = buildNodeModules { | ||
projectDir = filterNpm cleanSrc; | ||
packageJson = ./package.json; | ||
packageLockJson = ./package-lock.json; | ||
githubSourceHashMap = { }; | ||
}; | ||
|
||
client = buildPursPackage { | ||
inherit pkgs nodeModules; | ||
src = cleanSrc; | ||
checkPhase = '' | ||
node -e 'require("./output/Test.Main").main()' | ||
''; | ||
name = "marlowe-marketplace-client"; | ||
extraSrcs = { | ||
web-common = webCommon; | ||
web-common-marlowe = webCommonMarlowe; | ||
generated = plutus-pab.generated-purescript; | ||
}; | ||
packages = pkgs.callPackage ./packages.nix { }; | ||
spagoPackages = pkgs.callPackage ./spago-packages.nix { }; | ||
}; | ||
in | ||
{ | ||
inherit (plutus-pab) server-invoker generated-purescript generate-purescript start-backend; | ||
inherit client; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/*eslint-env node*/ | ||
import './static/css/main.css'; | ||
import './src/Main.purs'; |
Oops, something went wrong.