Coder Social home page Coder Social logo

intersectmbo / cardano-haskell-packages Goto Github PK

View Code? Open in Web Editor NEW
31.0 52.0 22.0 247.82 MB

Metadata for Cardano's Haskell package repository

Home Page: https://chap.intersectmbo.org/

License: Apache License 2.0

Nix 49.42% Shell 49.09% HTML 1.50%
cardano haskell nix

cardano-haskell-packages's Introduction

Cardano Haskell package repository ("CHaP")

Top How-Tos

This is a Cabal package repository ("CHaP") whose purpose is to contain all the Haskell packages used by the Cardano open-source project which are not on Hackage.

The package repository itself is available here. It is built from a git repository which contains the metadata specifying all the package versions. The package repository is built using foliage.

Help!

If you have trouble, open an issue, or contact the trustees: @intersectmbo/cardano-haskell-packages-trustees

Background

This section explains some concepts that are useful for understanding and working with CHaP.

What is a Cabal package repository?

A package repository is essentially a mapping from package name and version to the source distribution for the package. Most Haskell programmers will be familiar with the package repository hosted on Hackage, which is enabled by default in Cabal.

However, Cabal supports the use of additional package repositories. This is convenient for users who can't or don't want to put their packages on Hackage.

Cabal package repositories and source-repository-package

Using source-repository-package stanzas is another common way of getting dependencies that are not on Hackage. Both have their place: CHaP gives us proper versioning and simpler setup, source-repository-packages are useful for ad-hoc use of patched or pre-release versions.

Crucially, additional Cabal package repositories like CHaP and source-repository-package stanzas are compatible and source-repository-packages always win. That is, they interact in the same way as Hackage and source-repository-packages do. This gives us behaviour that we want: ad-hoc source-repository-package stanzas will override packages from Hackage or CHaP.

Using CHaP

To use CHaP with cabal, add the following lines to your cabal.project file:

repository cardano-haskell-packages
  url: https://chap.intersectmbo.org/
  secure: True
  root-keys:
    3e0cce471cf09815f930210f7827266fd09045445d65923e6d0238a6cd15126f
    443abb7fb497a134c343faf52f0b659bd7999bc06b7f63fa76dc99d631f9bea1
    a86a1f6ce86c449c46666bda44268677abf29b5b2d2eb5ec7af903ec2f117a82
    bcec67e8e99cabfa7764d75ad9b158d72bfacf70ca1d0ec8bc6b4406d1bf8413
    c00aae8461a256275598500ea0e187588c35a5d5d7454fb57eac18d9edb86a56
    d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee

The package repository will be understood by cabal, and can be updated with cabal update. You must run cabal update at least once so cabal can download the package index!

The index-state for the package repository can also be pinned as usual. You can either just use a single index-state for both Hackage and CHaP:

index-state: 2022-08-25T00:00:00Z

or you can specify a different index-state for each repository:

index-state:
  , hackage.haskell.org      2022-12-31T00:00:00Z
  , cardano-haskell-packages 2022-08-25T00:00:00Z

Note that a second index-state stanza completely ovverides the first, so

index-state: 2022-12-31T00:00:00Z
index-state: cardano-haskell-packages 2022-08-25T00:00:00Z

would override the index-state for Hackage to HEAD (since HEAD is the default).

... with haskell.nix

To use CHaP with haskell.nix, do the following:

  1. Add the package repository to your cabal.project as above.
  2. Setup a fetcher for the package repository. The easiest way is to use a flake input, such as:
inputs.CHaP = {
  url = "github:intersectmbo/cardano-haskell-packages?ref=repo";
  flake = false;
};
  1. Tell haskell-nix to map the CHaP url to the appropriate nix store path using the inputMap argument of one of haskell.nix project functions. Using cabalProject this would look like the following:
cabalProject {
  ...
  inputMap = { "https://chap.intersectmbo.org/" = CHaP; };
}

To build some of the pacakges from CHaP, some C libraries will need to be installed. If you don't have those libraries installed cabal may pick an older library version that might not compile. An easy way to add those libraries is using the overlays provided by iohk-nix. For example plutus-core==1.21.0.0 depends on libblst, haskell-nix-crypto and crypto are the two overlays that would make it available during the build.

When you want to update the state of CHaP, you can simply update the flake input (in the example above you would run nix flake lock --update-input CHaP).

If you have CHaP configured correctly, then when you run cabal build from inside a haskell.nix shell, you should not see any of the packages in CHaP being built by cabal. The exception is if you have a source-repository-package stanza which overrides a dependency of one of the packages in CHaP. Then cabal will rebuild them both. If this becomes a problem, you can consider adding the patched package to CHaP itself, see below.

Updating dependencies from CHaP

If you have a Haskell project which has bounds on CHaP packages, we provide a script which will update all of those bounds to pin the latest major version of each that is released to CHaP.

You can run it like so: nix run --update-input CHaP --no-write-lock-file "github:intersectmbo/cardano-haskell-packages#update-chap-deps" pkgA pkgB. This will update the bounds for everything from CHaP, except for those on pkgA or pkgB. This lets you blacklist packages that you don't want to update (e.g. because you know that the update will break you, or it's your own package!).

Creating a repository like CHaP

If you just want to test changes to CHaP, you should make a fork. If you want to replicate the setup from scratch you can clone this template.

Contributing packages and revisions

This section explains how to contribute to the main content of CHaP: packages and revisions. The contribution itself should be made in a PR.

Requirements for including a package

Monotonically increasing timestamps

When adding a package, it is important to use a timestamp (see below) that is greater than any other timestamp in the index. Indeed, cabal users rely on the changes to the repository index to be append-only. A non append-only change to the package index would change the repository index state as pinned by index-state, breaking reproducibility.

This condition is enforced by the CI, and we only allow FF-merges in order to ensure that we are always checking a linear history.

Tips for working with timestamps:

  • Most of the scripts will insert timestamps for you, e.g. ./scripts/add-from-github.sh
  • If you have a PR and the timestamps are now too old (e.g. because someone else made a PR in the meantime), then see below for tips
  • If you want to get a suitable timestamp for some other reason, ./scripts/current-timestamp.sh will produce one

No extra build configuration beyond what is given in the cabal file

When downstream users pull a package from CHaP, cabal will build it based only on the information in the cabal file. This means that if your package needs any additional configuration to build, then it will simply be broken for downstream users unless they replicate that configuration.

Typical examples of this are anything that you add in cabal.project:

  • constraints
  • allow-newer
  • source-repository-package

This is enforced by the CI, which will build newly added packages in PRs.

How to add a new package version

Package versions are defined using metadata files _sources/$pkg_name/$pkg_version/meta.toml, which you can create directly. The metadata files have the following format:

# REQUIRED timestamp at which the package appears in the index
timestamp = 2022-03-29T06:19:50+00:00
# REQUIRED URL pointing to the source code tarball (not necessarily a sdist)
url = 'https://github.com/intersectmbo/ouroboros-network/tarball/fa10cb4eef1e7d3e095cec3c2bb1210774b7e5fa'
# OPTIONAL subdirectory inside the tarball where the package is located
subdir = 'typed-protocols'

... from GitHub

There is a convenience script ./scripts/add-from-github.sh to simplify adding a package from a GitHub repository.

$ ./scripts/add-from-github.sh
Usage add-from-github.sh [-f OVERWRITE_VERSION] REPO_URL COMMIT-SHA [SUBDIRS...]

        -f OVERWRITE_VERSION      (DANGEROUS) uses OVERWRITE_VERSION as the package version instead of the one from the tarball
        REPO_URL                  the repository's Github URL
        COMMIT_SHA                the commit SHA for the package source
        SUBDIRS                   the list of relevant sub-directories

For example, to add a new version from plutus's plutus-core and plutus-ledger-api, etc from commit 75267027f157f1312964e7126280920d1245c52d, run

./scripts/add-from-github.sh "https://github.com/intersectmbo/plutus" 75267027f157f1312964e7126280920d1245c52d plutus-core plutus-ledger-api plutus-tx plutus-tx-plugin prettyprinter-configurable

The script will:

  1. Find the cabal files in the repo (either at the root or in the specified subdirectories)
  2. Obtain package names and versions from the cabal files
  3. Create the corresponding meta.toml files
  4. Commit the changes to the git repository

You can tell the script to override the package version either by passing the version explicitly or by adding a "revision number" (see below).

How to add a new package metadata revision

CHaP supports package metadata revisions just like Hackage. These allow you to provide an edited cabal file for a package version. The primary use of this is to tweak the dependency bounds of a package. In principle you can change other things too, but this is generally frowned upon.

This repository contains a convenience script for adding a revision to CHaP:

$ ./scripts/add-revision.sh _repo PACKAGE_NAME PACKAGE_VERSION

_repo needs to point to a built package repository. It will add a new revision and copy the current cabal file in as the revised cabal file. You can then edit that file and commit the result.

How to deprecate a pacakge

CHaP supports package version deprecations just like Hackage. These allow you to make a package "not-preferred" by the cabal solver (note that the solver will still pick a deprecated package version if it cannot pick a non-deprecated one).

There is not currently a script for adding a deprecation, but you can find examples by serarching for "deprecations" in the repository. Deprecations must include a timestamp (like all events) and indicate the new deprecation state (so package versions can also be un-deprecated).

How to add a patched versions of a Hackage package

CHaP should mostly contain versions of packages which are not on Hackage.

If you need to patch a version of a package on Hackage, then there are two options:

  1. For short lived forks, use a source-repository-package stanza by preference.
  2. For long-lived forks (because e.g. the maintainer is unresponsive or the patch is large and will take time to upstream), then we can consider releasing a patched version in CHaP.

The main constraint when adding a patched version to CHaP is to be sure that we use a version number that won't ever conflict with a release made by upstream on Hackage. There are two approaches to doing this:

  1. Release the package in CHaP under a different name (for the fork). This is very safe, but may not be possible if the dependency is incurred via a package we don't control, as then we can't force it to depend on the renamed package.
  2. Release the package under a version that is very unlikely to be used by upstream. The scheme that we typically use is to take the existing version number, add four zero components and then a patch version, e.g. 1.2.3.4.0.0.0.0.1.

IMPORTANT: if you release a patched package to CHaP, make sure to open an issue about it so we can keep track of which patched packages we have. Ideally, include the conditions under which we can deprecate it, e.g. "can deprecate either when it's fixed upstream or when package X removes their dependency on it".

How to update Hackage index used by CHaP

If one of your packages requires a newer version of a package published on Hackage, you will need to run: nix flake lock --update-input hackage-nix. hackage.nix is automatically updated from Hackage once per day. If things still don't work because the version of the package is not available you'll need either wait for the automatic update or make a PR to hackage.nix first and then rerun the above command.

Releasing CHaP packages to Hackage

It's totally fine to release a package in CHaP to Hackage. The thing to avoid is to have the same package version in both repositories. The simplest solution is to just make sure to use a higher major version number when you start releasing to Hackage, even if this looks a bit odd. For example, if CHaP contains X-1.0 and X-1.1, then the first Hackage release should be X-1.2 or X-2.0.

Building and testing CHaP

For most contributors this section is not going to be necessary, and you can rely on the CI.

However if you are making a large number of changes (e.g. many revisions), it can be useful to test your work before making a PR.

How to get the built Cabal package repository

The Cabal package repository itself is built using the tool foliage. You can either fetch the latest version which is stored in git; or build it yourself locally, which can be convenient or necessary if you have local changes.

... by downloading it from Github

The built repository is stored in the repo branch of CHaP itself. You can get the contents of the repo branch from Github at https://github.com/intersectmbo/cardano-haskell-packages/archive/refs/heads/repo.zip .

Or you can check out that branch and copy the contents, e.g.

git checkout repo
cp -aR . _repo
git checkout -

You can also check it out as a worktree:

git worktree add _repo repo

When using this later, remember to pull before creating a revision.

... by building it locally

foliage is available in the Nix dev shell, which you can get into using nix develop.

To build the repository, run foliage build -j 0 --write-metadata. This will build the repository and put it in _repo.

How to test changes

Sometimes it is useful to test in advance how a new package or a cabal file revision affects things.

First of all, build the repository. For the rest of this section we will assume the built repository is in /home/user/cardano-haskell-packages/_repo.

... by building packages with cabal

You can test a locally built CHaP with a small test project consisting of just a cabal.project file:

-- Give it a different name to avoid cabal confusing it with the
-- real CHaP
repository cardano-haskell-packages-local
  -- Point this to the *built* repository
  url: file:/home/user/cardano-haskell-packages/_repo
  secure: True
  -- You can skip the root-keys field

-- Add all the packages you want to try building
extra-packages:
  , cardano-prelude-0.1.0.0

You need to tell cabal about the new repository with cabal update (you might need to clear out ~/.cabal/packages/cardano-haskell-packages-local if you've been editing your repository destructively).

Then you can build whatever package version you want with cabal:

$ cabal build cardano-prelude

You can troubleshoot a failed build plan using the cabal flags --constraint, --allow-newer and --allow-older. Once you have obtained a working build plan, you should revise you cabal file with appropriate constraints.

... by building packages with Nix

You can build packages from CHaP using Nix like this:

nix build
  --override-input CHaP path:/home/user/cardano-haskell-packages/_repo
  '.#"ghc92/plutus-core/1.1.0.0"'

(Note the added quotes around .#"ghc92/plutus-core/1.1.0.0". For other shells than bash this is required to make sure that the above command works. See: NixOS/nix#4686. For bash, the quotes can be omitted.)

This will build all the components of that package version that CHaP cares about, namely libraries and executables (test suites and benchmarks are not built).

We need to use --override-input because the CHaP flake relies on a built repository. By default it points to a built repository on the main CHaP repo branch. But if you have just produced your own built repository (see above) then you want to use that instead, and --override-input will let you do that.

... by testing against a haskell.nix project

If you want to test a locally built CHaP against a project that uses CHaP via haskell.nix, you can build the project while overriding CHaP with your local version.

$ nix build --override-input CHaP path:/home/user/cardano-haskell-packages/_repo

Note that you will need to change the index-state for cardano-haskell-packages to be newer than the repository you just built, otherwise cabal will ignore your new package versions!

Also, you you can examine the build plan without completing the build:

$ nix build .#project.plan-nix.json \
	--out-link plan.json \
	--override-input CHaP path:/home/user/cardano-haskell-packages/_repo

This is useful if you just want to see whether cabal is able to successfully resolve dependencies and see what versions it picked.

Making changes

Changes to CHaP should simply be made using PRs.

Access control

CHaP uses CODEOWNERS to determine whose approval is needed to release a package. The general rules are:

  • If a package is clearly owned by a particular team, then set that team as the CODEOWNER.
  • Prefer to use GitHub teams over individual accounts wherever possible.
  • In the case of patched packages, the owner should be whichever team owns the package that causes the dependency on the package that needs patching.

Generally, use your judgement about what's appropriate.

CI

The CI for CHaP does the following things:

  • Checks that the timestamps in the git repository are monotonically increasing through commits. Along with requiring linear history, this ensures that package repository that we build is always an extension of the previous one.
  • Builds the package repository from the metadata using foliage.
  • Builds a small set of packages using the newly built repository.
    • We build with all the major GHC versions we expect to be in use.
    • At the moment we don't build all the packages in the repository, only the latest versions of a fixed set.
    • This happens twice, without Haddock and with Haddock.
  • Builds any newly added packages using the newly built repository.
    • This happens twice, without Haddock and with Haddock.
  • If on the master branch, deploys the package repository to the repo branch, along with some static web content.

Troubleshooting CI / GitHub Actions

In case the build-packages or build-new-packages actions fail, you can retrieve the built-repo Artifact from the Actions Summary page for the failed action. Then, unpack it into the _repo directory and proceed with the remaining steps in the CI.yml GitHub Workflow file. Note that the nixbuild flags are not relevant for reproducing the issue locally and can be ignored.

Dealing with timestamp conflicts

Since we require monotonically increasing timestamps, there can be timestamp conflicts if someone else merges a PR with later timestamps than yours. That means that your PR (once updated from main) will now introduce "old" timestamps, which is not allowed.

There are some scripts for dealing with this:

  • ./scripts/update-timestamps-in-revision.sh REV will look at the given revision, find any timestamps that were added in that commit, and make changes to update them to a fresh timestamp.
  • ./scripts/update-timestamps-and-fixup.sh REV will do the same but also commit the changes as a fixup commit. You can either leave these in your PR or get rid of them with git rebase main --autosquash

An easy way to run update-timestamps-and-fixup on a multi-commit PR is to run git rebase main --exec "./scripts/update-timestamps-and-fixup.sh HEAD". This will run the script at every step of the rebase on HEAD (i.e. the commit you have reached).

Debugging solver issues

Sometimes you may hit issues that are related to cabal's constraint solver making strange choices. For example, you are making a PR to release foo-X, which depends on bar via baz. But when the CI builds the package, instead of using the newest bar-Y, cabal inexplicably decides to build a very old verison of bar that either a) leads to solver errors; or b) leads to compilation errors.

The root cause is usually that the solver can't pick the version of bar that you want because it conflicts with your dependencies in some way, but it is often not obvious why. It's tricky to diagnose, since you'll sometimes want to rebuild the repository to add revisions while you're working.

The easiest way is to build the package in question with nix, i.e. something like this:

# repeat this whenever you change the repository, e.g. by adding a revision
> foliage build -j 0 --write-metadata
> nix build
  --override-input CHaP path:/home/user/cardano-haskell-packages/_repo
  '.#"ghc92/foo/X"'

There are then two ways to make progress:

  1. Add a constraint to force the good case. If you are expecting to build with bar-Y, you can add a bar == Y constraint and the solver should tell you why it's impossible! You can either add this to the cabal.project specified in nix/builder.nix, or add .addConstraint "bar == Y" to the nix invocation. For example:
nix build $(nix eval --raw '.#"ghc8107/cardano-ledger-core/0.1.0.0"' \
    --apply 'd: (d.passthru.addConstraint "cardano-crypto-class <2.0.0.1, cardano-binary<1.5.0.1").drvPath')
  1. Make a revision to rule out the bad case. If your build fails because baz-Z can't build with bar-P, then baz-Z should have a constraint that excludes bar-P. You can add this constraint by making a revision to baz-Z and try again.

Both of these should get you to a different error. The advantage of adding constraints is that it tends to more directly reveal the problem as it focusses on what you want to happen. The advantage of the revision is that it permanently records the incompatibility information, which is useful for future people.

cardano-haskell-packages's People

Contributors

amesgen avatar andreabedini avatar angerman avatar berewt avatar bezirg avatar bolt12 avatar carbolymer avatar coot avatar dermetfan avatar disassembler avatar dnadales avatar erikd avatar fraser-iohk avatar github-actions[bot] avatar jaredcorduan avatar jasagredo avatar jhbertra avatar jimbo4350 avatar jorisdral avatar kwxm avatar lehins avatar logan-the-lobster avatar lucsanszky avatar michaelpj avatar newhoggy avatar nfrisby avatar sjoerdvisscher avatar smelc avatar teodanciu avatar zliu41 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cardano-haskell-packages's Issues

add-from-github is not graceful if the revision does not exist

I typod the revision and got a confusing error.

~/projects/iohk/cardano-haskell-package-repo mpj/demo-release1 ❯ ./scripts/add-from-github.sh https://github.com/michaelpj/ekg-forward v1.1.0 
Work directory is /tmp/tmp.yiPOinOoW8
Fetching https://github.com/michaelpj/ekg-forward at revision v1.1.0

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

How do we manage access rights?

Ideally we want people to be able to merge their own PRs to their own packages, but we (maybe?) care about people pushing malicious packages? Or not.

We could use CODEOWNERS as a fairly lightweight permissions system.

Patched: flat-0.4.4.0.0.0.0.{1,2}

To fix various bugs and to get GHC 9.2. compatibility. Can be deprecated if it's fixed on Hackage, or more likely if the plutus team purges the dependency·

Patched: moo-1.2.0.0.0.0.1

It has a duplicate package stanza which means it breaks with cabal-3.8. The dependency has been removed from the ledger, but still exists for the currently-released versions, so it's worth patching it here.

Unlikely to ever be released again on Hackage, can be deprecated after we do a new release of the ledger if we're happy deprecating the old release of the ledger. But since it's going away we can probably also just leave it forever.

Clarify Step 3 of haskell.nix instructions

It's not clear where to add the snippet from Step 3 in the haskell.nix instructions:

  1. Add the fetched input to the inputMap argument of cabalProject, like this:
cabalProject {
  ...
  inputMap = { "https://input-output-hk.github.io/cardano-haskell-packages" = CHaP; };
}

What is cabalProject? Is this referring to whatever the project is named in the overlays section of the haskell.nix flake (i.e. helloProject in the sample scaffolding?

If this point could be clarified in the README it would be very helpful. Thank you!

Cut down the evaluation overhead of `build-packages`

At the moment build-packages builds ~6 derivations in a single Nix command. That doesn't seem so bad... except that each of them is its own independent cabal project, and so needs to do the haskell.nix cabal planning IFD. So in fact the evaluation time becomes significant: about 5min at the moment, and it'll be more as we add more packages to the smoke test.

(For the building we have nixbuild.net, which is massively parallel, but the evaluation is serial!)

It would be nice to cut this down. At the moment the only way I can think of doing that is to do a matrix build in GHA, with each package in its own job. Then the evaluation work can be done in parallel. But this would be a bit annoying, we'd need to get the list of things to build out of the flake and then call back into it again...

Patched: ekg-json-0.1.0.7.0.0.0.0.1

For aeson-2 compatibility. Can be deprecated once it's updated on Hackage, hard for us to otherwise remove the dependency since it's indirect.

Consider running `build` on PRs

I think at the moment it only runs on main. But it's probably useful (if expensive) to run on PRs, probably some kinds of malformed metadata will only be caught by actually trying to build the repo?

Provide migration script from source-repo-packages to custom package

Here's an crude awk script to extract the info from cabal.project

BEING {
    insrcpkg=0
    insubdir=0
}
/source-repository-package/ {
    insrcpkg=1
    url=""
    rev=""
    dir=""
}
/location:/ { if(insrcpkg) { url=$2 } }
/tag:/ { if(insrcpkg) { rev=$2 } }
/subdir:/ { if(insrcpkg) { insubdir=1; dir=$2 } }
/^\s*$/ { if(insrcpkg) {
    if(url != "" && rev != "") {
        print "./scripts/add-from-github.sh "url" "rev" "dir
    }
    insrcpkg=0
    insubdir=0
} }
{ if(insrcpkg) { if(insubdir) {
    if(dir != "" && dir != "subdir:") {
        print "./scripts/add-from-github.sh "url" "rev" "dir
    }
    dir=$1
} } }
END {
    if(insrcpkg) {
        print "./scripts/add-from-github.sh "url" "rev" "dir
    }
}

Patched: inline-r-1.0.0.0.0.0.0.1

It allows nix-installed R libraries to be visible to inline-r Haskell library.

Can deprecate when upstream makes a new release to Hackage.

Do we need to store the built repository in a branch?

In the original idea, the built repository would be stored in a branch so that GitHub Pages could serve it as a website.

GitHub now allows to publish a website directly from GitHub Actions by uploading a tarball, which is neater in some sense.

In nix workflows it is useful to refer to previous versions of the index. This could be implemented by publishing tarballs of the built repository but it is entirely trivial if the repository is saved in a git branch.

We will store the built repository in a git branch for the time being and keep this issue for discussion.

Add check that latest index state is not in the future

If someone adds a package that is in the future, as happened recently (discussion here: https://github.com/input-output-hk/cardano-haskell-packages/pull/214), then we will accept that fine. The only problem with this is:

  1. To use it you have to put your index-state in the future
  2. Subsequent people adding packages will have to add timestamps after this future date. This does not play well with all our scripts which assume they can safely put in the current time as the timestamp, they will all not work until the future date passes.

This is a bit of a weird occurrence, but annoying enough that we should probably guard against it.

scripts/add-from-github.sh -- add revision field

It would be nice if one could do something like:

./scripts/add-from-github.sh https://github.com/input-output-hk/nothunks 45d066c4f47400e645bda7dc0ffe5070bd2baf42 -rev 3

and have this produce $version.0.0.0.3.

Provide an automation hook for opening PRs based on github tags

Something like:

  • Given a repository and a revision
  • Create a branch called update/<repo>-<rev>
  • Run ./add-from-github <repo> <rev>
  • Make a PR

It would be nice if we could keep most of the logic here. I think we could do that by having it trigger off repository_dispatch, and then if someone wants to trigger that from another repository based on whatever condition they like (e.g. "pushed a release tag matching some regex") then they can do that and just send the event over (https://github.com/orgs/community/discussions/26323).

Tips on debugging/ inspection when I can't find the right version.

I can't see the right version of cardano-crypto-class no matter what I try. I'm also just guessing.

Context:

I'm trying to make a haskell repo that depends on the lastest version of plutus. This is not yet in CHaPs.
Starting from the plutus repo, nix/ haskell.nix, nix develop all behave correctly. I can open a shell and build.
I can make a new subdir, create a repo that uses the new elliptic curve pair methods - all works fine.

When I try to take the nix code into a new repo (of which there is quite a lot) and cut out the plutus-repo-specific parts, things go wrong.
Depending on what I do either I can't drop into a shell, or once I do, I can't see the right version of cardano-crypto-class.
Maybe I've got rid of something important.

CHaP cardano-ledger still behind ghc-next-packages in some ways

I used ghc-next-packages (now seemingly abandoned) to upgrade a project (https://github.com/mlabs-haskell/plutus-simple-model) to GHC 9.4. I had to disable the tests because they used plutus-tx-plugin, for which there was no GHC 9-compatible version on ghc-next-packages.

I am now attempting to switch to CHaP and upgrade the test suite.

However, ghc-next-packages was based off of the master branch of cardano-ledger, and CHaP is based off of the release/1.1.x branch. There are changes in master which are not in release/1.1.x.

What's currently breaking build for me is the renaming of Cardano.Ledger.Alonzo.TxWitnesses to TxWits, which is only on master. I'm loathe to change this back, as I'm sure this is not the only thing, and I'm not keen to go down an endless rabbit hole of undoig work already done.

What is the recommended way forward here?

cc @angerman

Repo Preparation for MBO

This repo has been marked as core tech and is part of initiative of repo preparation, part of this includes adding needed missing documentation.
This repo in particular needs:

  • Explain how to make a contribution (Contributing MD)
  • Include the Standard Code of Conduct
  • Use the Apache 2.0 License or agreed alternative
  • Identify the Core Maintainers

Actually build new (and existing) packages in CI

The gold standard for CI for CHaP would be to check when adding a new package foo-X:

  1. That foo-X builds from CHaP
    • If this fails the package is probably broken and shouldn't be released (might need bounds!)
  2. That all the other packages in CHaP still build (foo-X could supplant foo-(X-1) in build plans, causing failures)
    • If this happens that tells us that the other packages need to be revised to add upper bounds, which is great and we can do it in the same PR!
    • This is only remotely feasible because we have a small repository, but I think we could do it!

Doing this is going to be tricky:

  • We need a hackage.haskell.org index-state to use. We might just have to have a cabal.project for the CHaP CI and update the index-state occasionally.
  • We need to work out how to build them, including all their system deps and so on. We probably need to use haskell.nix for this. We will then need to record any special Nix setup (e.g. the forked libsodium) somewhere. Probably doable, but needs some thought. Ideally this will get lots of cache hits so the CI will be fast!
    • If we ever want to build Haddock we're going to need this anyway!

For bonus points, if we have this setup, then it's also something that can be used locally to test whether a new addition works properly.

Make add-from-github default workflow faster

Ideas:

  • Just call git commit straightaway
    • Add an option to not do so if necessary
  • Call git format-patch instead of providing a commit message file and a timestamp on stdout, so you can just git am it
    • Bonus points: git am can do a sequence of commits, so we can put each package addition into its own commit

I think my preferred workflow would be:

  • Commit by default, one commit per package added
  • Optionally don't commit, and produce output with format-patch

curl error

Warning: Caught exception during _mirrors lookup:res_query: does not exist
(Connection refused)
Warning: No mirrors found for
https://input-output-hk.github.io/cardano-haskell-packages
dieVerbatim: user error (Error: cabal:
'/nix/store/vd4p2dirng26fkfk024l00hvz0z7f5ks-curl-7.84.0-bin/bin/curl' exited
with an error:
curl: (6) Could not resolve host: input-output-hk.github.io
)

Patched: ekg-0.4.0.15.0.0.0.0.1

Upstream is basically unmaintained, no other way to get bounds relaxed. Getting tibbe/ekg#91 merged upstream would be a good start to making this not necessary, but I'm not optimistic.

add-from-github requires listing all subdirs

~/projects/iohk/cardano-haskell-packages mpj/plutus-and-ledger-releases ⇡1 ❯ ./scripts/add-from-github.sh -v 0.1.1.0 https://github.com/input-output-hk/cardano-ledger 26849193788a38479367799cbb249699ac952bab                                                                                                      ✘ INT
Work directory is /tmp/tmp.PawlrJcTic
/tmp/tmp.PawlrJcTic ~/projects/iohk/cardano-haskell-packages
Fetching https://github.com/input-output-hk/cardano-ledger at revision 26849193788a38479367799cbb249699ac952bab
~/projects/iohk/cardano-haskell-packages
awk: fatal: cannot open file `/tmp/tmp.PawlrJcTic//*.cabal' for reading: No such file or directory

Make revision for plutus-core

Reading cardano-node's cabal.project I noticed:

constraints:
  -- plutus-core: needs a constraint here, fixed on plutus master but not in the released version
  , algebraic-graphs < 0.7

Wouldn't it best for everyone to make the revision for plutus-core in cardano-haskell-packages then copying that constraint ~everywhere.

That applies to most of constraints in https://github.com/input-output-hk/cardano-node/blob/f7496b44538cf490eb6be9199783f37bad77862e/cabal.project#L85-L107
I'd expect those bounds to be corrected in the repository (with revisions).

EDIT: I'm very frustrated that I cannot just add the repository cardano-haskell-packages and use plutus-core or cardano-api, but I still need to add a bunch of constraints which are virtually impossible to discover reliably.

Document the creation of this repository better.

  • one needs to use nix shell -c foliage build to generate the _keys folder.
  • the GH action expects KEYS secret to be the result of tar -C _keys -cz . | base64.
  • a repo branch is needed, otherwise the build phase will fail.

I think that's all the issues I ran into. Maybe we should have a foilage-repo-template repository?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.