-
Notifications
You must be signed in to change notification settings - Fork 696
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
cabal new-install
UI design concept (WIP)
#4558
Comments
I'm not sure I really understand the use case for installing libraries this way. Can you explain what the actual end-user's use case would be? (Is it REPL use without having to have a .cabal file or something like that?) |
@BardurArantsson Yes, it's exactly that; we want to be able to support |
I wonder, would it be too onerous to just require users to specify the "world" file themselves instead of cabal maintaining it (statefully)? AFAIUI that's pretty similar to how stack does it, and it seems pretty reasonable, both for the REPL case ( |
@BardurArantsson Well, we can also support that workflow of course (we actually have something like that already: if you work in the context of a |
I'm not sure I see any advantage whatsoever for the stateful/interactive one, but maybe that's just me. It seems more difficult conceptually to have to explain "views", how to update them, etc. that to just say "plop a file in your working directory" (or wherever). /me shrugs :) |
I'm pretty OK with not supporting local libraries (and even exes) in the beginning. If you have a source tree, it's not a far step to just working with it directly, no need for install. @BardurArantsson I think it is reasonable for a user to say, "I want package X installed on my system, and I want it installed ASAP." Because life is too short to muck around with package systems all the time. |
Try hooking up (Here's one helper script I currently use for that; but I'd rather have this supported directly in |
Fair enough! |
#4120 is relevant here:
I should note that |
Another interesting issue raised by @dmwit is the interaction with |
Other than asking the user, isn't this just what happens when the build-depends are changed between (Very eager for this feature, btw!) |
Add the first part of the new-install command: nonlocal exes. See haskell#4558 for the design concept. This part of the command installs executables from outside of a project (ie from hackage) in the store and then symlinks them in the cabal bin directory. This is done by creating a dummy project and adding the targets as extra packages.
Add the first part of the new-install command: nonlocal exes. See haskell#4558 for the design concept. This part of the command installs executables from outside of a project (ie from hackage) in the store and then symlinks them in the cabal bin directory. This is done by creating a dummy project and adding the targets as extra packages.
#4120's semi-solution is not enough if we want to support local I can see an easy solution for executables (instead of trying to use a symlink, generate a tiny script that sets the correct environment variables and stuff, basically Either we decide on a more permanent/invasive solution that is strong enough that the library can just Know™ how to find the data files or we just refuse to support that because it's of semi-questionable usefulness. |
@typedrat This is much like how nix itself does it. You |
Currently blocking progress with @fgaz's idea is that building out of line requires a SourceHash, and I don't know how to intelligently define that. |
I'm half tempted to just put this on the back burner until I get |
Status
There's at least two axes for use-cases which need to be considered for the UI design: Most importantly is the distinction between
GHC_ENVIRONMENT
s (for GHC 8.0.2+)And then sources can be distinguished by being either
With the new nix-store paradigm, the idiomatic way to "install" things would be to first populate the requested target in the nix-store, and install a reference to the materialised artifact in a "view" (this signficantly differs depending on whether it's an executable or a library).
In this paradigm, the "installation" rather refers to installing a symlink or adding a reference to a package-env, than to build the actual artifacts. In some cases, all a
cabal new-install
operation does degenerates into replacing the target of an existing symlink (e.g. if you first "install"alex-3.2.0
, and then you installalex-3.2.1
, and then decide to installalex-3.2.0
again; the 3rd operation would merely update the symlink, as the store would already contain both versions ofalex
)Basic UI
The basic UI would look like
(NOTE: as of #4825, the syntax is
cabal new-install [--symlink-bindir=<install-location>] <build-target-spec>
)A build-target would be something like
Omission of
<install-location>
would denote a default location.For libraries the default would be the current value of
GHC_ENVIRONMENT
, or otherwise thedefault
environment (this matches the ghc-env lookup logic of GHC 8.0.2+).For executables, the install location denotes a
bin
folder; by default this would be the value configured in~/.cabal/config
(e.g.${HOME}/.cabal/bin
) or possibly in the in-scopecabal.project
.Executables
Non-local packages
Installing executables from non-local packages is the easiest case; in fact, this can be emulated already now via script like https://gist.github.com/hvr/c77c54d682555b7dd4fe1248732fe978
Which first causes the requested executable to be materialised (if it wasn't already cached) in the nix store via a dummy package description containing
build-tool-depends: ${PKG}:${EXE}
, and thenlocates the resulting executable to install a symlink to the desired folder-location.
Local packages
This case is currently less straightforward when the non-local components have associated package-data (#4120).
However, this use-case is quite important, e.g. when a cabal project is embedded into a larger build-system which needs to invoke cabal to make available some "local" executable to the rest of the
build-system, then such a project is often just part of the source-tree and as such comprised of local
unpublished) packages.
Libraries
Libraries are a bit more complicated, as package-environments should ideally represent views into the nix-store providing a flat consistent install-plan where each package exposed shall be compatible with each other package in the same view.
The simple case is when creating a new package-environment, and specify /all/ libraries to be installed therein upfront. This is the known situation as handled already by
cabal new-build
viabuild-depends
speecifications.However,
cabal new-install
should also support installing new packages into an existing view in an incremental way. But this means that if we may get into a situation where the "old"cabal install
would warn about running into a "reinstall"-situation.
One way to design the UI would be to ask the user whether we should try to resolve, and come up with a new consistent monolithic install-plan for the set of packages that were already available in the package-environment plus the newly to be added packages.
This would take into account the original version constraints imposed if there were any specified for the pre-existing packages. We may need something like per package-environment "world" files, to basically
keep track of an incrementally growing list of
build-depends
lines (and also possiblyconstraint
-lines and other flags such as profiling levels). This way the user could have control over the package environment in a direct way by editing the world-files in order to manually resolve hard conflicts.Non-local packages
To some degree, this could be emulated right now with an external shell (similiar to the executable-install-case mentioned above) by using a dummy
.cabal
file where the requested libraries arespecified via
build-depends
, and the automatically resulting.ghc.environment.*
file which is copied over to the package-environment specified as the install-location.Local packages
For one, parts of this is already automatically provided by the automatic creation of
.ghc.environment.*
files, but you'd currently need to manually copy them to their<install-location>
. But this would also be limited to singlecabal.project
s currently.This is more complicated just as for the local executable case, as associated package-data of local libraries is not handled conveniently for this use-case currently (#4120).
TODO:
extra-packages:
fits into this scheme (see this comment)The text was updated successfully, but these errors were encountered: