2020-10-27 15:55:49 +03:00
|
|
|
/* Examples
|
|
|
|
|
|
|
|
Perform the same evaluation that occurs on CI via:
|
|
|
|
|
|
|
|
$ NIX_PATH="" nix-instantiate ci.nix --arg supportedSystems '["x86_64-darwin"]'
|
|
|
|
|
|
|
|
Build the release tarball:
|
|
|
|
|
|
|
|
$ NIX_PATH="" nix-instantiate ci.nix -A darwin.tarball
|
|
|
|
*/
|
|
|
|
|
|
|
|
{ supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ] }:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2020-11-04 14:36:40 +03:00
|
|
|
inherit (import ./nix/default.nix { })
|
|
|
|
lib haskell-nix recurseIntoAttrs callPackage;
|
2020-10-27 15:55:49 +03:00
|
|
|
|
|
|
|
# Local library import from derivation functions such as fetchGitHubLFS, etc.
|
|
|
|
# upon which local package defintions are dependent.
|
2020-11-06 11:47:11 +03:00
|
|
|
libLocal = callPackage ./nix/lib { };
|
2020-10-27 15:55:49 +03:00
|
|
|
|
|
|
|
# The key with google storage bucket write permission,
|
2020-11-05 15:19:09 +03:00
|
|
|
# deployed to ci via nixops deployment.keys."service-account.json".
|
2020-11-04 13:14:57 +03:00
|
|
|
serviceAccountKey = builtins.readFile
|
|
|
|
("/var/lib/hercules-ci-agent/secrets/service-account.json");
|
2020-10-27 15:55:49 +03:00
|
|
|
|
2020-11-05 15:19:09 +03:00
|
|
|
# Filter out systems that this machine does not support.
|
2020-10-30 15:02:27 +03:00
|
|
|
systems = lib.filterAttrs (_: v: builtins.elem v supportedSystems) {
|
|
|
|
linux = "x86_64-linux";
|
|
|
|
darwin = "x86_64-darwin";
|
2020-10-27 15:55:49 +03:00
|
|
|
};
|
|
|
|
|
2020-11-06 11:47:11 +03:00
|
|
|
# Build the ci matrix for each of the supported systems, see pkgsFinal
|
2020-11-05 15:19:09 +03:00
|
|
|
# for the total set of attributes that will be evaluated per system.
|
2020-11-06 11:47:11 +03:00
|
|
|
in libLocal.dimension "system" systems (systemName: system:
|
2020-10-27 15:55:49 +03:00
|
|
|
let
|
2020-11-06 11:47:11 +03:00
|
|
|
pkgsShared = import ./default.nix {
|
2020-10-28 20:19:53 +03:00
|
|
|
inherit system;
|
2020-10-27 15:55:49 +03:00
|
|
|
|
|
|
|
enableStatic = false;
|
|
|
|
};
|
|
|
|
|
2020-11-06 11:47:11 +03:00
|
|
|
pkgsStatic = import ./default.nix {
|
2020-10-30 15:02:27 +03:00
|
|
|
inherit system;
|
2020-10-27 15:55:49 +03:00
|
|
|
|
|
|
|
enableStatic = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Filter the stack project to only our locally declared packages.
|
2020-11-06 11:47:11 +03:00
|
|
|
pkgsHaskell = haskell-nix.haskellLib.selectProjectPackages pkgsStatic.hs;
|
2020-10-27 15:55:49 +03:00
|
|
|
|
|
|
|
# The top-level set of attributes to build on ci.
|
2020-11-06 11:47:11 +03:00
|
|
|
pkgsFinal = {
|
2020-11-04 13:14:57 +03:00
|
|
|
# Expose select packages to increase signal-to-noise of the ci dashboard.
|
2020-11-06 11:47:11 +03:00
|
|
|
inherit (pkgsStatic) urbit;
|
|
|
|
inherit (pkgsShared) urbit-tests;
|
2020-10-30 15:02:27 +03:00
|
|
|
|
2020-11-04 13:14:57 +03:00
|
|
|
# Expose the nix-shell derivation as a sanity check + possible cache hit.
|
2020-10-27 15:55:49 +03:00
|
|
|
shell = import ./shell.nix;
|
|
|
|
|
2020-10-30 15:02:27 +03:00
|
|
|
# Replace the .hs attribute with the individual collections of components
|
2020-10-27 15:55:49 +03:00
|
|
|
# displayed as top-level attributes:
|
|
|
|
#
|
|
|
|
# <system>.hs.library.[...]
|
2020-10-30 15:02:27 +03:00
|
|
|
# <system>.hs.checks.[...]
|
2020-10-27 15:55:49 +03:00
|
|
|
# <system>.hs.tests.[...]
|
2020-10-30 15:02:27 +03:00
|
|
|
# <system>.hs.benchmarks.[...]
|
2020-10-27 15:55:49 +03:00
|
|
|
# ...
|
2020-10-30 15:02:27 +03:00
|
|
|
#
|
|
|
|
# Note that .checks are the actual _execution_ of the tests.
|
2020-11-06 11:47:11 +03:00
|
|
|
hs = libLocal.collectHaskellComponents pkgsHaskell;
|
2020-10-27 15:55:49 +03:00
|
|
|
|
2020-11-04 13:14:57 +03:00
|
|
|
# Push the tarball to the google storage bucket for the current platform.
|
2020-11-06 11:47:11 +03:00
|
|
|
release = let inherit (pkgsStatic) tarball;
|
|
|
|
in libLocal.pushStorageObject {
|
2020-11-05 15:19:09 +03:00
|
|
|
inherit serviceAccountKey;
|
|
|
|
|
|
|
|
bucket = "bootstrap.urbit.org";
|
|
|
|
object = "ci/${lib.removePrefix "/nix/store/" (toString tarball)}";
|
2020-10-28 13:43:22 +03:00
|
|
|
name = tarball.name;
|
2020-11-05 15:19:09 +03:00
|
|
|
file = tarball.out;
|
2020-10-28 13:43:22 +03:00
|
|
|
contentType = "application/x-gtar";
|
|
|
|
};
|
2020-10-27 15:55:49 +03:00
|
|
|
};
|
2020-11-05 14:07:24 +03:00
|
|
|
|
2020-10-27 15:55:49 +03:00
|
|
|
# Filter derivations that have meta.platform missing the current system,
|
|
|
|
# such as testFakeShip on darwin.
|
2020-11-06 11:47:11 +03:00
|
|
|
platformFilter = libLocal.platformFilterGeneric system;
|
2020-10-27 15:55:49 +03:00
|
|
|
|
2020-11-06 11:47:11 +03:00
|
|
|
in libLocal.filterAttrsOnlyRecursive (_: v: platformFilter v) pkgsFinal)
|