From b39e9cefd63e3a44132ddf245ff23dff2b62a16b Mon Sep 17 00:00:00 2001 From: James Eversole Date: Wed, 16 Oct 2024 15:54:34 -0500 Subject: [PATCH] Cabal updates --- HELPS.cabal | 55 +++++++++++++++++++++++++++++++++-------------------- flake.nix | 25 ++++++++++++++---------- result | 1 + src/Core.hs | 2 ++ 4 files changed, 52 insertions(+), 31 deletions(-) create mode 120000 result diff --git a/HELPS.cabal b/HELPS.cabal index cb43c27..0ece241 100644 --- a/HELPS.cabal +++ b/HELPS.cabal @@ -1,4 +1,4 @@ -cabal-version: 1.12 +cabal-version: 3.0 name: HELPS version: 0.0.1 @@ -9,13 +9,27 @@ copyright: James Eversole license: ISC license-file: LICENSE build-type: Simple +with-compiler: ghc-9.6.6 +documentation: True extra-source-files: README -executable Main - main-is: Main.hs - hs-source-dirs: - src +common global + build-depends: + base + , aeson + , bytestring + , effectful + , exceptions + , lucid + , mtl + , postgresql-simple + , resource-pool + , servant-server + , text + , time + , utf8-string + , warp default-extensions: BlockArguments ConstraintKinds @@ -31,25 +45,24 @@ executable Main StrictData TypeFamilies ghc-options: -threaded -rtsopts -with-rtsopts=-N -optl-pthread -fPIC - build-depends: - base - , aeson - , bytestring - , effectful - , exceptions - , lucid - , mtl - , postgresql-simple - , resource-pool - , servant-server - , text - , time - , utf8-string - , warp + default-language: GHC2021 + +executable Main + import: global + hs-source-dirs: + src + main-is: Main.hs other-modules: Core Database Handlers Logger Routes - default-language: GHC2021 + build-depends: + HELPS + +library + import: global + hs-source-dirs: + src + exposed-modules: Core, Database, Handlers, Logger, Routes diff --git a/flake.nix b/flake.nix index 4fcf4fe..e9b9b29 100644 --- a/flake.nix +++ b/flake.nix @@ -12,24 +12,29 @@ packageName = "HELPS"; containerPackageName = "${packageName}-container"; + c2n = haskellPackages.callCabal2nix packageName self rec {}; + HELPS = c2n.overrideAttrs (old: { + doHaddock = true; + enableSeparateDocOutput = false; + enableSharedExecutables = false; + enableSharedLibraries = false; + }); + haskellPackages = pkgs.haskellPackages; - - enableSharedExecutables = false; - enableSharedLibraries = false; - - HELPS = pkgs.haskell.lib.justStaticExecutables self.packages.${system}.default; in { - packages.${packageName} = - haskellPackages.callCabal2nix packageName self rec {}; + packages.${packageName} = pkgs.haskell.lib.justStaticExecutables HELPS; + packages.HELPSDocs = HELPS; packages.default = self.packages.${system}.${packageName}; defaultPackage = self.packages.${system}.default; devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ - ghcid - cabal-install - ghc + self.packages.${system}.default + pkgs.haskellPackages.cabal-install + pkgs.haskellPackages.ghc + pkgs.haskellPackages.ghcid + pkgs.haskellPackages.haskell-language-server ]; inputsFrom = builtins.attrValues self.packages.${system}; }; diff --git a/result b/result new file mode 120000 index 0000000..2fb4b94 --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/mjqr6gajan8a4nmhl4s6khq4lf6phrf3-HELPS-0.0.1 \ No newline at end of file diff --git a/src/Core.hs b/src/Core.hs index 7e8b54b..c69025d 100644 --- a/src/Core.hs +++ b/src/Core.hs @@ -68,7 +68,9 @@ data LogLevel = Info | Warning | Error instance ToField LogLevel where toField level = toField (T.pack (show level)) +-- -- Utility +-- liftIOE :: (IOE :> es, Error ServerError :> es) => IO a -> Eff es a -- Lift IO into Eff and catch IOExceptions liftIOE m = liftIO m `catch` \(e::IOException) -> do