Giter Site home page Giter Site logo

yesod-boilerplate's Introduction

readme

Setup

stack new yesod-boilerplate yesodweb/postgres

nix-shell

since I am using nixos I shall use nix to manage my packages instead of stack or cabal. Using nix has the advantage of sharing stack dependencies. By default stack would pull a new copy of the same packages for different projects.

Add to stack.yaml

nix:
  enable: true
  shell-file: shell.nix

Generate shell.nix

cabal2nix . > yesod-boilerplate.nix

Then pull out the packages required from yesod-boilerplate.nix

{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc865" }:

let
  inherit (nixpkgs) pkgs;
  #final01 = import ./default.nix {};
  ghc = pkgs.haskell.packages.${compiler}.ghcWithPackages (ps: with ps; [
    aeson base bytestring case-insensitive classy-prelude
    classy-prelude-conduit classy-prelude-yesod conduit containers
    data-default directory fast-logger file-embed foreign-store hjsmin
    http-client-tls http-conduit monad-control monad-logger persistent
    persistent-postgresql persistent-template safe shakespeare
    template-haskell text time unordered-containers vector wai
    wai-extra wai-logger warp yaml yesod yesod-auth yesod-core
    yesod-form yesod-static
    markdown
    yesod-text-markdown
  ]);
  systemPackages = with pkgs; [
    # add whatever system packages you want.
    binutils
    gcc
    ghc

    postgresql
    zlib
    zlib.dev
  ];
in
  pkgs.stdenv.mkDerivation {
    name = "yesod-boilerplate";
    buildInputs = [ ghc systemPackages ];
    shellHook = ''
      eval $(egrep ^export ${ghc}/bin/ghc)
    '';
}

Database Migrations

We then need to setup our database, I use nix to generate a postgresql db for me

services.postgresql = {
  enable = true;
  package = pkgs.postgresql;
  enableTCPIP = true;
  authentication = pkgs.lib.mkOverride 10 ''
    local all all trust
    host all all ::1/128 trust
  '';
  initialScript = pkgs.writeText "backend-initScript" ''
    CREATE ROLE detentionbarracksuser WITH LOGIN PASSWORD 'detentionbarrackspassword' CREATEDB;
    CREATE DATABASE detensionBarracks;
    GRANT ALL PRIVILEGES ON DATABASE detensionbarracks TO detentionbarracksuser;
  '';
};

Then we need to edit ./config/settings.yml to reflect the correct db settings

Now we are ready to begin!

yesod-boilerplate's People

Contributors

tomatocream avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.