(change the ~/ to wherever you actually put the directory)
In a new terminal (so it recognizes the new path),
you can rebuild and start the server in your snowdrift directory by running
yesod devel
To stop yesod devel, press ENTER a couple times
Note that `yesod devel` builds just the library,
so `cabal install` and related commands are needed to update other resources like sdm or the payment processing script.
APPENDIX B: Using the Nix package manager
=========================================
We're now testing the use of Nix as a reliable, simple way to manage packages for Snowdrift.
Once we have it fully working, it should help simplify building overall.
**The instructions in this appendix are just draft and need cleaning up.**
We're not sure each of these commands is best, it may change as we continue testing.
To install Nix, visit [NixOS.org/nix](https://nixos.org/nix/) and follow the "Get Nix" instructions (works for GNU/Linux and Mac OS).
*Note: Nix can take a lot of drive space, so if you do not have many GB of free space on your root partition, you may need to find another approach.
Free up space or put the `nix` directory somewhere else with more space and edit `/etc/fstab` to bind the location to mount at `/nix`.*
Next, log out and back into your whole system (the environment variables command shown at the end of the install script's output works for the immediate terminal session for a temporary fix).
[Nixpkgs](https://nixos.org/nixpkgs/), a collection of packages used by Nix, usually has only the latest packaged version and is a rolling-release distribution, which leaves us with two options:
* Update our code and dependencies whenever the unstable channel (or the master branch) is changed.
* Maintain our own collection of package versions that are known to work.
The former is clearly too much work and is not reliable anyway, so we use the latter approach.
It automatically switches to the right branch, so the only thing left is to point the [`NIX_PATH`](https://nixos.org/nix/manual/#sec-common-env) environment variable to the directory *containing* the `nixpkgs` repository.
For example, if a user cloned it to `/home/user`, that's the value they need to use:
export NIX_PATH=/home/user
Within the snowdrift project directory, run `nix-shell --pure -j4 shell.nix` to get necessary libraries and set `PATH` (the `-j4` part should be adapted to fit the number of cores on your machine).
The first time this is run, it will take a long time, but then will present you a new prompt within `nix-shell`.
Within the nix shell, run `cabal configure -fdev --enable-tests && cabal build -j4`
*Note the `-fdev` argument speeds up the build by bypassing optimization, which means the site runs slower, but that's not a problem for development work.*
This will take a *long* time but should ultimately tell you it built `Snowdrift`.
Since the `nix-shell` command changed your `PATH`, it doesn't have things like `sudo`, which is used by the `sdm` script.
Run `dist/build/sdm/sdm init`*outside* the nix shell (in a different terminal window) if you need to setup the databases.
Then, you can go back to the nix shell to run `cabal test`, which runs the testsuite.
You can run the application with `dist/build/Snowdrift/Snowdrift Development`.
Note for users of NixOS
-----------------------
To get the sdm script to work, NixOS users should install postgres by adding these lines to /etc/nixos/configuration.nix:
services.postgresql.enable = true;
services.postgresql.package = pkgs.postgresql94;
Then issue `sudo nixos-rebuild switch` to install.
Afterwards you may need to create the postgres user, like so:
sudo -su root
createuser -s -r postgres
APPENDIX C: Manual database management
======================================
Our sdm script makes database management quick and easy.
All the steps below can be done simply with the sdm script,
but here we explain what it does and how to handle databases manually if you prefer.
The commands below are written with GNU/Linux in mind.
***
Notes for Mac OS X
------------------
Assuming the postgres server is running, where `sudo -u postgres psql` is seen below, run `psql postgres` instead.
The commands that don't use psql can be adapted to run within the psql command line.
For Mac OS, instead of `sudo -u postgres psql snowdrift_development <devDB.sql` follow these steps:
1) Run `psql snowdrift_development`
2) At snowdrift_development=# prompt, run `\i devDB.sql`
Similar adjustments will be needed for the test database setup and resetting databases.
***
Setting up the development database manually
...
...
@@ -378,14 +484,10 @@ Setting up the development database manually
Go to the config/ directory within the project directory,
make a copy of postgresql.template, and name the new file postgresql.yml
Create database user called "snowdrift_development" *without* superuser, createdb, or createuser priveleges:
Create database user called "snowdrift_development" *without* superuser, createdb, or createuser privileges: