diff --git a/.config/devenv.yml b/.config/devenv.yml new file mode 100644 index 000000000..6c60f338a --- /dev/null +++ b/.config/devenv.yml @@ -0,0 +1,38 @@ +url: http://localhost:3000 +port: 3000 + +db: + host: 127.0.0.1 + port: 5432 + + db: calckey + + user: calckey + pass: calckey + +redis: + host: localhost + port: 6379 + family: 4 +#sonic: +# host: localhost +# port: 1491 +# auth: SecretPassword +# collection: notes +# bucket: default + +#elasticsearch: +# host: localhost +# port: 9200 +# ssl: false +# user: +# pass: + +id: 'aid' + +reservedUsernames: + - root + - admin + - administrator + - me + - system diff --git a/.gitignore b/.gitignore index 1fadce431..63ee4f35f 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ coverage # config /.config/* !/.config/example.yml +!/.config/devenv.yml !/.config/docker_example.env !/.config/helm_values_example.yml diff --git a/docs/development.md b/docs/development.md new file mode 100644 index 000000000..41d1b3469 --- /dev/null +++ b/docs/development.md @@ -0,0 +1,22 @@ +# 🌎 Calckey Developer Docs + +## Nix Dev Environment +The Calckey repo comes with a Nix-based shell environment to help make development as easy as possible! + +Please note, however, that this environment will not work on Windows outside of a WSL2 environment. + +### Prerequisites + +- Installed the [Nix Package Manager](https://nixos.org/download.html) +- Installed [direnv](https://direnv.net/docs/installation.html) and added its hook to your shell. + +Once the repo is cloned to your computer, follow these next few steps inside the Calckey folder: + +- Run `direnv allow`. This will build the environment and install all needed tools. +- Run `install-deps`, then `prepare-config`, to install the node dependencies and prepare the needed config files. +- In a second terminal, run `devenv up`. This will spawn a **Redis** server, a **Postgres** server, and the **Calckey** server in dev mode. +- Once you see the Calckey banner printed in your second terminal, run `migrate` in the first. +- Once migrations finish, open http://localhost:3000 in your web browser. +- You should now see the admin user creation screen! + +Note: When you want to restart a dev server, all you need to do is run `devenv up`, no other steps are necessary. diff --git a/flake.nix b/flake.nix index fd9098f0d..73d8fe02f 100644 --- a/flake.nix +++ b/flake.nix @@ -32,6 +32,8 @@ # Add additional packages to our environment packages = [ pkgs.nodePackages.pnpm + + pkgs.python3 ]; # No need to warn on a new version, we'll update as needed. devenv.warnOnNewVersion = false; @@ -43,6 +45,18 @@ # Enable stable Rust for the backend languages.rust.enable = true; languages.rust.version = "stable"; + processes = { + dev-server.exec = "pnpm run dev"; + }; + scripts = { + build.exec = "pnpm run build"; + clean.exec = "pnpm run clean"; + clear-state.exec = "rm -rf .devenv/state/redis .devenv/state/postgres"; + format.exec = "pnpm run format"; + install-deps.exec = "pnpm install"; + migrate.exec = "pnpm run migrate"; + prepare-config.exec = "cp .config/devenv.yml .config/default.yml"; + }; services = { postgres = { enable = true;