@@ -814,8 +814,8 @@ packThunk' noTrail (ThunkPackConfig force thunkConfig) thunkDir = checkThunkDire
814814 Right (ThunkData_Checkout _) -> do
815815 withSpinner' ("Packing thunk " <> T.pack thunkDir)
816816 (finalMsg noTrail $ const $ "Packed thunk " <> T.pack thunkDir) $ do
817− thunkPtr <- modifyThunkPtrByConfig thunkConfig <$> getThunkPtr (not force) (thunkDir </> unpackedDirName) (_thunkConfig_private thunkConfig)
818− callProcessAndLogOutput (Debug, Error) $ proc rmPath ["-rf", thunkDir </> unpackedDirName] -- thunkDir may be a symlink
817+ thunkPtr <- modifyThunkPtrByConfig thunkConfig <$> getThunkPtr (not force) thunkDir (_thunkConfig_private thunkConfig)
818+ callProcessAndLogOutput (Debug, Error) $ proc rmPath ["-rf", thunkDir] -- thunkDir may be a symlink
819819 createThunk thunkDir thunkPtr
820820 pure thunkPtr
821821
@@ -828,7 +828,13 @@ modifyThunkPtrByConfig (ThunkConfig markPrivate') ptr = case markPrivate' of
828828 }
829829
830830getThunkPtr :: forall m. MonadObelisk m => Bool -> FilePath -> Maybe Bool -> m ThunkPtr
831−getThunkPtr checkClean thunkDir mPrivate = do
831+getThunkPtr checkClean dir mPrivate = do
832+ let repoLocations = [(".git", "."), (unpackedDirName, unpackedDirName)]
833+ repoLocation' <- liftIO $ flip findM repoLocations $ doesDirectoryExist . (dir </>) . fst
834+ thunkDir <- case repoLocation' of
835+ Nothing -> failWith [i|Can't find an unpacked thunk in ${dir}|]
836+ Just (_, path) -> pure $ normalise $ dir </> path
837+
832838 when checkClean $ ensureCleanGitRepo thunkDir True
833839 "thunk pack: thunk checkout contains unsaved modifications"
834840