Installing StockazNG on NixOS
StockazNG is a web-based asset management system written in Python. It allows users to scan barcodes, add assets, and track their location and status.
Prerequisites
Before we start the installation process, make sure you have NixOS Latest installed on your system with root privileges.
Installation
Step 1: Create a new system user
In order to install and run StockazNG, we will create a dedicated system user for it.
$ sudo useradd -r stockazng
Step 2: Install and configure PostgreSQL
StockazNG uses PostgreSQL as its default database backend. To install PostgreSQL, execute the following command:
$ sudo nix-env -i postgresql
Next, we will create a new database and user for StockazNG.
$ sudo -u postgres psql -c "CREATE DATABASE stockazng;"
$ sudo -u postgres psql -c "CREATE USER stockazng WITH PASSWORD 'password';"
$ sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE stockazng TO stockazng;"
Step 3: Install and configure StockazNG
First, clone the repository and switch to the latest release branch.
$ git clone https://dev.sigpipe.me/dashie/StockazNG.git
$ cd StockazNG
$ git checkout release
Next, create a new virtual environment for StockazNG.
$ sudo -u stockazng bash -c "python3 -m venv env && source env/bin/activate"
Then, install the required dependencies.
$ sudo -u stockazng bash -c "pip install -r requirements.txt"
Finally, configure StockazNG by initializing the database and setting up the server.
$ sudo -u stockazng bash -c "python manage.py migrate"
$ sudo -u stockazng bash -c "python manage.py createsuperuser"
Step 4: Configure the StockazNG service
Create a new systemd service file.
$ sudo nano /etc/systemd/system/stockazng.service
Copy and paste the following into the file.
[Unit]
Description=StockazNG Asset Management System
After=network.target
[Service]
User=stockazng
Group=stockazng
WorkingDirectory=/path/to/StockazNG/
Environment="PATH=/path/to/StockazNG/env/bin"
ExecStart=/path/to/StockazNG/env/bin/python /path/to/StockazNG/manage.py runserver 0.0.0.0:8000
[Install]
WantedBy=multi-user.target
Save and close the file.
Finally, start and enable the service.
$ sudo systemctl start stockazng
$ sudo systemctl enable stockazng
Step 5: Access StockazNG
You can now access StockazNG by visiting your server's IP address or domain name followed by port 8000 in your web browser.
http://your_ip_address_or_domain_name:8000/
Login with the credentials you created earlier when initializing the database.
Conclusion
You have successfully installed and configured StockazNG on NixOS Latest. You can now begin managing assets and tracking their location and status with ease.