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-nixpkgs - : File with a list of ghc versions this nixpkgs rev has - per-haskell-ide-engine - - .nix: File generated by stack2nix for hie-rev and ghcVersion ./generated/ layout: - nixpkgsForGhc - : File containing the nixpkgsrev to use for that ghc - stable - .nix: File copied from the cache - revision: File with the git revision of current stable hie - unstable - .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//.nix is present - copy it to ./generated/stable/.nix - else generate that file by - Find a suitable nixpkgs revision for that ghc version - If ./generated/nixpkgsForGhc/ 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/ 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/ - If it has the ghc version we need - Save that revision in ./generated/nixpkgsForGhc/ - 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//.nix - If nix build flag is enabled, build it - Copy $CACHE/per-hie//.nix to ./generated/stable/.nix - If master flag is enabled, regenerate ./generated/unstable by - (same process as above, only difference is first step)