Go to file
2024-11-12 20:33:59 +01:00
app fixed permissions 2016-01-30 18:29:45 +01:00
config Fix example mail 2024-11-12 20:27:18 +01:00
Handler Drop List to domain that does not exist, Improve From header 2024-08-10 17:45:26 +02:00
Import fixed permissions 2016-01-30 18:29:45 +01:00
messages Fix typo 2024-05-25 16:07:39 +02:00
Migration/0.0.0-0.0.1 Fix typo 2024-05-25 16:07:39 +02:00
Settings fixed permissions 2016-01-30 18:29:45 +01:00
static added swedish language support 2023-05-01 10:19:05 +02:00
templates Set language cookies with path root to prevent different languages on sub pages 2023-10-03 23:11:46 +02:00
test test: fix pending signatures 2020-06-05 19:28:14 +02:00
.gitignore ignore .stack-work 2016-03-17 21:20:56 +01:00
Application.hs adding PIN "protection" 2018-10-02 20:25:32 +02:00
CONTRIBUTING.md Create CONTRIBUTING.md 2017-02-12 14:05:30 +01:00
default.nix pkg.nix: rename from default.nix, add sensible default.nix 2020-12-03 17:14:55 +01:00
flake.lock Specify flake inputs and bump nixpkgs 2024-05-25 16:11:39 +02:00
flake.nix Fix declared by reference 2024-11-12 20:28:20 +01:00
Foundation.hs Foundation: fix schema in approotRequest 2021-03-06 01:58:20 +01:00
Import.hs fixed permissions 2016-01-30 18:29:45 +01:00
LICENSE.md fixed permissions 2016-01-30 18:29:45 +01:00
Model.hs fixed permissions 2016-01-30 18:29:45 +01:00
nixos-module.nix Move config out of default to allow easily expanding it 2024-11-12 20:33:59 +01:00
pkg.nix Fix license 2024-05-23 21:33:56 +02:00
README.md clarify zlib dependency 2018-02-15 22:55:10 +01:00
Settings.hs Nuke analytics and other google domains 2023-04-27 19:01:28 +02:00
shell.nix s/stdenv.lib/lib/ 2021-03-12 01:41:40 +01:00
yammat.cabal yammat.cabal: add extensions DataKinds, FlexibleInstances 2021-03-17 15:20:51 +01:00

yammat

Yet Another MateMAT

Introduction

This project aims to be an implementation for a trust based POS for hackerspaces.

Installation

Dependencies

Environment dependencies

A working Haskell capable environment. For that you will need ghc and cabal-install, which can be installed with:

sudo apt-get install ghc cabal-install

After you installed cabal-install, let it make itself comfortable in your system with

cabal update && cabal install cabal-install

This might, depending on your system setup, take some time. Brew yourself some tea.

Build dependencies

Now that your Haskell environment is set up, you need to install the dependencies for building and running yammat, which are:

  • build-essential
  • alex
  • happy
  • libpq-dev
  • postgresql
  • libfftw3-dev
  • zlib1g-dev

Install all of them through your package management system.

Building

First create a sandbox in the project directory with:

cabal sandbox init && cabal install --only-dependencies

This will take a long time, so go on a quest to find some cookies to go with the tea.

To build this project enter cabal build into your command line.

Enjoy your cookies and tea while you watch your yammat being built.

Deployment

Create a directory outside of the project directory, where you want to actually run the application. Copy or link the executable yammat from dist/build/yammat/ to your desired run location alongside with the folders static and config and their contenst. The Folders should be copied, or you may get problems with your git pulls.

Configuration

Database

To set up your database, Enter the postgresql root console (change to user postgres and invoke psql on a debian system). then create a user with

CREATE USER <username> WITH PASSWORD '<password>':

and then create the database and grant all privileges to the user with

CREATE DATABASE <databasename>;
GRANT ALL PRIVILEGES ON <databasename> to <username>;

Webapp

Let's leave the project directory and enter your desired run location. Check the configuration File config/settings.yml and alter its content to your liking. Most of these settings normally don't need to be altered much, except for approot. Change this setting to the root address with which you want to connect to the application, including the scheme (http or https). Additionally edit the settings email, currency and cash_charge.

  • email is the email address, which will receive notifications from yammat, should the stock run low.
  • currency is your currency sign or shorthand, which will be used when displaying prices.
  • cash_charge is the extra you want to charge your users, who pay cash.
    • Note: The value of this setting is in hundredths of your currency denomination.

cash_charge is effectively a "guest tax". Setting it to 0 is perfectly fine, if you don't want that.

Create a Postgresql User and Database according to the settings in the settings file and grant the user all privileges on the database.

Lift-Off

Run ./yammat config/settings.yml in your desired run location. Finally point a reverse-proxy (something like nginx) at http://localhost:3000 or any other port you configured in config/settings.yml.

For better control You can wrap an systemd unit file around this. How to do this is described in my blog.

Migrations

0.0.0-0.0.1

  • Delete column alt_time from table avatar in your Database with alter table "avatar" drop column "alt_time";
  • Start yammat normally to fill database with dummy data and stop it again
  • Run migration script
    • if you have built yammat with a sandbox, run runghc -package-db/full/path/to/sandbox(XXX-ghc-version-packages.conf.d /path/to/yammat/Migration/0.0.0-0.0.1/Migration.hs
      • Note: No space between the option -package-db and its argument
    • without sandbox: runghc /path/to/yammat/Migration/0.0.0-0.0.1/Migration.hs
  • Enjoy your freshly migrated Matemat

0.0.2-0.0.3

  • stop old matemat
  • create a view with new and old timestamps and user ids with create or replace view "user_new" as select "user".id, "user".timestamp, date 'epoch' + "user".timestamp * interval '1 second' as timestamp_new from "user";
  • create temporary timestamp column in user table with alter table "user" add column "timestamp_temp" date;
  • fill temporary timestamp column with new timestamps with update "user" set timestamp_temp = (select timestamp_new from user_new where user_new.id = "user".id);
  • check if new timestamps look sane
  • drop old timestamp column alter table "user" drop column timestamp cascade;
  • rename temporary column alter table "user" rename column timestamp_temp to "timestamp";
  • start new matemat