Skip to content

Commit

Permalink
[#526] Add documentation on Nix usage
Browse files Browse the repository at this point in the history
Provide comprehensive documentation on utilizing Nix with the project to
enhance development processes and streamline environment setup. The
.envrc files are updated to ensure compatibility with Nix
configurations, facilitating package installation and project building.
This documentation emphasizes the use of Nix and Direnv for effective
project setup and module combination within the GovTool project
structure.

Changes:
- Updated `README.md` in `govtool/backend` to include instructions for
  utilizing Nix and Direnv, aligning the setup with Nix Flakes
  configuration.
- Revised `README.md` in `govtool/frontend` to streamline instructions
  for using Nix and Direnv, ensuring proper environment setup and
  dependencies for the frontend module development.
  • Loading branch information
placek committed Mar 22, 2024
1 parent def0229 commit 7a7e482
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 79 deletions.
17 changes: 6 additions & 11 deletions govtool/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,24 @@ You will need your `cardano-node` and `cardano-db-sync` to be compatible with Sa

[`sancho` testnet config files](https://sancho.network/tutorials/start-node/)

### Using Nix
### Using Nix and Direnv

Due to problems with openapi3 package it's hard to build this project with plain `ghc` and `cabal-install`. Until the prolem is solved we reccomend using `nix` - this problem is fixed when you build your project from inside of the nix shell.

1. Get [Nix](https://nixos.org/download).

2. Enter `govtool/backend` directory:
2. Get [direnv](https://direnv.net/).

```sh
cd govtool/backend
```

3. Allow broken nix packages
3. Enter `govtool/backend` directory:

```sh
export NIXPKGS_ALLOW_BROKEN=1
cd govtool/backend
```
This is due to `openapi3` package being marked as broken.

4. Run `nix-shell`
4. Allow direnv to setup your environment:

```sh
nix-shell
direnv allow
```

5. Update cabal & build project
Expand Down
84 changes: 16 additions & 68 deletions govtool/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@

Installed on your machine:

1. Node.js >= 16 ([official website](https://nodejs.org/en))
1. Node.js >= 18 ([official website](https://nodejs.org/en))
2. npm or yarn - for package management

Clone the project

```bash
git clone https://github.com/IntersectMBO/govtool
git clone https://github.com/IntersectMBO/govtool
```

Fill .env based on env.example file

Go to the project directory

```bash
cd voltaire-era/govtool/frontend
cd voltaire-era/govtool/frontend
```

Install dependencies

```bash
npm install
npm install
```

or

```bash
yarn install
yarn install
```

Start the server
Expand All @@ -43,47 +43,6 @@ or
yarn dev
```

#### Using nix

1. Get [Nix](https://nixos.org/download).

2. Enter `govtool/frontend` directory:

```sh
cd govtool/frontend
```

3. Run `nix-shell`

```sh
nix-shell
```

4. Run project

```sh
npm run dev
```

##### Alternative

You can skip point 3 by using an automatic direnv configuration:

Install [`direnv`](https://direnv.net/):

```sh
nix-env -i direnv
```

Allow direnv configuration in `govtool/frontend`:

```sh
direnv allow govtool/frontend
```

From now on, once you enter the `govtool/frontend` the `nix-shell` with proper
configuration will be propagated.

## Developing

### Frontend Built With
Expand All @@ -107,7 +66,6 @@ configuration will be propagated.
Install [`Git`](https://git-scm.com/) - version control
Recommendetd [`React developer tools`](https://react.dev/learn/react-developer-tools)


## To Develop

### Standard way
Expand All @@ -124,42 +82,32 @@ npm install
npm run dev
```

### Using nix
#### Using Nix and Direnv

1. Get [Nix](https://nixos.org/download).

2. Enter `govtool/frontend` directory:
```sh
cd govtool/frontend
```
2. Get [direnv](https://direnv.net/).

3. Run `nix-shell`
```sh
nix-shell
```
3. Fill .envrc based on envrc.example file in project root.

4. Enter `govtool/frontend` directory:

4. Run project
```sh
npm run dev
cd govtool/frontend
```

##### Alternative

You can skip point 3 by using an automatic direnv configuration:
5. Allow direnv to setup your environment:

Install [`direnv`](https://direnv.net/):
```sh
nix-env -i direnv
direnv allow
```

Allow direnv configuration in `govtool/frontend`:
5. Run project

```sh
direnv allow govtool/frontend
yarn dev
```

From now on, once you enter the `govtool/frontend` the `nix-shell` with proper
configuration will be propagated.

### Users

The GovTool application can read and display data from the Cardano chain using REST API.
Expand Down

0 comments on commit 7a7e482

Please sign in to comment.