Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update nix documentation the README #56

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .envrc

This file was deleted.

4 changes: 2 additions & 2 deletions CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ pre-commit run purs-tidy

=== How to build the code during development

The `nix-shell` environment has the correct GHC with all the external Haskell dependencies of the project.
The nix shell environment has the correct GHC with all the external Haskell dependencies of the project.
From here you can build the project packages directly with `cabal`.

NOTE: You may need to run `cabal update` so that `cabal` knows about the index state xref:update-index-state[we have pinned].


[WARNING]
====
You can also use `cabal` and `stack` outside the `nix-shell` environment to build the project.
You can also use `cabal` and `stack` outside the nix shell environment to build the project.
_However_ there are two caveats:

* You may get different versions of packages.
Expand Down
96 changes: 3 additions & 93 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ Related projects:
====
The rest of this README is focussed on people who want to develop or contribute to Marlowe.

====

[[cache-warning]]
[IMPORTANT]
====
DO NOT IGNORE THIS

If you want to use Nix with this project, make sure to set up the xref:iohk-binary-cache[IOHK binary cache].
If you do not do this, you will end up building GHC, which takes several hours.
If you find yourself building GHC, STOP and fix the cache.
====

== Documentation

== Working with the project
Expand Down Expand Up @@ -57,12 +45,11 @@ The other artifacts (docs etc.) are also most easily built with Nix.

===== Nix

Install https://nixos.org/nix/[Nix] (recommended). following the instructions on the https://nixos.org/nix/[Nix website].
This repository uses nix to provide a development and build environment.

Make sure you have read and understood the xref:cache-warning[cache warning].
DO NOT IGNORE THIS.
For instructions on how to install and configure nix (including how to enable access to our binary caches), refer to link:https://github.com/input-output-hk/iogx/blob/main/doc/nix-setup-guide.md[this document].

See <<nix-advice>> for further advice on using Nix.
If you already have nix installed and configured, you may enter the development shell by running `nix develop`.

===== Non-Nix

Expand All @@ -72,27 +59,13 @@ If you use Nix, these tools are provided for you via `shell.nix`, and you do *no
* If you want to build our Haskell packages with https://www.haskell.org/cabal/[`cabal`], then install it.
* If you want to build our Haskell packages with https://haskellstack.org/[`stack`], then install it.

[[building-with-nix]]
==== Using Nix

Run `nix develop` to enter the shell.

From there, you can type `info` to get a list of available commands.

==== How to build the Haskell packages with `cabal`

The Haskell packages can be built directly with `cabal`.
We do this during development (see <<how-to-develop>>).
The best way is to do this is inside a `nix-shell`.

[NOTE]
====
For fresh development setups, you also need to run `cabal update`.
====

Run `cabal build all` from the root to build all artifacts.


=== Deployment

The Marlowe Playground is automatically deployed upon certain pushes to GitHub
Expand All @@ -101,69 +74,6 @@ The Marlowe Playground is automatically deployed upon certain pushes to GitHub

For more details, including instructions for setting up ad hoc testing deployments, see https://github.com/input-output-hk/plutus-ops[the plutus-ops repo].


[[nix-advice]]
== Nix

[[iohk-binary-cache]]
=== How to set up the IOHK binary caches

Adding the IOHK binary cache to your Nix configuration will speed up
builds a lot, since many things will have been built already by our CI.

If you find you are building packages that are not defined in this
repository, or if the build seems to take a very long time then you may
not have this set up properly.

To set up the cache:

. On non-NixOS, edit `/etc/nix/nix.conf` and add the following lines:
+
----
experimental-features = nix-command flakes
substituters = "https://cache.nixos.org" "https://cache.iog.io "https://marlowe-playground.cachix.org"
trusted-public-keys = "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= marlowe-playground.cachix.org-1:8TmdbVgcB4QzTmuzLxNdaCxdc8ZVI9S8eeeXsY9stxo="
----
+
[NOTE]
====
If you don't have an `/etc/nix/nix.conf` or don't want to edit it, you may add the `nix.conf` lines to `~/.config/nix/nix.conf` instead.
You must be a https://nixos.org/nix/manual/#ssec-multi-user[trusted user] to do this.
====
. On NixOS, set the following NixOS options:
+
----
nix.settings = {
experimental-features = [ "nix-command" "flakes" ];
substituters = [
"https://cache.nixos.org"
"https://cache.iog.io"
];
trusted-public-keys = [
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
];
};
----


=== Nix on macOS

Nix on macOS can be a bit tricky. In particular, sandboxing is disabled by default, which can lead to strange failures.

These days it should be safe to turn on sandboxing on macOS with a few exceptions. Consider setting the following Nix settings, in the same way as in xref:iohk-binary-cache[previous section]:

----
sandbox = true
extra-sandbox-paths = /System/Library/Frameworks /System/Library/PrivateFrameworks /usr/lib /private/tmp /private/var/tmp /usr/bin/env
----

Changes to `/etc/nix/nix.conf` may require a restart of the nix daemon in order to take affect. Restart the nix daemon by running the following commands:

----
sudo launchctl stop org.nixos.nix-daemon
sudo launchctl start org.nixos.nix-daemon
----

== Licensing

You are free to copy, modify, and distribute Marlowe under the terms
Expand Down
24 changes: 13 additions & 11 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Plutus and Marlowe documentation site

This is a sphinx site. You can build it with sphinx directly (assuming you're in a `nix-shell`):
# Plutus documentation site

```
sphinx-build -j 4 -n . _build
```
This is a sphinx site.

Or you can build it with Nix at the top level, which will also build the Haddock for the project and link it in:
Run `nix develop` to enter a development shell with `sphinx-build` and `sphinx-autobuild`.

```
nix build -f default.nix docs.site
```
The following commands are also available:

- `develop-rtd-site`
Start a development server with live reload on `http://localhost:8000`
- `build-rtd-site`
Build the docs locally in `_build/index.html`
- `serve-rtd-site`
Build the full site with nix (including Haddock) and serve it on `http://localhost:8002`

The doc site from main is built automatically and hosted [here](https://plutus.readthedocs.io/en/latest).

The doc site from master is built automatically and hosted [here](https://plutus.readthedocs.io/en/latest).
Additionally, the site is built for all PRs, and a link to a preview can be found in the PR statuses.
4 changes: 2 additions & 2 deletions doc/marlowe/tutorials/using-marlowe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Marlowe in Haskell

This tutorial works in the version of Marlowe which can be found in the
``main`` branch of the `marlowe-cardano repository <https://github.com/input-output-hk/marlowe-cardano>`_.
We can run ghci by using the `nix-shell` available in `marlowe-dependency-docs repository <https://github.com/input-output-hk/marlowe-dependency-docs>`_:
We can run ghci by using the shell available in `marlowe-dependency-docs repository <https://github.com/input-output-hk/marlowe-dependency-docs>`_:

.. code:: bash

git clone "https://github.com/input-output-hk/marlowe-dependency-docs.git"
cd marlowe-dependency-docs
nix-shell
nix develop
ghci

A standalone version and formalisation of the semantics can also be found in
Expand Down
38 changes: 19 additions & 19 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions marlowe-playground-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,22 @@ 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)
- 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:

- Inside the nix-shell environment: `update-client-deps`
- Outside of the nix-shell environment (from the client directory): `$(nix-build -A plutus.updateClientDeps ../)/bin/update-client-deps`

The `update-client-deps` script will generate/update `.nix` files which have to be committed and are required for a successful CI run.
Whenever you change `packages.dhall` or `packages.json` you must also run the following commands inside the nix shell:
```bash
gen-nix-lockfiles
generate-purescript
```

## 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:

```bash
nix-shell shell.nix --run fix-purs-tidy
pre-commit run purs-tidy
```

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:

## VSCode notes

In order to have the PureScript IDE working properly with this project you need to open this folder as the root folder.
Expand Down