{"id":13702269,"url":"https://github.com/andreasabel/cabal-clean","last_synced_at":"2025-03-16T14:30:53.270Z","repository":{"id":59154193,"uuid":"396873913","full_name":"andreasabel/cabal-clean","owner":"andreasabel","description":"Remove outdated compilation artefacts left by cabal v2-build","archived":false,"fork":false,"pushed_at":"2025-03-15T20:16:03.000Z","size":79,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T21:29:58.581Z","etag":null,"topics":["cabal","clean","disk-space","haskell"],"latest_commit_sha":null,"homepage":"https://hackage.haskell.org/package/cabal-clean","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreasabel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-16T16:19:38.000Z","updated_at":"2025-03-15T20:16:07.000Z","dependencies_parsed_at":"2024-10-27T10:54:02.020Z","dependency_job_id":"675b3164-9ac1-4315-86ea-d0083e48893f","html_url":"https://github.com/andreasabel/cabal-clean","commit_stats":{"total_commits":33,"total_committers":1,"mean_commits":33.0,"dds":0.0,"last_synced_commit":"6fbdd09bda6966701e412e2d40454fc588fd26e6"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasabel%2Fcabal-clean","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasabel%2Fcabal-clean/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasabel%2Fcabal-clean/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasabel%2Fcabal-clean/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreasabel","download_url":"https://codeload.github.com/andreasabel/cabal-clean/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243795041,"owners_count":20349180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cabal","clean","disk-space","haskell"],"created_at":"2024-08-02T21:00:33.067Z","updated_at":"2025-03-16T14:30:52.778Z","avatar_url":"https://github.com/andreasabel.png","language":"Haskell","funding_links":[],"categories":["Cabal Assistants"],"sub_categories":["Talks"],"readme":"[![Hackage version](https://img.shields.io/hackage/v/cabal-clean.svg?label=Hackage\u0026color=informational)](http://hackage.haskell.org/package/cabal-clean)\n[![cabal-clean on Stackage Nightly](https://stackage.org/package/cabal-clean/badge/nightly)](https://stackage.org/nightly/package/cabal-clean)\n[![Stackage LTS version](https://www.stackage.org/package/cabal-clean/badge/lts?label=Stackage)](https://www.stackage.org/package/cabal-clean)\n[![Cabal build](https://github.com/andreasabel/cabal-clean/workflows/Haskell-CI/badge.svg)](https://github.com/andreasabel/cabal-clean/actions)\n\ncabal-clean : Remove superseded artefacts of `cabal v2-build`\n=============================================================\n\nRemoves compilation artefacts in `dist-newstyle/build` from older\nversions of the package or superseded minor versions of GHC.\n\nFor the impatient\n-----------------\n\n### Installation\n\n    cabal install cabal-clean\n\n### Run\n\n    cd $MY_PROJECT\n    cabal-clean\n\nThis lists the build artifacts under `dist-newstyle/build`.\n```diff\n---\t191M\tdist-newstyle/build/x86_64-osx/ghc-7.10.3/$MY_PROJECT-2.9.2\n---\t 72M\tdist-newstyle/build/x86_64-osx/ghc-8.10.4/$MY_PROJECT-2.9.2\n---\t162M\tdist-newstyle/build/x86_64-osx/ghc-9.0.1/$MY_PROJECT-2.9.2\n+++\t135M\tdist-newstyle/build/x86_64-osx/ghc-7.10.3/$MY_PROJECT-2.9.3\n---\t 70M\tdist-newstyle/build/x86_64-osx/ghc-8.10.4/$MY_PROJECT-2.9.3\n+++\t145M\tdist-newstyle/build/x86_64-osx/ghc-8.10.7/$MY_PROJECT-2.9.3\n---\t159M\tdist-newstyle/build/x86_64-osx/ghc-9.0.1/$MY_PROJECT-2.9.3\n```\nThe superseded ones (assuming `ghc-9.0.1` is not on the `PATH`),\nprinted in red and prefixed by dashes (`---`),\ncan then be removed by:\n\n    cabal-clean --delete\n\nRationale\n---------\n\n`v2-cabal` (the nix-based `cabal`) maintains a directory structure for\nlocal builds of the form\n`dist-newstyle/build/$ARCH/$HC/$PACKAGE-$VERSION` (plus other stuff\nthat does not take up much disk space).  During active development\nwith several `$HC` versions and `$VERSION` bumps for the `$PACKAGE`,\nlots of out-dated build artefacts accumulate over time.\n\nA simple way to clean up is removing the whole `dist-newstyle` folder,\nbut one might want to keep the build artefacts of the most recent\npackage `$VERSION`s of the most recent versions of the Haskell\ncompiler (`$HC`).\n\nPhilosophy\n----------\n\n- Go for saving the most disk space with the simplest approach, rather\n  than a complete clean-up.  E.g., don't care about outdated contents\n  in `dist-newstyle/package-db` as they take little space.\n\n- Keep only the most recent `$VERSION` of the package.\n\n- Keep only the most recent major versions of `$HC`.\n\n- Keep only versions build with a `$HC` which is still on the PATH\n  (since version 0.2).\n\n- Assume a monopoly of GHC, ignoring other Haskell compilers, so only\n  treat `$HC`s of the form `ghc-$GHCVER`.\n\n- Work autonomously, ignoring `cabal` files.\n  This saves us parsing various home-grown `cabal` file formats.\n  The latter could be easy using the `Cabal` package,\n  but this package is not very stable,\n  and we shy the maintenance effort of depending on `Cabal`.\n\n- Dry-run is the default, giving the user opportunity to review the clean-up plan.\n\nFunctionality\n-------------\n\n- Read the contents of `dist-newstyle/build`,\n  organizing them into a tree according to the pattern\n  `$ARCH/ghc-$GHCVER/$PACKAGE-$VERSION`.\n\n- Display the outdated versions.\n\n  Try to get the disk usage with `du -h` and display it.\n  (I could not find a Haskell library that gets the disk usage OS-agnostically.)\n\n- With option `--delete` actually remove the respective folders.\n\nExamples\n--------\n\nList build artifacts of current project,\nmarking superseded ones that can be deleted:\n\n    cabal-clean\n\nActually delete superseded builds:\n\n    cabal-clean --delete\n\nDelete superseded builds without changing to directory:\n\n    cabal-clean --delete path/to/my/project/dist-newstyle\n\nDelete superseded builds in many projects:\n\n    find . -name \"dist-newstyle\" -exec cabal-clean --delete {} \\;\n\nGet help:\n\n    cabal-clean --help\n\nRelated\n-------\n\n`cabal v2-clean` (as of 2021-08-16)\n\n  - Removes *all* build artefacts.\n  - Does not have a `--dry-run` preview.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreasabel%2Fcabal-clean","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreasabel%2Fcabal-clean","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreasabel%2Fcabal-clean/lists"}