[nix] make it build
This commit is contained in:
parent
12099b5e9e
commit
9cdd10eb0e
19
app/Main.hs
19
app/Main.hs
@ -11,8 +11,7 @@ import Servant
|
||||
import Control.Monad.IO.Class
|
||||
import Servant.HTML.Blaze
|
||||
import qualified Data.Text as T
|
||||
import Data.Text.Encoding (decodeUtf8)
|
||||
import Crypto.Argon2
|
||||
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
|
||||
import Data.Text.Short (fromText, ShortText)
|
||||
import Data.ByteString (ByteString)
|
||||
|
||||
@ -36,7 +35,7 @@ type API = Get '[HTML] Quote
|
||||
|
||||
api :: Proxy API
|
||||
api = Proxy
|
||||
|
||||
{-
|
||||
checkBasicAuth :: T.Text -> ShortText -> BasicAuthCheck User
|
||||
checkBasicAuth user passhash = BasicAuthCheck $ \authData ->
|
||||
let u = decodeUtf8 (basicAuthUsername authData)
|
||||
@ -48,6 +47,20 @@ checkBasicAuth user passhash = BasicAuthCheck $ \authData ->
|
||||
Argon2Ok -> return $ Authorized $ User u p
|
||||
_ -> return Unauthorized
|
||||
|
||||
-}
|
||||
checkBasicAuth :: T.Text -> ShortText -> BasicAuthCheck User
|
||||
checkBasicAuth _ _ = BasicAuthCheck $ \_ -> return NoSuchUser
|
||||
|
||||
initDb :: FilePath -> IO ()
|
||||
initDb dbFile = withConnection dbFile $ \conn ->
|
||||
execute_ conn
|
||||
[sql|CREATE TABLE IF NOT EXISTS quotes ( quote text non null
|
||||
, author text
|
||||
, title text
|
||||
, page text
|
||||
, chapter text
|
||||
, created_on integer);|]
|
||||
|
||||
-- | TODO: readerT
|
||||
server :: FilePath -> Server API
|
||||
server dbf = randomQuote dbf
|
||||
|
60
flake.lock
Normal file
60
flake.lock
Normal file
@ -0,0 +1,60 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1699562885,
|
||||
"narHash": "sha256-fb7RDv0ePGzayhGvkBh9NrilU3pCecgfbbTNPHprRfg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "97b0ae26f7c8a1682b5437a64edcd73ab1798c9b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
44
flake.nix
Normal file
44
flake.nix
Normal file
@ -0,0 +1,44 @@
|
||||
# SPDX-FileCopyrightText: 2021 Serokell <https://serokell.io/>
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
{
|
||||
description = "quotes-api";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
haskellPackages = pkgs.haskellPackages;
|
||||
|
||||
jailbreakUnbreak = pkg:
|
||||
pkgs.haskell.lib.doJailbreak (pkg.overrideAttrs (_: { meta = { }; }));
|
||||
|
||||
# DON'T FORGET TO PUT YOUR PACKAGE NAME HERE, REMOVING `throw`
|
||||
packageName = "quptes-api";
|
||||
in {
|
||||
packages.${packageName} = haskellPackages.callCabal2nix packageName self
|
||||
rec {
|
||||
# Dependency overrides go here
|
||||
};
|
||||
|
||||
packages.default = self.packages.${system}.${packageName};
|
||||
defaultPackage = self.packages.${system}.default;
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
haskellPackages.haskell-language-server # you must build it with your ghc to work
|
||||
ghcid
|
||||
cabal-install
|
||||
];
|
||||
inputsFrom =
|
||||
map (__getAttr "env") (__attrValues self.packages.${system});
|
||||
};
|
||||
devShell = self.devShells.${system}.default;
|
||||
});
|
||||
}
|
@ -71,7 +71,7 @@ library
|
||||
-- other-extensions:
|
||||
|
||||
-- Other library packages from which modules are imported.
|
||||
build-depends: base ^>=4.16.3.0,
|
||||
build-depends: base,
|
||||
text,
|
||||
aeson,
|
||||
deriving-aeson,
|
||||
@ -104,10 +104,10 @@ executable quotes-api
|
||||
|
||||
-- Other library packages from which modules are imported.
|
||||
build-depends:
|
||||
base ^>=4.16.3.0,
|
||||
sqlite-simple ^>=0.4.18.0,
|
||||
text ^>=1.2.5.0,
|
||||
servant-server ^>=0.19.1,
|
||||
base,
|
||||
sqlite-simple,
|
||||
text,
|
||||
servant-server,
|
||||
wai,
|
||||
warp,
|
||||
aeson,
|
||||
@ -115,7 +115,7 @@ executable quotes-api
|
||||
quotes-api,
|
||||
servant-blaze,
|
||||
optparse-applicative,
|
||||
argon2 >= 1.3.0,
|
||||
-- argon2,
|
||||
text-short,
|
||||
bytestring,
|
||||
QuickCheck,
|
||||
@ -186,5 +186,5 @@ test-suite quotes-api-test
|
||||
|
||||
-- Test dependencies.
|
||||
build-depends:
|
||||
base ^>=4.16.3.0,
|
||||
base,
|
||||
quotes-api
|
||||
|
23
shell.nix
23
shell.nix
@ -1,23 +0,0 @@
|
||||
{ pkgs ? import <unstable> {}
|
||||
}:
|
||||
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
name = "quotes-api";
|
||||
|
||||
nativeBuildInputs = [
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
pkgs.zlib
|
||||
pkgs.ghc
|
||||
pkgs.cabal-install
|
||||
pkgs.haskellPackages.ghcid
|
||||
pkgs.haskellPackages.cabal-plan
|
||||
pkgs.haskellPackages.haskell-language-server
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath buildInputs}:$LD_LIBRARY_PATH
|
||||
export LANG=en_US.UTF-8
|
||||
'';
|
||||
}
|
Loading…
Reference in New Issue
Block a user