all-hies/Design.org
Silvan Mosberger ba4e8c7ad5
Faster, more succeeding builds, better everything
- Now fetching nixpgks with fetchFromGitHub by computing and saving the
sha256 at update time
- Detecting core GHC libraries and setting them to null to fix builds,
workaround for https://github.com/input-output-hk/stack2nix/issues/134
- Add override directory to fix builds for specific ghc versions
- Speed up builds by disabling library profiling for everything
- New nix file structure with powerful selection mechanisms
2019-04-06 06:44:02 +02:00

3.0 KiB

Assumption: The stack build does not depend on which nixpkgs version it uses, it only needs a matching ghc version

~/.cache/all-hies/ layout:

  • history-nixpkgs-unstable
  • nixpkgs
  • haskell-ide-engine
  • per-ghcMinor

    • <major><minor>: File with the list of base libraries for that ghc version
  • per-nixpkgs

    • ghcVersions

      • <nixpkgsrev>: File with a list of ghc versions this nixpkgs rev has
    • sha256

      • <nixpkgsRev>: sha256 hash for fetchFromGitHub
  • per-haskell-ide-engine

    • <hie-rev>

      • <ghcVersion-stack2nix>.nix: File generated by stack2nix for hie-rev and ghcVersion

./ layout:

  • nixpkgsForGhc

    • <ghcVersion>: File containing the nixpkgsrev to use for that ghc
  • nixpkgsHashes

    • <nixpkgsRevision>: File containing the sha256 hash for fetchFromGitHub for a nixpkgs version
  • ghcBaseLibraries:

    • <ghcVersion>: List of base libraries for that ghc version
  • versions

    • stable

      • <ghcVersion>.nix: File copied from the cache
      • revision: File with the git revision of current stable hie
    • unstable

      • <ghcVersion>.nix: File copied from the cache
      • revision: File with the git revision of current unstable hie

Flags:

  • Whether master should be regenerated
  • Whether to build the generated versions with Nix

Process:

  • Update/initialize hie repo
  • Regenerate ./generated/stable by

    • Removing ./generated/stable/*
    • Getting the latest tag (~=stable)
    • Write stable tag to ./generated/stable/revision
    • Determining the stable hie sha1 hash from the tag
    • Checking out that hie revision
    • For each stack file for a ghc version

      • If $CACHE/per-hie/<rev>/<ghcVersion>.nix is present

        • copy it to ./generated/stable/<ghcVersion>.nix
      • else generate that file by

        • Find a suitable nixpkgs revision for that ghc version

          • If ./generated/nixpkgsForGhc/<ghcVersion> present, use that version
          • else

            • fetch channel history (or use cached version if <15 minutes ago)
            • for each channel nixpkgs revision (from newest to oldest)

              • Get ghc versions

                • If $CACHE/per-nixpkgs/<revision> exists use that
                • Otherwise

                  • Check out that nixpkgs version (and maybe update/initialize the repo first)
                  • Run nix evaluation to determine available compilers
                  • Save result in $CACHE/per-nixpkgs/<revision>
              • If it has the ghc version we need

                • Save that revision in ./generated/nixpkgsForGhc/<ghcVersion>
                • revision found, exit channel history loop
              • Otherwise continue
            • If no fitting ghc version was found, log error
        • Checking out that nixpkgs revision
        • Invoke stack2nix to generate $CACHE/per-hie/<rev>/<ghcVersion>.nix
        • If nix build flag is enabled, build it
        • Copy $CACHE/per-hie/<rev>/<ghcVersion>.nix to ./generated/stable/<ghcVersion>.nix
  • If master flag is enabled, regenerate ./generated/unstable by

    • (same process as above, only difference is first step)