Skip to content

Commit 5308bbf

Browse files
committed
Implement production of hydraJobs on a generic flake
1 parent eaee40d commit 5308bbf

File tree

3 files changed

+86
-7
lines changed

3 files changed

+86
-7
lines changed

flake.nix

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
outputs =
2727
inputs@{
28+
self,
2829
nixpkgs,
2930
flake-parts,
3031
...
@@ -50,10 +51,17 @@
5051

5152
systems = [
5253
"x86_64-linux"
53-
# "x86_64-darwin"
54-
# "aarch64-linux"
55-
# "aarch64-darwin"
54+
"x86_64-darwin"
55+
"aarch64-linux"
56+
"aarch64-darwin"
5657
];
58+
59+
flake.hydraJobs = import ./nix/hydra.nix {
60+
flake = self;
61+
inherit lib;
62+
systems = [ "x86_64-linux" ];
63+
};
64+
5765
};
5866

5967
}

nix/build.nix

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
{ inputs, ... }:
1+
# NOTE(bladyjoker): Removing the hydraJobs from iogx to produce it generically for the entire flake after
2+
{ inputs, config, ... }:
23
{
3-
flake = inputs.iogx.lib.mkFlake {
4+
flake = builtins.removeAttrs (inputs.iogx.lib.mkFlake {
45

56
inherit inputs;
67

78
repoRoot = ./..;
89

910
outputs = import ./outputs.nix;
1011

11-
systems = [ "x86_64-linux" ];
12-
};
12+
inherit (config) systems;
13+
}) [ "hydraJobs" ];
1314
}

nix/hydra.nix

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Make default hydraJobs from Flake outputs
2+
# If you have the following checks/devShells/packages
3+
# ├───checks
4+
# │ └───x86_64-linux
5+
# │ ├───check-foo: derivation 'check-foo'
6+
# │ ├───check-bar: derivation 'check-bar'
7+
# │ └───x86_64-darwin
8+
# │ ├───check-foo: derivation 'check-foo'
9+
# │ ├───check-bar: derivation 'check-bar'
10+
# ├───devShells
11+
# │ └───x86_64-linux
12+
# │ ├───dev-foo: development environment 'dev-foo'
13+
# │ ├───dev-bar: development environment 'dev-bar'
14+
# │ └───x86_64-darwin
15+
# │ ├───dev-foo: development environment 'dev-foo'
16+
# │ ├───dev-bar: development environment 'dev-bar'
17+
# └───packages
18+
# └───x86_64-linux
19+
# ├───foo: package 'foo'
20+
# ├───bar: package 'bar'
21+
# └───x86_64-darwin
22+
# ├───foo: package 'foo'
23+
# ├───bar: package 'bar'
24+
# This function will produce hydraJobs as
25+
# ├───hydraJobs
26+
# │ ├───checks
27+
# │ │ ├───check-foo
28+
# │ │ │ └───x86_64-linux: derivation 'check-foo'
29+
# │ │ │ └───x86_64-darwin: derivation 'check-foo'
30+
# │ │ ├───check-bar
31+
# │ │ │ └───x86_64-linux: derivation 'check-bar'
32+
# │ │ │ └───x86_64-darwin: derivation 'check-bar'
33+
# │ ├───devShells
34+
# │ │ ├───dev-foo
35+
# │ │ │ └───x86_64-linux: derivation 'dev-foo'
36+
# │ │ │ └───x86_64-darwin: derivation 'dev-foo'
37+
# │ │ ├───dev-bar
38+
# │ │ │ └───x86_64-linux: derivation 'dev-bar'
39+
# │ │ │ └───x86_64-darwin: derivation 'dev-bar'
40+
# │ └───packages
41+
# │ ├───foo
42+
# │ │ └───x86_64-linux: derivation 'foo'
43+
# │ │ └───x86_64-darwin: derivation 'foo'
44+
# │ ├───bar
45+
# │ │ └───x86_64-linux: derivation 'bar'
46+
# │ │ └───x86_64-darwin: derivation 'bar'
47+
{
48+
flake,
49+
lib,
50+
systems,
51+
...
52+
}:
53+
let
54+
flakeOutputs = [
55+
"packages"
56+
"checks"
57+
"devShells"
58+
];
59+
in
60+
lib.genAttrs flakeOutputs (
61+
flakeOutput:
62+
lib.foldl' lib.recursiveUpdate { } (
63+
builtins.map (
64+
system:
65+
lib.genAttrs (builtins.attrNames flake.${flakeOutput}.${system}) (drvName: {
66+
${system} = flake.${flakeOutput}.${system}.${drvName};
67+
})
68+
) systems
69+
)
70+
)

0 commit comments

Comments
 (0)