Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions ci/ci.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{ supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ]
, system ? builtins.currentSystem
, src ? {
rev = pkgs.lib.commitIdFromGitRepo (pkgs.lib.gitDir ../.);
revCount = 0; # TODO: would be nice to get the `revCount` using Nix as well.
}
, src ? builtins.fetchGit ../.
, RustSec-advisory-db ? null

# The version of the release. Will be set to the right value in ./release.nix.
Expand All @@ -12,12 +9,10 @@
# TODO: Remove isMaster once switched to new CD system (https://dfinity.atlassian.net/browse/INF-1149)
, isMaster ? true

, pkgsPath ? ../nix
, pkgs ? import pkgsPath pkgsArgs
, pkgsArgs ? { inherit RustSec-advisory-db releaseVersion isMaster; }
, pkgs ? import ../nix { inherit system releaseVersion isMaster RustSec-advisory-db; }
}:
import ./mk-jobset.nix {
inherit supportedSystems system pkgsPath pkgs pkgsArgs;
pkgs.lib.mk-jobset {
inherit supportedSystems;
inherit (src) rev;
jobsetSpecificationPath = ../.;
jobsArgs = { inherit RustSec-advisory-db releaseVersion isMaster src; };
Expand Down
19 changes: 18 additions & 1 deletion nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,24 @@ let
inherit (nixFmt) nix-fmt;
nix-fmt-check = nixFmt.check;

lib = super.lib // { mkRelease = super.callPackage ./mk-release.nix { inherit isMaster; }; };
lib = super.lib // {
mk-jobset = import ./mk-jobset.nix self;

mkRelease = super.callPackage ./mk-release.nix { inherit isMaster; };
};

# 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 releaseVersion isMaster RustSec-advisory-db;
system = supportedSystem;
}
);
}
)
];
Expand Down
35 changes: 3 additions & 32 deletions ci/mk-jobset.nix → nix/mk-jobset.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pkgs:
# This function returns a Hydra jobset like for example:
#
# {
Expand Down Expand Up @@ -39,23 +40,9 @@
# This should only be overridden in debugging scenarios.
, system ? pkgs.system

# The nixpkgs set used to implement this function.
, pkgs

# The git revision used in the `all-jobs` job.
, rev

# Path to the Nix expression defining the nixpkgs set.
#
# It's recommended to standardize this to `../nix`.
#
# Note that nixpkgs will be called with the following arguments:
#
# pkgsArgs // { inherit system; }
#
# for every supported `system`.
, pkgsPath

# Path to the jobset specification.
#
# It's recommended to standardize this to `../.`.
Expand All @@ -65,7 +52,7 @@
#
# jobsArgs // {
# inherit system;
# pkgs = pkgsForSystem."${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`)
Expand All @@ -76,35 +63,19 @@
# for every supported `system`.
, jobsetSpecificationPath

# Extra arguments to the `pkgsPath` function.
, pkgsArgs ? {}

# Extra arguments to the `jobsetSpecificationPath` function.
, jobsArgs ? {}
}:
let
# This functions creates a nixpkgs set for the given system.
pkgsFor = system: import pkgsPath (pkgsArgs // { inherit system; });

lib = pkgs.lib;

# 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 pkgs.
pkgsForSystem = lib.genAttrs supportedSystems (
supportedSystem:
if supportedSystem == system
then pkgs
else pkgsFor supportedSystem
);

# 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: import jobsetSpecificationPath (
jobsArgs // {
inherit system;
pkgs = pkgsForSystem."${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`)
Expand Down