no more tls & swap nix flake template
This commit is contained in:
parent
842bf44a88
commit
fff0b6175a
5 changed files with 100 additions and 72 deletions
|
|
@ -1,2 +1,3 @@
|
|||
allow-newer: servant, servant-server, *:servant-server, *:base, lucid-htmx:*
|
||||
packages: rcv-site.cabal
|
||||
packages:
|
||||
./
|
||||
allow-newer: servant, servant-server, *:servant-server, *:base, lucid-htmx:*, beam:*
|
||||
|
|
|
|||
78
flake.lock
generated
78
flake.lock
generated
|
|
@ -1,58 +1,78 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1689068808,
|
||||
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
|
||||
"lastModified": 1690933134,
|
||||
"narHash": "sha256-ab989mN63fQZBFrkk4Q8bYxQCktuHmBIBqUG1jl6/FQ=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "59cf3f1447cfc75087e7273b04b31e689a8599fb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"haskell-flake": {
|
||||
"locked": {
|
||||
"lastModified": 1690398210,
|
||||
"narHash": "sha256-1wnx2K3U2xmUI5rUulOZ66tcIva+OGWS47dyHdZJjsA=",
|
||||
"owner": "srid",
|
||||
"repo": "haskell-flake",
|
||||
"rev": "d3c8d8be31d3a5dcf9d49e9dacfc570b5c736658",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "srid",
|
||||
"repo": "haskell-flake",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1690924695,
|
||||
"narHash": "sha256-1yshNzds/qJztMoJk0Sa2xhKwSLaOAuepR6ABWbrgRU=",
|
||||
"owner": "NixOS",
|
||||
"lastModified": 1691403902,
|
||||
"narHash": "sha256-J74y4xWtKPDPyVtF4arzrwuSOGznlFlJ+uB9RwNNnbo=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "7282565b1ca9ba7b293b899411e70167f4a7c1ff",
|
||||
"rev": "c91024273f020df2dcb209cc133461ca17848026",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"dir": "lib",
|
||||
"lastModified": 1690881714,
|
||||
"narHash": "sha256-h/nXluEqdiQHs1oSgkOOWF+j8gcJMWhwnZ9PFabN6q0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9e1960bc196baf6881340d53dccb203a951745a2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"dir": "lib",
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"flake-parts": "flake-parts",
|
||||
"haskell-flake": "haskell-flake",
|
||||
"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",
|
||||
|
|
|
|||
76
flake.nix
76
flake.nix
|
|
@ -1,43 +1,53 @@
|
|||
# SPDX-FileCopyrightText: 2021 Serokell <https://serokell.io/>
|
||||
#
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
{
|
||||
description = "My haskell application";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
haskell-flake.url = "github:srid/haskell-flake";
|
||||
};
|
||||
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = nixpkgs.lib.systems.flakeExposed;
|
||||
imports = [ inputs.haskell-flake.flakeModule ];
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
perSystem = { self', pkgs, ... }: {
|
||||
|
||||
haskellPackages = pkgs.haskellPackages;
|
||||
# Typically, you just want a single project named "default". But
|
||||
# multiple projects are also possible, each using different GHC version.
|
||||
haskellProjects.default = {
|
||||
# The base package set representing a specific GHC version.
|
||||
# By default, this is pkgs.haskellPackages.
|
||||
# You may also create your own. See https://zero-to-flakes.com/haskell-flake/package-set
|
||||
# basePackages = pkgs.haskellPackages;
|
||||
|
||||
jailbreakUnbreak = pkg:
|
||||
pkgs.haskell.lib.doJailbreak (pkg.overrideAttrs (_: { meta = { }; }));
|
||||
# Extra package information. See https://zero-to-flakes.com/haskell-flake/dependency
|
||||
#
|
||||
# Note that local packages are automatically included in `packages`
|
||||
# (defined by `defaults.packages` option).
|
||||
#
|
||||
# packages = {
|
||||
# base.source = "4.17.0.0"; # Hackage version override
|
||||
# };
|
||||
# settings = {
|
||||
# beam = {
|
||||
# broken = false;
|
||||
# jailbreak = true;
|
||||
# };
|
||||
# };
|
||||
|
||||
# DON'T FORGET TO PUT YOUR PACKAGE NAME HERE, REMOVING `throw`
|
||||
packageName = "rcv-site";
|
||||
in {
|
||||
packages.${packageName} =
|
||||
haskellPackages.callCabal2nix packageName self rec {
|
||||
# Dependency overrides go here
|
||||
devShell = {
|
||||
# Enabled by default
|
||||
enable = true;
|
||||
|
||||
# Programs you want to make available in the shell.
|
||||
# Default programs can be disabled by setting to 'null'
|
||||
tools = hp: { sqlite = pkgs.sqlite; haskell-language-server = pkgs.haskell-language-server ; ghcid = null; };
|
||||
|
||||
hlsCheck.enable = true;
|
||||
};
|
||||
|
||||
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
|
||||
cabal-install
|
||||
];
|
||||
inputsFrom = map (__getAttr "env") (__attrValues self.packages.${system});
|
||||
};
|
||||
devShell = self.devShells.${system}.default;
|
||||
});
|
||||
|
||||
# haskell-flake doesn't set the default package, but you can do it here.
|
||||
packages.default = self'.packages.rcv-site;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ executable rcv-site
|
|||
build-depends:
|
||||
acid-state,
|
||||
aeson,
|
||||
-- beam-sqlite,
|
||||
-- beam-core,
|
||||
-- sqlite-simple,
|
||||
async,
|
||||
base,
|
||||
bytestring,
|
||||
|
|
@ -70,6 +73,7 @@ executable rcv-site
|
|||
other-modules:
|
||||
API
|
||||
Database
|
||||
-- BeamDatabase
|
||||
InstantRunoff
|
||||
Error
|
||||
Poll
|
||||
|
|
|
|||
|
|
@ -233,17 +233,10 @@ emptyApp _ respondf = respondf $ NW.responseLBS TS.status200 [] "redirecting to
|
|||
main :: IO ()
|
||||
main = do
|
||||
env <- getEnv
|
||||
opts <- S.getArgs
|
||||
M.void . liftIO $ Ac.update (db env) (DB.CreatePoll examplePoll (P.PollId 7))
|
||||
M.void . liftIO $ Ac.update (db env) (DB.PostBallot (P.PollId 7) (B.Ballot ["blue", "green", "yellow", "orange", "pink"]))
|
||||
M.void . liftIO $ Ac.update (db env) (DB.PostBallot (P.PollId 7) (B.Ballot ["blue", "red", "pink", "purple", "green"]))
|
||||
M.void . liftIO $ Ac.update (db env) (DB.PostBallot (P.PollId 7) (B.Ballot ["purple", "black", "yellow", "orange", "blue"]))
|
||||
print =<< Ac.query (db env) (DB.GetPoll (P.PollId 14836861905326358375))
|
||||
mapM_ print =<< (liftIO . Ac.query (db env) $ DB.GetPollIds)
|
||||
let application = serve api . hoistServer api (runWithEnv env) $ server
|
||||
case opts of -- TODO: allow more command-line options like tls & domain
|
||||
["--with-tls"] -> do
|
||||
httpsSite <- A.async $ WTLS.runTLS tlsSettings warpSettings application
|
||||
httpSite <- A.async $ W.run 80 $ TLS.forceSSL emptyApp
|
||||
M.void $ A.waitAny [httpsSite, httpSite]
|
||||
_ -> W.run 8080 application
|
||||
W.run 8080 application
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue