From 30d03210f7ac5b12235760f625bac5ff3aa3f85a Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 16 Aug 2023 13:45:40 -0400 Subject: Log and return output to caller The main change here is 'puts' now returns a value, this enables me to collect the value from the conduit source while also doing stuff with it, like printing or logging it as I want. Previously I was running conduit over the source, *and then* kicking off the concurrent processes to wait for the process and collect the output. This would (I think) drain the source before it got to the 'puts' conduit run, and so I wouldn't be able to get the output streamed in real time. It took a lot of refactoring and exploratory programming to get to this relatively-small diff, but now puts works correctly. At least I think it does... it seems to work more reliably from ghci than from the shell. Maybe the shell or TERM is causing nix-store to do some buffering? Maybe I need to use the threaded runtime in GHC? Not sure, but I will look out for this issue and try to identify and fix. Update: yep it was the threaded runtime. I enabled that and now it works in the shell. I squashed that commit into this one. --- Biz/Bild.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Biz/Bild.nix') diff --git a/Biz/Bild.nix b/Biz/Bild.nix index 0391d84..dca1b3b 100644 --- a/Biz/Bild.nix +++ b/Biz/Bild.nix @@ -32,7 +32,7 @@ rec { ghcPackageSetBild = private.ghcWith (hpkgs: with hpkgs; [ aeson async base bytestring conduit conduit-extra containers directory docopt filepath process protolude rainbow regex-applicative split tasty - tasty-hunit tasty-quickcheck text neat-interpolation + tasty-hunit tasty-quickcheck text hostname wai # can remove when removed from Biz.Log ]); @@ -50,14 +50,13 @@ rec { # this is just to get access to ghc-pkg in bild (private.ghcWith (hpkgs: with hpkgs; [])) - /* disable until nixified builds are complete + /* disable until nixified builds are complete */ rustc # c deps gcc gdb valgrind argp-standalone SDL # lisp deps guile (private.sbclWith (p: with p; [asdf alexandria])) # just enough to build Example.lisp - */ ]; # a standard nix build for `bild` - this should be the only hand-written @@ -75,6 +74,7 @@ rec { ${private.ghcPackageSetFull}/lib/ghc-${private.ghcPackageSetFull.version}/package.conf.d \ $out/lib/ghc-${private.ghcPackageSetFull.version} ghc \ + -threaded \ -Werror \ -i. \ --make Biz/Bild.hs \ -- cgit v1.2.3