flake: Cleanup devenv on clean, add helper scripts, and run dev server on devenv up
Also adds a new config example for use with the devenv scripts, as well as a developer's guide for setting up the Nix environment. This could also have steps for speific distros, such as what packages to install, and specific notes.
This commit is contained in:
parent
619250a51d
commit
62e0ded409
4 changed files with 75 additions and 0 deletions
38
.config/devenv.yml
Normal file
38
.config/devenv.yml
Normal file
|
@ -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
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -22,6 +22,7 @@ coverage
|
||||||
# config
|
# config
|
||||||
/.config/*
|
/.config/*
|
||||||
!/.config/example.yml
|
!/.config/example.yml
|
||||||
|
!/.config/devenv.yml
|
||||||
!/.config/docker_example.env
|
!/.config/docker_example.env
|
||||||
!/.config/helm_values_example.yml
|
!/.config/helm_values_example.yml
|
||||||
|
|
||||||
|
|
22
docs/development.md
Normal file
22
docs/development.md
Normal file
|
@ -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.
|
14
flake.nix
14
flake.nix
|
@ -32,6 +32,8 @@
|
||||||
# Add additional packages to our environment
|
# Add additional packages to our environment
|
||||||
packages = [
|
packages = [
|
||||||
pkgs.nodePackages.pnpm
|
pkgs.nodePackages.pnpm
|
||||||
|
|
||||||
|
pkgs.python3
|
||||||
];
|
];
|
||||||
# No need to warn on a new version, we'll update as needed.
|
# No need to warn on a new version, we'll update as needed.
|
||||||
devenv.warnOnNewVersion = false;
|
devenv.warnOnNewVersion = false;
|
||||||
|
@ -43,6 +45,18 @@
|
||||||
# Enable stable Rust for the backend
|
# Enable stable Rust for the backend
|
||||||
languages.rust.enable = true;
|
languages.rust.enable = true;
|
||||||
languages.rust.version = "stable";
|
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 = {
|
services = {
|
||||||
postgres = {
|
postgres = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
Loading…
Reference in a new issue