NixOS Virtualbox Dev VM
You can use the official NixOS VirtualBox appliance if you want to run the project on our preferred production system NixOS.
This will guide you from downloading the appliance to a running application.
Note
You need VirtualBox installed on your system.
Note
If you want to run the application elsewhere, please look at Development Quick Start
VM Preparation
The following code snippets are written for ekklesia-portal but also work for ekklesia-voting when you change the project name.
Get the NixOS 21.11 VirtualBox appliance and follow the instructions there to import and start the VM. Enable clipboard integration in the VirtualBox menu bar with Devices -> Shared Clipboard -> Host to Guest so you can copy-paste longer commands from here.
In the VM, open konsole (press Alt-F1 and type konsole) and run the following commands as the demo user.
Add the edemocracy binary cache:
# password for sudo is `demo` nix-shell -p cachix --run "sudo cachix use edemocracy" # ignore the instructions shown by cachix, we do that later.
Edit
/etc/nixos/configuration.nix
(usingsudo nano /etc/nixos/configuration.nix
, for example) and change theimports
line to:# no commas between list items in Nix! imports = [ <nixpkgs/nixos/modules/installer/virtualbox-demo.nix> ./ekklesia_dev.nix ];
Fetch our recommended NixOS configuration with curl and put it in
/etc/nixos
(you can alsodownload it here
):curl -O https://raw.githubusercontent.com/edemocracy/ekklesia/master/docs/development/ekklesia_dev.nix sudo mv ekklesia_dev.nix /etc/nixos
Rebuild the NixOS system to activate our configuration and reload the current shell:
sudo nixos-rebuild switch exec bash
Tell direnv where nix-direnv is located:
echo "source /run/current-system/sw/share/nix-direnv/direnvrc" > ~/.direnvrc
Setting up the Project
Clone the repository and change to the checked out directory:
git clone https://github.com/edemocracy/ekklesia-portal cd ekklesia-portal
Tell
direnv
to usenix-direnv
whenever you enter the directory.nix-direnv
starts building immediately which may take a while:echo "use nix" > .envrc direnv allow # direnv runs nix-build now
Compile translations and CSS (look at dodo.py to see what this does):
doit
Create a config file named
config.yml
using the config template fromsrc/ekklesia_portal/config.example.yml
. Underdatabase
, you have to changeuri
. Underapp
, changeforce_ssl
to false andinsecure_development_mode
to true. The beginning of the config file should look like this:database: uri: "postgresql+psycopg2:///ekklesia_portal?host=/run/postgresql" fts_language: 'english' app: instance_name: my_ekklesia_portal insecure_development_mode: true login_visible: true force_ssl: false
Initialize the dev database with a custom config file:
python tests/create_test_db.py -c config.yml
The development server can be run with a custom config file by executing:
python src/ekklesia_portal/runserver.py --debug -c config.yml 2>&1 | eliot-tree -l0
Setting up Tests
Add an environment variable to .envrc to configure the test database URL:
echo 'export EKKLESIA_PORTAL_TEST_DB_URL="postgresql+psycopg2:///test_ekklesia_portal?host=/run/postgresql"' >> .envrc direnv allow
Populate the test database:
python tests/create_test_db.py
Run all tests:
pytest