about summary refs log tree commit diff
path: root/users/Profpatsch/lorri-wait-for-eval
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2023-04-08T12·18+0200
committerclbot <clbot@tvl.fyi>2023-04-08T12·25+0000
commit260626e0165b9b6ca330d75f830d06fa08b5d4b7 (patch)
tree5cbc230faa9e38305bcffed2e1942fe490931c50 /users/Profpatsch/lorri-wait-for-eval
parentca7c1a4eae3adc1aa9f8b2bb3a6cd1c023117d97 (diff)
refactor(users/Profpatsch/lorri-wait-for-eval): use MyPrelude r/6082
Change-Id: I45aec0cd178cd51b1857b576e9c3a8ccc1866100
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8469
Autosubmit: Profpatsch <mail@profpatsch.de>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/Profpatsch/lorri-wait-for-eval')
-rw-r--r--users/Profpatsch/lorri-wait-for-eval/LorriWaitForEval.hs23
-rw-r--r--users/Profpatsch/lorri-wait-for-eval/default.nix1
2 files changed, 5 insertions, 19 deletions
diff --git a/users/Profpatsch/lorri-wait-for-eval/LorriWaitForEval.hs b/users/Profpatsch/lorri-wait-for-eval/LorriWaitForEval.hs
index 180def3425a9..a1a45864019c 100644
--- a/users/Profpatsch/lorri-wait-for-eval/LorriWaitForEval.hs
+++ b/users/Profpatsch/lorri-wait-for-eval/LorriWaitForEval.hs
@@ -17,20 +17,14 @@ import Control.Concurrent.Async qualified as Async
 import Control.Monad
 import Data.Aeson.BetterErrors qualified as Json
 import Data.Bifunctor
-import Data.ByteString (ByteString)
 import Data.Conduit.Binary qualified as Conduit.Binary
 import Data.Conduit.Combinators qualified as Cond
 import Data.Conduit.Process
 import Data.Error
 import Data.Function
 import Data.Functor
-import Data.List.NonEmpty (NonEmpty ((:|)), nonEmpty)
-import Data.Text (Text)
-import Data.Text qualified as Text
-import Data.Text.Encoding qualified
-import Data.Text.Encoding.Error qualified
 import Data.Text.IO (hPutStrLn)
-import PyF
+import MyPrelude
 import System.Directory qualified as Dir
 import System.Environment qualified as Env
 import System.Exit qualified as Exit
@@ -49,7 +43,7 @@ data LorriEvent = LorriEvent
 data LorriEventType
   = Completed
   | Started
-  | Failure
+  | EvalFailure
   deriving stock (Show)
 
 main :: IO ()
@@ -92,7 +86,7 @@ main = do
                               "Failure"
                               ( do
                                   nixFile <- Json.key "nix_file" Json.asText
-                                  pure LorriEvent {nixFile, eventType = Failure}
+                                  pure LorriEvent {nixFile, eventType = EvalFailure}
                               )
                         )
                       & first Json.displayError'
@@ -120,7 +114,7 @@ main = do
                 Completed -> do
                   log [fmt|build completed|]
                   exec (inDirenvDir (takeDirectory shellNix) <$> argv)
-                Failure -> do
+                EvalFailure -> do
                   log [fmt|evaluation failed! for path {ev & nixFile}|]
                   Exit.exitWith (Exit.ExitFailure 111)
 
@@ -170,9 +164,6 @@ findShellNix curDir = do
               else go parent
   go (FilePath.normalise curDir)
 
-textToString :: Text -> String
-textToString = Text.unpack
-
 smushErrors :: Foldable t => Text -> t Error -> Error
 smushErrors msg errs =
   errs
@@ -180,9 +171,3 @@ smushErrors msg errs =
     & foldMap (\err -> "\n- " <> prettyError err)
     & newError
     & errorContext msg
-
--- | decode a Text from a ByteString that is assumed to be UTF-8,
--- replace non-UTF-8 characters with the replacment char U+FFFD.
-bytesToTextUtf8Lenient :: Data.ByteString.ByteString -> Data.Text.Text
-bytesToTextUtf8Lenient =
-  Data.Text.Encoding.decodeUtf8With Data.Text.Encoding.Error.lenientDecode
diff --git a/users/Profpatsch/lorri-wait-for-eval/default.nix b/users/Profpatsch/lorri-wait-for-eval/default.nix
index af8135839a52..90c6365fed5a 100644
--- a/users/Profpatsch/lorri-wait-for-eval/default.nix
+++ b/users/Profpatsch/lorri-wait-for-eval/default.nix
@@ -4,6 +4,7 @@ let
   lorri-wait-for-eval = pkgs.writers.writeHaskell "lorri-wait-for-eval"
     {
       libraries = [
+        depot.users.Profpatsch.my-prelude
         pkgs.haskellPackages.async
         pkgs.haskellPackages.aeson-better-errors
         pkgs.haskellPackages.conduit-extra