teutat3s
44a0598bd1
Relax python dependency: croniter • Updated input 'agenix': 'github:ryantm/agenix/2994d002dcff5353ca1ac48ec584c7f6589fe447' (2023-04-21) → 'github:ryantm/agenix/0d8c5325fc81daf00532e3e26c6752f7bcde1143' (2023-07-14) • Updated input 'agenix/darwin': 'github:lnl7/nix-darwin/43ce086813c83184b88f67fc544af2050a3035ba' (2023-07-12) → 'github:lnl7/nix-darwin/87b9d090ad39b25b2400029c64825fc2a8868943' (2023-01-09) • Added input 'agenix/home-manager': 'github:nix-community/home-manager/32d3e39c491e2f91152c84f8ad8b003420eab0a1' (2023-04-22) • Added input 'agenix/home-manager/nixpkgs': follows 'agenix/nixpkgs' • Updated input 'devshell': 'github:numtide/devshell/6b2554d28d46bfa6e24b941e999a145760dad0e1' (2023-06-05) → 'github:numtide/devshell/f9238ec3d75cefbb2b42a44948c4e8fb1ae9a205' (2023-07-03) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/e635192892f5abbc2289eaac3a73cdb249abaefd' (2023-06-01) → 'github:NixOS/nixpkgs/6cee3b5893090b0f5f0a06b4cf42ca4e60e5d222' (2023-07-16) |
||
---|---|---|
docs | ||
modules | ||
node | ||
python | ||
scripts | ||
secrets | ||
srcs | ||
test-vm | ||
.envrc | ||
.gitignore | ||
erpnext-package.json | ||
erpnext-yarn.lock | ||
flake.lock | ||
flake.nix | ||
frappe-package.json | ||
nginx-erpnext-conf.nix | ||
overlay.nix | ||
python-overlay.nix | ||
README.md | ||
update.sh |
ERPNext on NixOS
Cachix
Using the https://pub-solar.cachix.org binary cache:
cachix use pub-solar
Or manually add the following lines to your ~/.config/nix/nix.conf
:
substituters = https://cache.nixos.org/ https://pub-solar.cachix.org
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= pub-solar.cachix.org-1:ZicXIxKgdxMtgSJECWR8iihZxHRvu8ObL4n2cuBmtos=
Pushing to the https://pub-solar.cachix.org binary cache (in this example, we push the
package run-erpnext
and its dependencies):
nix develop
nix build --json .#run-erpnext \
| jq -r '.[].outputs | to_entries[].value' \
| cachix push pub-solar
Updating bench
, erpnext
, frappe
versions and hashes
Versions and hashes are in srcs/pin.nix
. To quickly update those to the
latest version, run:
cd srcs
./update.sh
# If you need specific versions, specify them as arguments
./update.sh <bench_version> <erpnext_version> <frappe_version>
NixOS VM
Initial setup:
# Build the test VM
nix build '.#nixosConfigurations.test-vm.config.system.build.vm'
# Start the VM, to generate SSH host key files required for secrets
./result/bin/run-nixos-vm
# In another terminal, get the ed25519 SSH hostkey, then stop the VM with CTRL-c
ssh-keyscan -p 2222 127.0.0.1 | grep ssh-ed25519
...
[127.0.0.1]:2222 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMdCOs16W731ftPDqO+X6RZVSdwVVNw2Xfmcpk5pzbeO
# Edit secrets.nix and add the SSH hostkey to machine 'test-vm', starting with 'ssh-ed25519 ...'
sed --in-place \
's|test-vm = .*|test-vm = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMdCOs16W731ftPDqO+X6RZVSdwVVNw2Xfmcpk5pzbeO host@test-vm";|' \
secrets/secrets.nix
# Rekey the secrets with agenix
cd secrets && agenix --rekey && cd ..
# Build the test VM again
nix build '.#nixosConfigurations.test-vm.config.system.build.vm'
# Start the VM once more
./result/bin/run-nixos-vm
# Access the VM via SSH, use an empty password (Enter) to login
ssh root@localhost -p 2222
# Watch erpnext startup:
# The initial startup can take a few minutes
journalctl -fu erpnext-web.service
# Open https://localhost:8081 in your browser and follow the setup wizard
# User: Administrator
# Password: admin
After the initial setup, make changes, build and run the VM again to test the changes.
# Build the test VM
nix build '.#nixosConfigurations.test-vm.config.system.build.vm'
# Start the VM
./result/bin/run-nixos-vm
Useful for debugging, you can delete a special file in the VM to force the ERPNext init script to run again. It will then try to initialize the DB again and create a new site directory.
ssh root@localhost -p 2222
rm /var/lib/erpnext/.db-created
systemctl restart erpnext-web
To reset the VM's data and start fresh, run:
rm nixos.qcow2
Note that this will re-generate SSH host keys and you will need to do the initial setup again.
Docker
docker run -d --name erpnext-redis-socketio -p 12311:6379 redis:latest
docker run -d --name erpnext-redis-queue -p 6379:6379 redis:latest
docker run -d --name erpnext-db -p 3306:3306 -e MARIADB_ROOT_PASSWORD=password -e MARIADB_DATABASE=erpnext -e MARIADB_USER=erpnext -e MARIADB_PASSWORD=erpnext mariadb:latest --collation-server=utf8mb4_unicode_ci
nix build .#run-erpnext
./result/bin/run-erpnext
# new terminal
nix shell nixpkgs#nginx
nginx -c /tmp/erpnext/nginx-erpnext.conf -g "daemon off;"
# http://localhost:8081
# User: Administrator
# Password: admin
Links:
- https://erpnext.com
- https://docs.erpnext.com/docs/v14/user/manual/en/setting-up
- https://discuss.frappe.io/t/installing-the-docker-image-on-a-local-machine-without-letsencrypt-so-we-can-access-it-with-http-localhost/87585/7
- https://github.com/frappe/frappe_docker/blob/main/images/production/Containerfile
- https://github.com/frappe/bench
- https://github.com/frappe/erpnext
- https://github.com/frappe/frappe