diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Main.hs | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/app/Main.hs b/app/Main.hs index 4765405..07767a6 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -12,6 +12,7 @@ import Control.Concurrent import Control.Concurrent.STM import Control.Exception import Control.Monad +import Data.ByteString.Char8 qualified as B import Data.ByteString.Lazy qualified as LB import Data.ByteString.Lazy.UTF8 qualified as LB import Data.ByteString.UTF8 qualified as B @@ -19,6 +20,7 @@ import Data.List.Split import Data.Map.Merge.Strict qualified as M import Data.Map.Strict qualified as M import Data.Maybe +import Data.String import Data.String.Interpolate (i) import Data.Tagged import Data.Text qualified as T @@ -213,23 +215,34 @@ build logs builder buildJob@(BuildJob {jobName, commitHash}) = do rev = "#{rev}"; }) |] - (LB.lines -> out) <- - readProcessInterleaved_ - (setWorkingDir tmpDir "nix-build .") + ((B.toString . B.strip . LB.toStrict) -> drv, LB.lines -> err) <- + readProcess_ + (setWorkingDir tmpDir "nix-instantiate") mapM_ ( atomically . writeTQueue logs . BuildEntry builder buildJob ) - out - getSymbolicLinkTarget (tmpDir </> "result") + err + ((B.toString . B.strip . LB.toStrict) -> res, LB.lines -> err) <- + readProcess_ + ( setWorkingDir + tmpDir + (fromString (printf "nix-store --realise '%s'" drv)) + ) + mapM_ + ( atomically + . writeTQueue logs + . BuildEntry builder buildJob + ) + err + pure res exitCode <- atomically $ takeTMVar exitCodeT case exitCode of Left e -> throw e Right nixDir -> do createDirectoryIfMissing True jobName - _ <- try @SomeException (removeDirectoryLink refDir) - createDirectoryLink nixDir refDir + runProcess_ (fromString (printf "nix-store --add-root '%s' --realise '%s'" refDir nixDir)) watch :: INotify -> TVar DesiredOutputs -> JobName -> Url -> IO () watch inotify desiredOutputsT jobName url = do |