cabal-clean: Remove outdated cabal build artefacts from `dist-newstyle`.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Simple command line tool to remove cabal build artefacts from `dist-newstyle/build` that are superseded by newer versions of the built package or the Haskell compiler.


[Skip to Readme]

Properties

Versions 0.1.20210815, 0.1.20210924, 0.1.20210924
Change log CHANGELOG.md
Dependencies base (>=4.9 && <5), containers (>=0.5.8), directory, filepath, mtl, optparse-applicative, pretty-terminal, process, split, string-qq [details]
License BSD-3-Clause
Copyright Andreas Abel, 2021
Author Andreas Abel
Maintainer Andreas Abel <andreas.abel@cse.gu.se>
Category Development
Home page https://github.com/andreasabel/cabal-clean
Bug tracker https://github.com/andreasabel/cabal-clean/issues
Source repo head: git clone git://github.com/andreasabel/cabal-clean.git
this: git clone git://github.com/andreasabel/cabal-clean.git(tag v0.1.20210924)
Uploaded by AndreasAbel at 2021-09-24T16:47:18Z

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for cabal-clean-0.1.20210924

[back to package description]

Hackage version cabal-clean on Stackage Nightly Stackage LTS version Cabal build

cabal-clean : Remove superseded artefacts of cabal v2-build

Removes compilation artefacts in dist-newstyle/build from older versions of the package or superseded minor versions of GHC.

For the impatient

Installation

cabal install cabal-clean

Run

cd $MY_PROJECT
cabal-clean

This lists the build artifacts under dist-newstyle/build.

---	191M	dist-newstyle/build/x86_64-osx/ghc-7.10.3/$MY_PROJECT-2.9.2
---	 72M	dist-newstyle/build/x86_64-osx/ghc-8.10.4/$MY_PROJECT-2.9.2
---	162M	dist-newstyle/build/x86_64-osx/ghc-9.0.1/$MY_PROJECT-2.9.2
+++	135M	dist-newstyle/build/x86_64-osx/ghc-7.10.3/$MY_PROJECT-2.9.3
---	 70M	dist-newstyle/build/x86_64-osx/ghc-8.10.4/$MY_PROJECT-2.9.3
+++	145M	dist-newstyle/build/x86_64-osx/ghc-8.10.5/$MY_PROJECT-2.9.3
+++	159M	dist-newstyle/build/x86_64-osx/ghc-9.0.1/$MY_PROJECT-2.9.3

The superseded ones, printed in red and prefixed by dashes (---), can then be removed by:

cabal-clean --delete

Rationale

v2-cabal (the nix-based cabal) maintains a directory structure for local builds of the form dist-newstyle/build/$ARCH/$HC/$PACKAGE-$VERSION (plus other stuff that does not take up much disk space). During active development with several $HC versions and $VERSION bumps for the $PACKAGE, lots of out-dated build artefacts accumulate over time.

A simple way to clean up is removing the whole dist-newstyle folder, but one might want to keep the build artefacts of the most recent package $VERSIONs of the most recent versions of the Haskell compiler ($HC).

Philosophy

Functionality

Examples

List build artifacts of current project, marking superseded ones that can be deleded:

cabal-clean

Actually delete superseded builds:

cabal-clean --delete

Delete superseded builds without changing to directory:

cabal-clean --delete path/to/my/project/dist-newstyle

Delete superseded builds in many projects:

find . -name "dist-newstyle" -exec cabal-clean --delete {} \;

Get help:

cabal-clean --help

cabal v2-clean (as of 2021-08-16)