From 3aa1dd53d12f28f3de5ecb3e3e5d4457ea205803 Mon Sep 17 00:00:00 2001 From: Jappie Klooster Date: Fri, 13 May 2022 09:15:03 -0400 Subject: [PATCH] Change nix to not be kept up to date with cabal file These changes don't need to be kept up to date with cabal file This also closes https://github.com/snoyberg/keter/issues/263 Fix all incoming issues with this change --- .github/workflows/nix.yaml | 2 +- default.nix | 8 +++++ incoming/foo/hello.hs | 3 +- incoming/foo1_0/hello.hs | 3 +- incoming/websockets/chat.hs | 5 +-- nix/pin.nix | 4 +-- nix/pkgs.nix | 13 +++++++ shell.nix | 67 ++++++++----------------------------- 8 files changed, 43 insertions(+), 62 deletions(-) create mode 100644 default.nix create mode 100644 nix/pkgs.nix diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml index 07c48c6..1acc442 100644 --- a/.github/workflows/nix.yaml +++ b/.github/workflows/nix.yaml @@ -21,5 +21,5 @@ jobs: # signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' # # Only needed for private caches # #authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - # - run: nix-build nix/ci.nix + - run: nix-build . - run: nix-shell --run "cd incoming; make all" diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..a51e303 --- /dev/null +++ b/default.nix @@ -0,0 +1,8 @@ +{ pkgs ? import ./nix/pkgs.nix, ... }: +let + ignore = import (builtins.fetchGit { + url = "https://github.com/hercules-ci/gitignore.nix"; + rev = "bff2832ec341cf30acb3a4d3e2e7f1f7b590116a"; + }) { inherit (pkgs) lib; }; +in +pkgs.haskellPackages.callCabal2nix "keter" (ignore.gitignoreSource ./.) { } diff --git a/incoming/foo/hello.hs b/incoming/foo/hello.hs index ddb81ae..254b127 100644 --- a/incoming/foo/hello.hs +++ b/incoming/foo/hello.hs @@ -2,7 +2,6 @@ import Control.Monad.IO.Class import qualified Data.ByteString.Lazy.Char8 as L8 -import Data.Default import Network.HTTP.Types import Network.Wai import Network.Wai.Handler.Warp @@ -20,7 +19,7 @@ main = do portS <- getEnv "PORT" env <- getEnvironment let port = read portS - logger <- mkRequestLogger def + logger <- mkRequestLogger defaultRequestLoggerSettings { outputFormat = Apache FromHeader } run port $ logger $ \req send -> do diff --git a/incoming/foo1_0/hello.hs b/incoming/foo1_0/hello.hs index bd46061..fca14fd 100644 --- a/incoming/foo1_0/hello.hs +++ b/incoming/foo1_0/hello.hs @@ -2,7 +2,6 @@ import Control.Monad.IO.Class import qualified Data.ByteString.Lazy.Char8 as L8 -import Data.Default import Network.HTTP.Types import Network.Wai import Network.Wai.Handler.Warp @@ -19,7 +18,7 @@ main = do portS <- getEnv "PORT" env <- getEnvironment let port = read portS - logger <- mkRequestLogger def + logger <- mkRequestLogger defaultRequestLoggerSettings { outputFormat = Apache FromHeader } run port $ logger $ \req send -> do diff --git a/incoming/websockets/chat.hs b/incoming/websockets/chat.hs index 682aa2e..de7f6ef 100644 --- a/incoming/websockets/chat.hs +++ b/incoming/websockets/chat.hs @@ -18,12 +18,13 @@ import Yesod.WebSockets data App = App (TChan Text) -instance Yesod App mkYesod "App" [parseRoutes| / HomeR GET |] +instance Yesod App + chatApp :: WebSocketsT Handler () chatApp = do sendTextData ("Welcome to the chat server, please enter your name." :: Text) @@ -35,7 +36,7 @@ chatApp = do dupTChan writeChan race_ (forever $ atomically (readTChan readChan) >>= sendTextData) - (sourceWS $$ CL.mapM_ (\msg -> + (runConduit $ sourceWS .| CL.mapM_ (\msg -> atomically $ writeTChan writeChan $ name <> ": " <> msg)) getHomeR :: Handler Html diff --git a/nix/pin.nix b/nix/pin.nix index 5472859..139fc66 100644 --- a/nix/pin.nix +++ b/nix/pin.nix @@ -1,6 +1,6 @@ import (builtins.fetchGit { # Descriptive name to make the store path easier to identify - name = "nixos-pin-2022.03.02"; + name = "nixos-pin-2022.05.13"; url = "https://github.com/nixos/nixpkgs/"; - rev = "5d5de3be19855371eecbea5fd500818925ec109d"; + rev = "6925d06dd1e2039835ffe749cda11660431ffefa"; }) diff --git a/nix/pkgs.nix b/nix/pkgs.nix new file mode 100644 index 0000000..a4435ed --- /dev/null +++ b/nix/pkgs.nix @@ -0,0 +1,13 @@ +import ./pin.nix { + config = { + + packageOverrides = pkgs: { + + haskell = pkgs.lib.recursiveUpdate pkgs.haskell { + packageOverrides = hpNew: hpOld: { + keter = hpNew.callPackage ../default.nix {}; + }; + }; + }; + }; +} diff --git a/shell.nix b/shell.nix index b1f7590..0368cc9 100644 --- a/shell.nix +++ b/shell.nix @@ -1,54 +1,15 @@ -{ nixpkgs ? import ./nix/pin.nix {}, compiler ? "default", doBenchmark ? false }: - -let - - inherit (nixpkgs) pkgs; - - f = { mkDerivation, aeson, array, async, attoparsec, base - , blaze-builder, bytestring, case-insensitive, conduit - , conduit-extra, containers, data-default, directory, filepath - , fsnotify, hspec, http-client, http-conduit, http-reverse-proxy - , http-types, HUnit, indexed-traversable, lib, lifted-base, mtl - , network, optparse-applicative, process, random, regex-tdfa, stm - , tar, template-haskell, text, time, tls, tls-session-manager - , transformers, unix, unix-compat, unordered-containers, vector - , wai, wai-app-static, wai-extra, warp, warp-tls, yaml, zlib - , cabal-install, yesod, stm-lifted, yesod-websockets - }: - mkDerivation { - pname = "keter"; - version = "1.5"; - src = ./.; - isLibrary = true; - isExecutable = true; - libraryToolDepends = [ cabal-install ]; - libraryHaskellDepends = [ - aeson array async attoparsec base blaze-builder bytestring - case-insensitive conduit conduit-extra containers data-default - directory filepath fsnotify http-client http-conduit - http-reverse-proxy http-types indexed-traversable lifted-base mtl - network optparse-applicative process random regex-tdfa stm tar - template-haskell text time tls tls-session-manager transformers - unix unix-compat unordered-containers vector wai wai-app-static - wai-extra warp warp-tls yaml zlib yesod stm-lifted yesod-websockets +{ pkgs ? import ./nix/pkgs.nix, ... }: +pkgs.haskellPackages.shellFor { + packages = ps : [ ps.keter ]; + # this is to build the examples from incoming + extraDependencies = ps: { + libraryHaskellDepends = [ + ps.yesod-websockets + ps.yesod-core + ps.stm-lifted + ]; + }; + buildInputs = [ + pkgs.cabal-install ]; - executableHaskellDepends = [ base data-default filepath ]; - testHaskellDepends = [ - base bytestring conduit hspec HUnit transformers unix - ]; - homepage = "http://www.yesodweb.com/"; - description = "Web application deployment manager, focusing on Haskell web frameworks"; - license = lib.licenses.mit; - }; - - haskellPackages = if compiler == "default" - then pkgs.haskellPackages - else pkgs.haskell.packages.${compiler}; - - variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; - - drv = variant (haskellPackages.callPackage f {}); - -in - - if pkgs.lib.inNixShell then drv.env else drv +}