Skip to content

Commit

Permalink
Update nix documentation the README (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeme-wana authored Nov 10, 2023
1 parent 4cef18a commit b16241f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 88 deletions.
83 changes: 4 additions & 79 deletions CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,90 +14,15 @@ If you _really_ cannot use Nix and still want to contribute to Marconi, then xre

=== Installing and setting up Nix

This project uses Flakes, so you must have Nix version `>= 2.4` installed.
This repository uses Nix to provide the development and build environment.

Either upgrade or install https://nixos.org/[Nix] following the instructions on https://nixos.org/download.html[its website].
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].

On Linux this command should suffice: `sh <(curl -L https://nixos.org/nix/install) --daemon`

=== How to get a shell environment with tools

To enter the development shell run the following command in the root directory:

`nix develop`

If you receive this message:

`error: experimental Nix feature 'nix-command' is disabled; use '--extra-experimental-features nix-command' to override`

Then try this:

`nix develop --extra-experimental-features 'nix-command flakes'`

You may now choose to edit your `/etc/nix/nix.conf` (global) or `~/.config/nix/nix.conf` (you must be a https://nixos.org/nix/manual/#ssec-multi-user[trusted user] to do this) by appending the following line:

`extra-experimental-features = nix-command flakes`

If you do so you will be able to enter the development shell by running `nix develop`.

If you are a VSCode user, you may want to start your development session by running:

`nix develop --command code`

If this is your first time running `nix develop`, you may be asked the following:
```
do you want to allow configuration setting 'allow-import-from-derivation' to be set to 'true' (y/N)? y
do you want to permanently mark this value as trusted (y/N)? y
```
Please type `y` to this and all subsequent prompts to make life easy for yourself.

IMPORTANT: *It is particularly important to accept the `extra-substituters` and `extra-trusted-public-keys` settings, which will grant access to our Nix binary cache.*

At this point and if this is your first time running `nix develop` then Nix will download, build and install a copious amout of dependencies.

It is not uncommon for this process to take a couple of hours and to write tens of GBs to the `/nix/store`.

*Rest assured that this only happens the very first time you run `nix develop`.*

However you should pay attention to the output of `nix develop`: if you notice that you are _building_ GHC, it is likely that your caches have not been configured correctly.

Accepting the configuration settings as outlined above should be sufficient to avoid this, however if your caches are still broken, you may try to append the following lines to `/etc/nix/nix.conf` and/or `~/.config/nix/nix.conf`:

----
substituters = https://cache.iog.io https://cache.nixos.org/
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
extra-experimental-features = nix-command flakes
----

On NixOS, set the following NixOS options:
----
nix = {
binaryCaches = [ "https://cache.iog.io" ];
binaryCachePublicKeys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
};
----

You will need to restart the nix-daemon on non-NixOS for the changes to take effect, or just restart your machine.

IMPORTANT: If you are on NixOS or otherwise using a multi-user Nix install, you **must** be a trusted user to set substituters. If you are not a trusted user, enabling the options prompted by the flake will have no effect (non-trusted users are disallowed from doing this).

On non-NixOS systems, add the following to the system-wide configuration (`/etc/nix/nix.conf`):

```
trusted-users = <username> root
```

You can also use a group name by prefixing it with `@`, e.g. to add all members of the `wheel` group:

```
trusted-users = @wheel root
```

On NixOS, add the user/group name to the list under [`nix.settings.trusted-users`](https://search.nixos.org/options?show=nix.settings.trusted-users).
If you already have Nix installed and configured, you may enter the development shell by running `nix develop`.

=== Note on pre-commit hooks

If you are committing code outside nix develop, you will get this error:
If you are committing code outside `nix develop`, you will get this error:

----
pre-commit not found. Did you forget to activate your virtualenv?
Expand Down
12 changes: 7 additions & 5 deletions doc/read-the-docs-site/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Plutus documentation site
# Marconi documentation site

This is a sphinx site.

Run `nix develop` to enter a development shell with `sphinx-build` and `sphinx-autobuild`.

The following commands are also available:

- `build-readthedocs-site`
Build the docs locally in `_build/index.html`
- `serve-readthedocs-site`
- `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://marconi.readthedocs.io).
The doc site from main is built automatically and hosted [here](https://marconi.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.
25 changes: 21 additions & 4 deletions flake.lock

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

0 comments on commit b16241f

Please sign in to comment.