From a2a9bcafc118e186c440881ccd08b07d24ec808e Mon Sep 17 00:00:00 2001 From: Ryan Mulligan Date: Sat, 1 Aug 2020 10:02:38 -0700 Subject: [PATCH] skip updateScript rewriter if there is no updateScript --- src/Rewrite.hs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Rewrite.hs b/src/Rewrite.hs index 1442267..df63a74 100644 --- a/src/Rewrite.hs +++ b/src/Rewrite.hs @@ -243,16 +243,20 @@ golangModuleVersion log args@Args {..} = do -------------------------------------------------------------------------------- -- Calls passthru.updateScript updateScript :: MonadIO m => (Text -> m ()) -> Args -> ExceptT Text m (Maybe Text) -updateScript log args = do - (exitCode, msg) <- Nix.runUpdateScript (attrPath args) - case exitCode of - ExitSuccess -> do - lift $ log "Success" - lift $ log msg - return $ Just "Ran passthru.UpdateScript" - ExitFailure num -> do - throwE $ "[updateScript] Failed with exit code " <> tshow num <> "\n" <> msg - +updateScript log Args {..} = do + if hasUpdateScript + then do + (exitCode, msg) <- Nix.runUpdateScript attrPath + case exitCode of + ExitSuccess -> do + lift $ log "Success" + lift $ log msg + return $ Just "Ran passthru.UpdateScript" + ExitFailure num -> do + throwE $ "[updateScript] Failed with exit code " <> tshow num <> "\n" <> msg + else do + lift $ log "skipping because derivation has no updateScript" + return Nothing -------------------------------------------------------------------------------- -- Common helper functions and utilities -- Helper to update version and src attributes, re-computing the sha256.