Skip to content

Support for dist-newstyle outside of project directory #8809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andrewthad opened this issue Feb 24, 2023 · 2 comments
Closed

Support for dist-newstyle outside of project directory #8809

andrewthad opened this issue Feb 24, 2023 · 2 comments
Labels

Comments

@andrewthad
Copy link
Contributor

andrewthad commented Feb 24, 2023

This is a feature request, and if it's out of scope for this project, just shoot it down, but I wanted to get it out there because I don't see that this request has come up before. First I'll describe an analogous feature that the vim text editor has, and then I'll describe how this might look for cabal and why it would be useful.

Vim

Vim has a feature that lets the user control where swp files. By default, a swp file is in the same directory as the text file that it refers to. For example, if I open a file at /home/andrewthad/docs/prose.txt, vim creates /home/andrewthad/docs/.prose.txt.swp. However, in vim, this behavior is configurable. With the command

set directory=/home/andrewthad/.vim/swap_files//

The same swp file would then be created at /home/andrewthad/.vim/swap_files/home/andrewthad/docs/.prose.txt.swp. That is, vim recreates the absolute path underneath a base directory.

Cabal

For cabal, the analogous feature that I envision gives the user greater control over the location of dist-newstyle. Why is this useful?

  • Backups. Users who regularly backup their file system do not need build artifacts to be backed up.
  • Searching through many repositories. Not all search tools are aware of .gitignore files (although this is pretty common in grep replacements), and even for those that are aware will not understand that they should ignore the dist-newstyle directory in a project that was copied to the local filesystem with cabal unpack instead of git clone.
  • Cleaning up old build artifacts after a GHC or cabal upgrade. Just delete one directory and its all gone.

It is mostly possible for users to accomplish all of these with the right shell scripts and tooling (except in cases where someone passes something odd to --builddir, but I usually use names like dist-8.10.7 to make it clear what's going on), but all of these become trivial if cabal directly supports a feature to keep build artifacts out of projects.

The way I imagine that this would work is that a directory for build artifacts would be specified in ~/.cabal/config (maybe the name for this setting would be build-artifacts-directory), and this could not be overridden at the CLI.

I'm not familiar with cabal's code, so there might be compelling technical reasons to not do this. Or this might just be out of scope because of difficulty maintaining it or the confusion resulting from users having different setups. But if it seems worthwhile, I could look into implementing this.

@ulysses4ever ulysses4ever added type: enhancement cabal-install: nix-local-build re: config-file Concerning the cabal configuration file and the `--config-file` option re: builddir labels Feb 24, 2023
@andreabedini
Copy link
Collaborator

andreabedini commented May 27, 2023

Thanks @andrewthad, you can find a long discussion about this in #5271. The tl;dr would be "to parse a global/project config we need a cache directory and to have a cache directory we need a builddir" so we cannot write the builddir into a configuration file. I agree that this is not optimal but I don't have a vision for how to solve this. I would refer you to the issue linked above.

To be clear: a dist-newstyle outside the project directory is supported and works without any problem (that I am aware of). As I read it, the issue above is how to set the location of dist-newstyle globally.

@ulysses4ever
Copy link
Collaborator

Let's close it as a dup of #5271 perhaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants