-
Notifications
You must be signed in to change notification settings - Fork 10
/
flake.nix
46 lines (44 loc) · 1.78 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
description = "Utilities for ops and packaging nix";
outputs = { self, nixpkgs }: let
# This is meant to make it easy to create hydraJobs with flakes
# the two issues with numtide-flakeutils, is that it will create the packages
# at the wrong attr path. E.g. hydraJobs.x86_64-linux.package. And the
# other issue is that it also makes it hard to scope the jobs to
# only as subset of platforms.
#
# Example usage:
#
# let
# pkgsForSystem = system: (import nixpkgs) { inherit system; overlays = [
# (import ./nix/overlay.nix)
# ];};
# hydraUtils = ops-lib.lib.mkHydraUtils pkgsForSystem;
# inherit (hydraUtils) collectHydraSets mkHydraSet;
# in (collectHydraSets [
# (mkHydraSet [ "mantis-docker" ] [ "x86_64-linux" ])
# (mkHydraSet [ "mantis" "mantis-explorer" ] [ "x86_64-linux" "x86_64-darwin" ])
# ])
#
# This flake will evaluate to:
# { hydraJobs = {
# mantis.x86_64-linux = <drv>;
# mantis.x86_64-darwin = <drv>;
# mantis-explorer.x86_64-linux = <drv>;
# mantis-explorer.x86_64-darwin = <drv>;
# mantis-docker.x86_64-linux = <drv>;
# };}
mkHydraUtils = mkPkgs: let
inherit (nixpkgs) lib;
# [attrset] -> attrset
recursiveMerge = lib.foldr lib.recursiveUpdate {};
mkHydraJobsForSystem = attrs: system:
recursiveMerge (map (n: { "${n}"."${system}" = (mkPkgs system)."${n}"; }) attrs);
in {
collectHydraSets = jobSets: { hydraJobs = recursiveMerge jobSets; };
mkHydraSet = attrs: systems: recursiveMerge (map (mkHydraJobsForSystem attrs) systems);
};
in {
lib = { inherit mkHydraUtils; };
};
}