Skip to content
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

InstalledPackageInfo mega issue #8967

Open
andreabedini opened this issue May 23, 2023 · 5 comments
Open

InstalledPackageInfo mega issue #8967

andreabedini opened this issue May 23, 2023 · 5 comments

Comments

@andreabedini
Copy link
Collaborator

There are a bunch of issues and PRs calling for adding more information to InstalledPackageInfo. I thought it would be a good idea to collect them here with a short summary so we can have better visbility and, if needed, discuss the bigger picture.

AFAIU Changing InstalledPackageInfo requires some level of coordination with GHC since ghc-pkg uses Cabal to read the files and distill them into a GHC specific version. What is the process to make changes to InstalledPackageInfo?

Is it a good idea to keep adding cabal specific things to InstalledPackageInfo? Other tools might install packages in packagedb.

Should cabal install have its own database?

Should we have a clear distinction between ghc fields and tool specific fields?

In #8702 @bgamari refers to "non-normative" fields (which I have not found any documentation for) and suggests a syntax for fields ghc-pkg will automatically ignore (x-field).

Ping spamming @ulysses4ever @fgaz @Mikolaj @gbaz @hsyl20 and others (apologies in advance).

@Mikolaj
Copy link
Member

Mikolaj commented May 23, 2023

x-field sounds fine. Would establishing this convention (with a buy-in from GHC) solve all the other problems?

@andreabedini
Copy link
Collaborator Author

x-field sounds fine. Would establishing this convention (with a buy-in from GHC) solve all the other problems?

Should it be x-cabal- for cabal specific fields?

Package metadata (author, etc) are not used by GHC, should they get the x-cabal- prefix? why are they even needed in packagedb?

Sorry for bombarding with questions, I don't want to led us to analysis-paralisys :-) I want to understand the design space a bit more.

@bgamari
Copy link
Contributor

bgamari commented May 23, 2023

Thanks for putting together this list, @andreabedini !

An X- field convention sounds quite reasonable to me and reasonably straightforward to implement. Yes, I think it would be best if users prefixed tool/library-specific fields with their name (e.g. X-Cabal).

Package metadata (author, etc) are not used by GHC, should they get the x-cabal- prefix? why are they even needed in packagedb?

Indeed GHC doesn't care about these fields but they are fairly universal and I don't think they do much harm to include. Moreover, some of these fields may be used by tools other than GHC (e.g. license for license compliance checking).

@bairyn
Copy link
Collaborator

bairyn commented Nov 15, 2023

The Cabal-syntax package is the one inside cabal.git that provides the InstalledPackageInfo record.

data InstalledPackageInfo
	= InstalledPackageInfo {
…
		author            :: !ShortText,
		stability         :: !ShortText,
		homepage          :: !ShortText,
		pkgUrl            :: !ShortText,
		synopsis          :: !ShortText,
…
		depends           :: [UnitId],
		abiDepends        :: [AbiDependency],
		ccOptions         :: [String],
…
	}
	deriving (Eq, Generic, Typeable, Read, Show)

In ghc.git, there is a utility application called ‘ghc-pkg’ whose source is largely in ghc.git/utils/ghc-pkg/Main.hs. ghc-pkg depends on Cabal-syntax to have access to Cabal-syntax's InstalledPackageInfo. cabal-install also depends on Cabal-syntax.

I think x- sounds fine at least if RFC 6648's warning is accommodated. We could add a list of external/extensible ‘x-’ fields as a new field in InstalledPackageInfo, and, secondly, any new field inside InstalledPackageInfo could optionally itself get an ‘x-’ prefix if it isn't wanted to be added without ‘x-’. It technically wouldn't be conformant with that RFC, for what it's worth, since it has the opinion that an ‘x-’ convention makes future standardization of the name difficult. But I think we can still allow for future standardization, by adding a Cabal-syntax version field to the IPI record and by using the Haskell PVP. Then if support for older Cabal-syntax versions and their IPI records is desired (e.g. in particular if ‘x-’ is removed for an experimental (rather than external/extensible field) once a new major version is released), newer versions could look at what the IPI version is, to make adjustments similar to the various migrations in e.g. cabal-install:D.C.Setup.filterConfigureFlags, which adjusts flags depending on the cabal version.

Perhaps the main solution is adding a version field, then, enabling the IPI record serialized into the package's .conf file to be tied to the Cabal-syntax version that specifies it. This would make any ‘x-’ experimental standardization easier in the future. Then perhaps a list of x- fields can be added, for external users of Cabal-syntax to use to extend IPI. Cabal-syntax would store these key value pairs uninterpreted in InstalledPackageInfo, for external users to manage.

Does this sound reasonable?

@andreabedini
Copy link
Collaborator Author

@bairyn Thanks for chiming in and also for mentioning RFC 6648.

I am actually reluctant to go down the x- route since I believe it will keep masking a natural separation of concerns. If you look at ghc-pkg, you will see that only a small part of IPI is actually used by GHC. Which again brings the question of why we have packagedb, who owns it and who uses it.

You could say it's a Cabal thing that GHC reads, but then why ghc-pkg can modify it?
You could say it's a GHC thing that Cabal writes, but then why IPI is defined in Cabal-syntax and why it includes details irrelevant to GHC?
You could say it's a common component both Cabal and GHC depends on and use to communicate; then it should be moved to a separate library along with (most of) ghc-pkg and it should take into account being used by other tools too.

TBH I am still confused by the whole situation.

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

No branches or pull requests

5 participants