Jann Marc Villablanca neon_arch commited on
Commit
0943b8b
1 Parent(s): 1284341

:memo: Developer environment setup on NixOS (#454)

Browse files

* 🧑‍💻feat: update nix flake dev environment

- This removes installing `docker`, `rust-analyzer`, `rustfmt`
imperatively. `nodejs` is used to install dev dependencies
`stylelint-config-standard` and `postcss-lit`
- The `shellHook`s adds `rusty-hook` CLI to the PATH and the node
dev dependencies to the NODE_PATH.

* 📝 docs(developing): update NixOS dev environment setup

* fix: remove nonvital guide and improve grammar

---------

Co-authored-by: neon_arch <[email protected]>

Files changed (2) hide show
  1. docs/developing.md +11 -11
  2. flake.nix +9 -1
docs/developing.md CHANGED
@@ -212,12 +212,6 @@ This section covers how to setup the project for development using the `NixOS de
212
  Before you start working on the project. You will need the following packages installed on your system:
213
 
214
  - `Git` installed on your system. The installation instructions for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
215
- - Finally, The latest version of `Docker` is installed on your system which will be used to avoid introducing unexpected issues when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/).
216
-
217
- > Optionally, On `NixOS` the above-mentioned required packages except for `stylelint` and `cargo-watch` could also be installed by following the link to the installation instructions provided below:
218
- >
219
- > - `Git`: https://search.nixos.org/packages?channel=23.05&show=git&from=0&size=50&sort=relevance&type=packages&query=git
220
- > - `Docker`: https://search.nixos.org/packages?channel=23.05&show=docker&from=0&size=50&sort=relevance&type=packages&query=docker
221
 
222
  #### Setting up Pre-commit Checks
223
 
@@ -234,7 +228,11 @@ Then run the following command to setup the `NixOS dev-shell`:
234
  nix develop
235
  ```
236
 
237
- Once you have finished running the above commands then run the following command to setup the `pre-commit` checks:
 
 
 
 
238
 
239
  ```shell
240
  cargo test
@@ -244,14 +242,16 @@ By running the above-mentioned command, it will automatically set up all the pre
244
 
245
  #### Post Setup Requirements
246
 
247
- After you have done setting up pre-commit checks, then you may need to fulfill a few more requirements to finish setting up the development environment with `NixOS dev-shell`. These include:
248
-
249
- - `Cargo-watch` installed on your system which will allow you to auto-build the project when any checks occur in the source code files in the codebase (`websurfx` directory). Before you install `cargo-watch` on your system, make sure you have `cargo` installed on your system. To install `cargo-watch` run the following command:
250
 
251
  ```shell
252
- cargo install cargo-watch
253
  ```
254
 
 
 
 
 
255
  #### Running the Project
256
 
257
  If you have followed the above section then you should now be inside a `dev-shell` environment. In the same environment run the following command to run the project:
 
212
  Before you start working on the project. You will need the following packages installed on your system:
213
 
214
  - `Git` installed on your system. The installation instructions for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
 
 
 
 
 
 
215
 
216
  #### Setting up Pre-commit Checks
217
 
 
228
  nix develop
229
  ```
230
 
231
+ > You can use `nix-direnv` to simplify entering into the `nix-shell`. Its setup is beyond the scope of this guide. Read more about it here: [nix-direnv](https://github.com/nix-community/nix-direnv)
232
+
233
+ This will add `docker`, `cargo-watch`, and other dev environment essentials to your `nix-shell` so you don't have to install everything imperatively.
234
+
235
+ After finishing the commands above, run the following command to setup the `pre-commit` checks:
236
 
237
  ```shell
238
  cargo test
 
242
 
243
  #### Post Setup Requirements
244
 
245
+ The final step is to run
 
 
246
 
247
  ```shell
248
+ npm i -D stylelint-config-standard postcss-lit`
249
  ```
250
 
251
+ This will add `node_modules` in the current directory.
252
+
253
+ Run `git commit` and if every thing is setup correctly, it should say that your branch is up to date.
254
+
255
  #### Running the Project
256
 
257
  If you have followed the above section then you should now be inside a `dev-shell` environment. In the same environment run the following command to run the project:
flake.nix CHANGED
@@ -32,24 +32,32 @@
32
  buildInputs = [
33
  actionlint
34
  cargo
 
35
  haskellPackages.hadolint
 
36
  nodePackages_latest.cspell
37
  nodePackages_latest.eslint
38
  nodePackages_latest.markdownlint-cli2
39
  nodePackages_latest.stylelint
40
  redis
41
  rustPackages.clippy
 
42
  cargo-watch
43
  rustc
 
44
  yamllint
45
  openssl
46
  pkg-config
47
  ];
48
  RUST_SRC_PATH = rustPlatform.rustLibSrc;
 
 
 
 
49
  };
50
 
51
  # Build via "nix build .#websurfx", which is basically just
52
  # calls the build function
53
  packages.websurfx = packages.default;
54
  });
55
- }
 
32
  buildInputs = [
33
  actionlint
34
  cargo
35
+ docker
36
  haskellPackages.hadolint
37
+ nodejs
38
  nodePackages_latest.cspell
39
  nodePackages_latest.eslint
40
  nodePackages_latest.markdownlint-cli2
41
  nodePackages_latest.stylelint
42
  redis
43
  rustPackages.clippy
44
+ rust-analyzer
45
  cargo-watch
46
  rustc
47
+ rustfmt
48
  yamllint
49
  openssl
50
  pkg-config
51
  ];
52
  RUST_SRC_PATH = rustPlatform.rustLibSrc;
53
+ shellHook = ''
54
+ export PATH="$PATH:$HOME/.cargo/bin"
55
+ export NODE_PATH="$NODE_PATH:./node_modules"
56
+ '';
57
  };
58
 
59
  # Build via "nix build .#websurfx", which is basically just
60
  # calls the build function
61
  packages.websurfx = packages.default;
62
  });
63
+