diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3a76b1ea..243d2f11 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -106,11 +106,6 @@ jobs: runs-on: ubuntu-latest needs: - build-repo - strategy: - matrix: - ghc: - - ghc8107 - - ghc926 steps: - name: Install Nix @@ -133,7 +128,7 @@ jobs: name: built-repo path: _repo - - name: Build a smoke-test package + - name: Build checks # The > is the "YAML folded string" marker, which replaces # newlines with spaces, since the usual bash idiom of \ # doesn't work for some reason @@ -141,14 +136,13 @@ jobs: # See https://github.com/nixbuild/feedback/issues/14 for # why some of these options are here run: > - nix build + nix flake check -L --override-input CHaP path:_repo --eval-store auto --store ssh-ng://eu.nixbuild.net --max-jobs 2 --builders "" - .#hydraJobs.${{matrix.ghc}}.plutus-core-1-1-1-0.x86_64-linux deploy-check: runs-on: ubuntu-latest diff --git a/builder/default.nix b/builder/default.nix index 1e583e37..6a071fd2 100644 --- a/builder/default.nix +++ b/builder/default.nix @@ -2,15 +2,25 @@ compiler-nix-name: let inherit (pkgs) lib; + inherit (pkgs.haskell-nix) haskellLib; + # [ { name = "foo"; version = "X.Y.Z"; }, { name = "foo"; version = "P.Q.R"; } ] chap-package-list = - builtins.filter (lib.strings.hasPrefix "plutus-core") ( - builtins.map (p: "${p.pkg-name}-${p.pkg-version}") - (builtins.fromJSON (builtins.readFile "${CHaP}/foliage/packages.json"))); + builtins.map (p: { name = p.pkg-name; version = p.pkg-version; }) + (builtins.fromJSON (builtins.readFile "${CHaP}/foliage/packages.json")); - build-chap-package = package-id: + # { "foo" : [ "X.Y.Z" "P.Q.R" ], ... } + chap-package-attrs = + let + # { "foo" = [{ name = "foo"; version = "X.Y.Z"; }, { name = "foo"; version = "P.Q.R"; }]; ... } + grouped = lib.groupBy (m: m.name) chap-package-list; + # { "foo" : [ "X.Y.Z" "P.Q.R" ], ... } + simplified = lib.mapAttrs (name: metas: builtins.map (m: m.version) metas) grouped; + in simplified; + + chap-package-components = package-name: package-version: let - package-name = (builtins.parseDrvName package-id).name; + package-id = "${package-name}-${package-version}"; # No need to set index-state: # - haskell.nix will automatically use the latest known one for hackage @@ -46,16 +56,10 @@ let }]; }; - - in - pkgs.releaseTools.aggregate { - name = package-id; - constituents = lib.collect lib.isDerivation { - inherit (project.hsPkgs.${package-name}) components checks; - }; - }; - + pkg = project.hsPkgs.${package-name}; + components = haskellLib.getAllComponents pkg; + # Not an ideal name here, would be nice to use something simpler + in lib.recurseIntoAttrs (builtins.listToAttrs (builtins.map (c: lib.nameValuePair c.name c) components)); in -lib.attrsets.mapAttrs' (name: lib.attrsets.nameValuePair (builtins.replaceStrings [ "." ] [ "-" ] name)) ( - lib.attrsets.genAttrs chap-package-list build-chap-package -) +# { foo = { X.Y.Z = ; P.Q.R = ; }; ... } +lib.recurseIntoAttrs (lib.mapAttrs (name: versions: lib.recurseIntoAttrs (lib.genAttrs versions (version: chap-package-components name version))) chap-package-attrs) diff --git a/flake.nix b/flake.nix index 9a5f07fd..784f7eb5 100644 --- a/flake.nix +++ b/flake.nix @@ -34,18 +34,29 @@ }; outputs = { self, nixpkgs, flake-utils, foliage, haskell-nix, CHaP, iohk-nix, ... }: - flake-utils.lib.eachDefaultSystem + let + compilers = [ "ghc8107" "ghc926" ]; + smokeTestPackages = [ + "cardano-node" + "cardano-cli" + "cardano-api" + "plutus-core" + ]; + # The foliage flake only works on this system, so we are stuck with it too + in flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: - let pkgs = import nixpkgs { - inherit system; - inherit (haskell-nix) config; - overlays = [ - haskell-nix.overlay - iohk-nix.overlays.crypto - ]; - }; + let + pkgs = import nixpkgs { + inherit system; + inherit (haskell-nix) config; + overlays = [ + haskell-nix.overlay + iohk-nix.overlays.crypto + ]; + }; + inherit (pkgs) lib; in - { + rec { devShells.default = with pkgs; mkShellNoCC { name = "cardano-haskell-packages"; buildInputs = [ @@ -58,13 +69,27 @@ ]; }; - hydraJobs = + # { ghc8107 = { foo = { X.Y.Z = ; ... }; ...}; ... } + haskellPackages = let - inherit (pkgs) lib; builder = import ./builder { inherit pkgs CHaP; }; - compilers = [ "ghc8107" "ghc926" ]; in - lib.attrsets.genAttrs compilers builder; + lib.recurseIntoAttrs (lib.genAttrs compilers builder); + + # A nested tree of derivations containing all the smoke test packages for all the compiler versions + smokeTestDerivations = lib.genAttrs compilers (compiler: + let + # The latest version in the set (attrValues sorts by key). Remove the 'recurseForDerivations' here otherwise + # we get that! + latest = versionToValue: lib.last (lib.attrValues (builtins.removeAttrs versionToValue ["recurseForDerivations"])); + compilerPkgs = builtins.getAttr compiler haskellPackages; + smokeTestPkgs = lib.recurseIntoAttrs (lib.genAttrs smokeTestPackages (pkgname: latest (builtins.getAttr pkgname compilerPkgs))); + in smokeTestPkgs); + + # The standard checks: build all the smoke test packages + checks = flake-utils.lib.flattenTree smokeTestDerivations; + + hydraJobs = checks; }); nixConfig = { @@ -82,5 +107,6 @@ "loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk=" "nixbuild.net/smart.contracts@iohk.io-1:s2PhQXWwsZo1y5IxFcx2D/i2yfvgtEnRBOZavlA8Bog=" ]; + allow-import-from-derivation = true; }; }