erpnext-nix/README.md

2.5 KiB

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

NixOS VM

# 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

# Get the ed25519 SSH hostkey
ssh-keyscan -p 2222 127.0.0.1

# Edit secrets.nix and add the SSH hostkey to machine 'test-vm'
vim secrets/secrets.nix

# Rekey the secrets with agenix
cd secrets
agenix --rekey
cd ..

# Stop with CTRL-c & build the test VM again
nix build '.#nixosConfigurations.test-vm.config.system.build.vm'
# Start the VM
./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 http://localhost:8081 in your browser
# User: Administrator
# Password: admin

# To reset all data for the VM
rm nixos.qcow2

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