diff --git a/nix/default.nix b/nix/default.nix index 73e0f4e17a..236b03609e 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -53,23 +53,6 @@ let inherit (nixFmt) nix-fmt; nix-fmt-check = nixFmt.check; - - lib = super.lib // { - mk-jobset = import ./mk-jobset.nix self; - }; - - # An attribute set mapping every supported system to a nixpkgs evaluated for - # that system. Special care is taken not to reevaluate nixpkgs for the current - # system because we already did that in self. - pkgsForSystem = super.lib.genAttrs [ "x86_64-linux" "x86_64-darwin" ] ( - supportedSystem: - if supportedSystem == system - then self - else import ./. { - inherit RustSec-advisory-db; - system = supportedSystem; - } - ); } ) ]; diff --git a/nix/mk-jobset.nix b/nix/mk-jobset.nix deleted file mode 100644 index d84a88997a..0000000000 --- a/nix/mk-jobset.nix +++ /dev/null @@ -1,145 +0,0 @@ -pkgs: -# This function returns a Hydra jobset like for example: -# -# { -# ... -# dfx.build.x86_64-linux = derivation { system = "x86_64-linux"; ... }; -# dfx.build.x86_64-darwin = derivation { system = "x86_64-darwin"; ... }; -# publish.dfx.x86_64-linux = derivation { system = "x86_64-linux"; ... }; -# ... -# } -# -# by applying it to a jobset specification like: -# -# { -# ... -# dfx.build = derivation { ... }; -# publish.dfx = lib.linuxOnly ( derivation { ... } ); -# ... -# } -# -# So it transforms every top-level derivation in the specification to a set of -# jobs for every supported system (filtered by what the derivation supports). -# -# This function should be used in `common`, `dfinity`, `sdk` and `infra` to -# define their Hydra jobsets. -# -# TODO: This function is independent of this repo and should be moved to -# `common` eventually. See: https://dfinity.atlassian.net/browse/INF-1151 -{ - # A list of strings specifying for which systems to build jobs. - # - # Note that derivations can filter this list be setting the `meta.platforms` - # attribute or using the `lib.linuxOnly` function which does it for them. - supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ] - - # The system used to evaluate the nixpkgs set used in the implementation of - # this function (mainly to get access to its `lib`) and to evaluate the jobset - # specification which determines the final Hydra jobset. - # - # This should only be overridden in debugging scenarios. -, system ? pkgs.system - - # The git revision used in the `all-jobs` job. -, rev - - # Function to create the jobset specification. - # - # Note that this function will be called with the following argument: - # - # { - # inherit system; - # pkgs = pkgs.pkgsForSystem."${system}"; - # - # # We pass the final jobset such that jobs (like `publish.*` in the `sdk` - # # repo) can select pre-evaluated jobs (like `dfx-release.x86_64-linux`) - # # for a specific system without requiring them to do any reevaluation. - # inherit jobset; - # } - # - # for every supported `system`. -, mkJobsetSpec -}: -let - lib = pkgs.lib; - - # An attribute set mapping every supported system to an attribute set of jobs - # (as defined by `jobsetSpecificationPath`) evaluated for that system. - jobsForSystem = lib.genAttrs supportedSystems ( - system: mkJobsetSpec { - inherit system; - pkgs = pkgs.pkgsForSystem."${system}"; - - # We pass the final jobset such that jobs (like `publish.*` in the `sdk` - # repo) can select pre-evaluated jobs (like `dfx-release.x86_64-linux`) - # for a specific system without requiring them to do any re-evaluation. - inherit jobset; - } - ); - - # The final Hydra jobset defined as an attribute set as specified by the - # jobset specification but with every derivation replaced with an attribute - # set mapping the system that it should be build for to the derivation - # instantiated for that system. For example: - # - # jobset = { - # ... - # dfx.build.x86_64-linux = derivation { system = "x86_64-linux"; ... }; - # dfx.build.x86_64-darwin = derivation { system = "x86_64-darwin"; ... }; - # publish.dfx.x86_64-linux = derivation { system = "x86_64-linux"; ... }; - # ... - # } - jobset = lib.mapAttrsRecursiveCond - (as: !lib.isDerivation as) createJobsForDrv jobsForSystem."${system}"; - createJobsForDrv = path: drv: - let - # All supported systems filtered by what's specified by the derivation's - # `meta.platforms` attribute. - supportedSystemsByDrv = - if drv ? meta.platforms - then supportedMatches drv.meta.platforms - else supportedSystems; - in - lib.genAttrs supportedSystemsByDrv ( - system: lib.getAttrFromPath path jobsForSystem."${system}" - ); - - # (Copied from then modified). - # - # Given a list of 'meta.platforms'-style patterns, return the sublist of - # `supportedSystems` containing systems that matches at least one of the given - # patterns. - supportedMatches = metaPatterns: - let - anyMatch = platform: - lib.any (lib.meta.platformMatch platform) metaPatterns; - matchingPlatforms = lib.filter anyMatch supportedPlatforms; - in - map ({ system, ... }: system) matchingPlatforms; - - # The supported systems converted into platforms such that they can be matched - # with the derivation's `meta.platforms`. - supportedPlatforms = - map (system: lib.systems.elaborate { inherit system; }) supportedSystems; - - # The `all-jobs` is an aggregate job consisting of all other jobs. - # This job should build successfully to allow PRs to merge. - all-jobs = pkgs.releaseTools.aggregate { - name = "all-jobs"; - constituents = lib.collect lib.isDerivation jobset; - }; -in -jobset // { - all-jobs = all-jobs.overrideAttrs ( - _oldAttrs: { - # We need to make sure the `all-jobs` job is always rebuilt - # for every git commit. So we set a `rev` attribute on the - # derivation to the current git HEAD revision. Every time the git - # HEAD changes the `rev` attribute changes. This causes the - # derivation to be different causing it to be rebuild. - inherit rev; - - allowSubstitutes = false; - } - ); -} diff --git a/nix/sources.json b/nix/sources.json index 9b9c640d01..f65411ac19 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -26,9 +26,10 @@ "url_template": "https://github.com///archive/.tar.gz" }, "common": { - "ref": "master", + "branch": "basvandijk/refactor-and-optimize-mk-jobset", + "ref": "basvandijk/refactor-and-optimize-mk-jobset", "repo": "ssh://git@github.com/dfinity-lab/common", - "rev": "c022ff9f16ed0b9e3eb4ed97f26b493de3858df7", + "rev": "ed0b80ce1f370ead2f67f9827bb3ab5cc38655aa", "type": "git" }, "dfinity": {