Find a file
teutat3s ceb04d96de
module: fix DNS by adding resolv.conf, ssl dirs to
BindReadOnlyPaths
This should fix temporary name resolution errors observed in erpnext.

Minor cleanup and explanatory comment for confinement.packages

We don't use pkgs from path, but prefer explicitly referring to pkgs
2023-07-18 12:23:09 +02:00
docs Manage secrets using agenix 2023-07-15 16:32:18 +02:00
modules module: fix DNS by adding resolv.conf, ssl dirs to 2023-07-18 12:23:09 +02:00
node Update bench, erpnext, frappe versions 2023-07-17 21:10:27 +02:00
python flake: set nixpkgs to nixos-23.05 2023-07-18 02:30:30 +02:00
scripts Separate apps and assets 2023-06-03 10:24:05 +02:00
secrets module: final fixes and cleanup 2023-07-17 21:06:45 +02:00
srcs Update bench, erpnext, frappe versions 2023-07-17 21:10:27 +02:00
test-vm module: final fixes and cleanup 2023-07-17 21:06:45 +02:00
.envrc wip: cleanup, more docs 2023-06-12 15:28:17 +02:00
.gitignore wip: cleanup, more docs 2023-06-12 15:28:17 +02:00
erpnext-package.json wip: assets 2023-05-20 23:36:21 +02:00
erpnext-yarn.lock wip: assets 2023-05-20 23:36:21 +02:00
flake.lock flake: set nixpkgs to nixos-23.05 2023-07-18 02:30:30 +02:00
flake.nix flake: set nixpkgs to nixos-23.05 2023-07-18 02:30:30 +02:00
frappe-package.json wip: assets 2023-05-20 23:36:21 +02:00
nginx-erpnext-conf.nix wip: working vm 2023-06-07 21:58:05 +02:00
overlay.nix wip: cleanup, more docs 2023-06-12 15:28:17 +02:00
python-overlay.nix wip: cleanup, more docs 2023-06-12 15:28:17 +02:00
README.md Update bench, erpnext, frappe versions 2023-07-17 21:10:27 +02:00
update.sh Update bench, erpnext, frappe versions 2023-07-17 21:10:27 +02:00

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