Browse Source

Add Iolaus.Opaleye.Config

master
Peter J. Jones 3 months ago
commit
89365ec505
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49

+ 4
- 0
.envrc View File

@@ -0,0 +1,4 @@
# -*- sh -*-

# Load in the shell.nix file:
use nix

+ 1
- 0
.gitignore View File

@@ -0,0 +1 @@
/**/dist/

+ 26
- 0
LICENSE View File

@@ -0,0 +1,26 @@
Copyright (c) 2019 Peter J. Jones <pjones@devalot.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the
distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 0
- 0
README.md View File


+ 6
- 0
default.nix View File

@@ -0,0 +1,6 @@
{ pkgs ? import <nixpkgs> { }
, haskell ? pkgs.haskellPackages
}:

# FIXME:
import ./opaleye { inherit pkgs haskell; }

+ 7
- 0
opaleye/CHANGELOG.md View File

@@ -0,0 +1,7 @@
Revision History for iolaus-opaleye
===================================

0.1.0.0 -- YYYY-mm-dd
---------------------

* First version. Released on an unsuspecting world.

+ 1
- 0
opaleye/LICENSE View File

@@ -0,0 +1 @@
../LICENSE

+ 0
- 0
opaleye/README.md View File


+ 2
- 0
opaleye/Setup.hs View File

@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain

+ 5
- 0
opaleye/default.nix View File

@@ -0,0 +1,5 @@
{ pkgs ? import <nixpkgs> {}
, haskell ? pkgs.haskellPackages
}:

haskell.callPackage ./iolaus-opaleye.nix { }

+ 50
- 0
opaleye/iolaus-opaleye.cabal View File

@@ -0,0 +1,50 @@
cabal-version: 2.2

--------------------------------------------------------------------------------
name: iolaus-opaleye
version: 0.1.0.0
synopsis: Common bits of Opaleye that you need in all your apps.
description: Please see the README.md file.
license: BSD-2-Clause
license-file: LICENSE
author: Peter Jones <pjones@devalot.com>
maintainer: Peter Jones <pjones@devalot.com>
copyright: Copyright (c) 2019 Peter Jones
category: Application
-- bug-reports:

--------------------------------------------------------------------------------
extra-source-files: CHANGELOG.md

--------------------------------------------------------------------------------
common options
default-language: Haskell2010
ghc-options: -Wall
-Werror=incomplete-record-updates
-Werror=incomplete-uni-patterns
-Werror=missing-home-modules
-Widentities
-Wmissing-export-lists
-Wredundant-constraints

--------------------------------------------------------------------------------
common dependencies
build-depends: base >= 4.9 && < 5.0
, aeson >= 1.3 && < 1.5
, dhall >= 1.19 && < 2.0
, opaleye >= 0.6 && < 0.7
, postgresql-simple >= 0.5 && < 0.7
, postgresql-simple-migration >= 0.1 && < 0.2
, product-profunctors >= 0.10 && < 0.11
, resource-pool >= 0.2 && < 0.3
, retry >= 0.7 && < 0.8
, text >= 1.2 && < 1.3

library
import: options, dependencies
hs-source-dirs: src
exposed-modules:
Iolaus.Opaleye

other-modules:
Iolaus.Opaleye.Config

+ 16
- 0
opaleye/iolaus-opaleye.nix View File

@@ -0,0 +1,16 @@
{ mkDerivation, aeson, base, dhall, opaleye, postgresql-simple
, postgresql-simple-migration, product-profunctors, resource-pool
, retry, stdenv, text
}:
mkDerivation {
pname = "iolaus-opaleye";
version = "0.1.0.0";
src = ./.;
libraryHaskellDepends = [
aeson base dhall opaleye postgresql-simple
postgresql-simple-migration product-profunctors resource-pool retry
text
];
description = "Common bits of Opaleye that you need in all your apps";
license = stdenv.lib.licenses.bsd2;
}

+ 22
- 0
opaleye/src/Iolaus/Opaleye.hs View File

@@ -0,0 +1,22 @@
{-|

Copyright:
This file is part of the package iolaus. It is subject to the
license terms in the LICENSE file found in the top-level directory
of this distribution and at:

https://code.devalot.com/open/iolaus.git

No part of this package, including this file, may be copied,
modified, propagated, or distributed except according to the terms
contained in the LICENSE file.

License: BSD-2-Clause

-}
module Iolaus.Opaleye
( Config(..)
) where

--------------------------------------------------------------------------------
import Iolaus.Opaleye.Config

+ 60
- 0
opaleye/src/Iolaus/Opaleye/Config.hs View File

@@ -0,0 +1,60 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}

{-|

Copyright:
This file is part of the package iolaus. It is subject to the
license terms in the LICENSE file found in the top-level directory
of this distribution and at:

https://code.devalot.com/open/iolaus.git

No part of this package, including this file, may be copied,
modified, propagated, or distributed except according to the terms
contained in the LICENSE file.

License: BSD-2-Clause

-}
module Iolaus.Opaleye.Config
( Config(..)
) where

--------------------------------------------------------------------------------
-- Library Imports:
import Data.Aeson (ToJSON, FromJSON)
import Data.Text (Text)
import Dhall (Interpret)
import GHC.Generics (Generic)
import Numeric.Natural (Natural)

--------------------------------------------------------------------------------
-- | Database configuration.
--
-- There are several ways to parse a configuration file that contains
-- the fields from this record:
--
-- * Use the 'Dhall.inputFile' function from the @dhall@ package.
-- * Decode from JSON via the @aeson@ package.
-- * Decode from YAML via the @yaml@ package.
--
data Config = Config
{ connectionString :: Text
-- ^ libpq connection string.

, poolSize :: (Maybe Natural)
-- ^ Size of the database connection pool. A value of 'Nothing'
-- means to use the default value.

, retries :: (Maybe Natural)
-- ^ Number of times to retry a failed query. Set to @0@ to
-- disable. (A value of 'Nothing' means to use the default.)

, backoff :: (Maybe Natural)
-- ^ Number of microseconds (\(10^{-6}\)) to wait before retrying a
-- failed query. This value is increased exponentially after each
-- subsequent failure. (A value of 'Nothing' means use the
-- default.)

} deriving (Generic, Show, Eq, Interpret, ToJSON, FromJSON)

+ 27
- 0
shell.nix View File

@@ -0,0 +1,27 @@
{ pkgs ? (import <nixpkgs> {}).pkgs
}:

let
nix-hs-src = fetchGit {
url = "https://code.devalot.com/pjones/nix-hs.git";
rev = "4a9ea2c8c6712ae3cb5892bc74dc051906535238";
};

nix-hs = (import "${nix-hs-src}/default.nix" {inherit pkgs;});

in

pkgs.mkShell {
buildInputs = with pkgs; [

# Haskell Dependencies:
haskellPackages.ghc
haskellPackages.cabal-install

# For IDEs:
nix-hs
haskellPackages.hoogle
haskellPackages.hlint
# haskellPackages.cabal-dependency-licenses
];
}

Loading…
Cancel
Save