Tutorial: How to Install PartKeepr on NixOS Latest

PartKeepr is an open-source inventory management software designed to help you manage electronic components and other small parts. In this tutorial, we will walk you through how to install PartKeepr on NixOS Latest.

Prerequisites

Before starting the installation, ensure you have the following:

Step 1: Install Nixpkgs unstable

To install PartKeepr on NixOS Latest, we need to ensure we have access to the "unstable" distribution of Nixpkgs.

Open a terminal and run the following command to add the "unstable" channel to your Nix package management system:

$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable
$ nix-channel --update unstable

Step 2: Install Dependencies

Next, we need to install the dependencies required to run PartKeepr.

Open a terminal and run the following command to install the dependencies:

$ nix-shell -p mariadb mariadb-client nginx php php-fpm phpMyAdmin

Step 3: Download and Install PartKeepr

Now that we have installed the dependencies, we can proceed to download and install PartKeepr.

Open a terminal and run the following command to download and install PartKeepr:

$ sudo git clone https://github.com/partkeepr/PartKeepr.git /var/www/partkeepr
$ sudo chown www-data:www-data /var/www/partkeepr -R

Step 4: Configure PHP-FPM and Nginx

To allow PHP scripts to be executed, we need to configure PHP-FPM and Nginx.

Open a terminal and run the following commands to configure PHP-FPM:

$ sudo cp /nix/store/*-php-fpm-*/bin/php-fpm /run/php-fpm.sock
$ sudo chown www-data:www-data /run/php-fpm.sock

Next, open a text editor and create a new configuration file for Nginx:

$ sudo nano /etc/nginx/sites-available/partkeepr

Add the following configuration to the file:

server {
  listen 80;
  server_name yourdomain.com;
  root /var/www/partkeepr/Web/;
  index index.php;

  location / {
    try_files $uri $uri/ /index.php?$args;
  }

  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php-fpm.sock;
  }

  location /phpMyAdmin {
    alias /usr/share/phpMyAdmin/;
    index index.php;
    try_files $uri $uri/ /index.php?$args;

    location ~ \.php$ {
      include snippets/fastcgi-php.conf;
      fastcgi_pass unix:/run/php-fpm.sock;
    }
  }
}

Save the file and exit the editor.

Next, run the following commands to create a symbolic link and enable the site:

$ sudo ln -s /etc/nginx/sites-available/partkeepr /etc/nginx/sites-enabled/
$ sudo nginx -t
$ sudo systemctl reload nginx

Step 5: Setup MariaDB and PartKeepr

To set up MariaDB and PartKeepr, execute the following commands in sequence:

$ echo "CREATE DATABASE partkeepr DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;" | sudo mysql
$ echo "CREATE USER 'partkeepr'@'localhost' IDENTIFIED BY 'password';" | sudo mysql
$ echo "GRANT ALL ON partkeepr.* TO 'partkeepr'@'localhost';" | sudo mysql

$ cd /var/www/partkeepr
$ sudo cp app/config/parameters.yml.dist app/config/parameters.yml
$ sudo nano app/config/parameters.yml

In the parameters.yml file, update the following lines with your preferred settings:

database_host: 127.0.0.1
database_port: null
database_name: partkeepr
database_user: partkeepr
database_password: password

Save the file and exit the editor.

Finally, run the following commands to set up PartKeepr:

$ sudo php bin/console doctrine:schema:create
$ sudo php bin/console cache:clear
$ sudo chown www-data:www-data /var/www/partkeepr -R
$ sudo chmod +x /var/www/partkeepr/bin/console

Step 6: Access PartKeepr

You can now access PartKeepr by opening your web browser and navigating to http://yourdomain.com/.

Congratulations! You have successfully installed PartKeepr on NixOS Latest.

Conclusion

In this tutorial, we have walked you through how to install PartKeepr on NixOS Latest. If you have any questions or issues in following the tutorial, please feel free to leave a comment below.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!