Skip to content

Commit feaaa6c

Browse files
committed
experiment
1 parent ea57a13 commit feaaa6c

File tree

3 files changed

+26
-54
lines changed

3 files changed

+26
-54
lines changed

flake.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
cardano-mainnet-mirror.url = "github:input-output-hk/cardano-mainnet-mirror/nix";
6767

6868
tullia = {
69-
url = "github:input-output-hk/tullia";
69+
url = "github:input-output-hk/tullia/hydra";
7070
inputs.nixpkgs.follows = "nixpkgs";
7171
};
7272
};

nix/tullia.nix

Lines changed: 21 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
self: system:
22

33
let
4-
inherit (self.inputs.nixpkgs) lib;
5-
inherit (self.inputs.utils.lib) flattenTree;
6-
74
ciInputName = "GitHub event";
85
in rec {
96
tasks = let
7+
inherit (self.inputs.nixpkgs) lib;
8+
inherit (self.inputs.tullia) flakeOutputTasks taskSequence;
9+
1010
common = {
1111
config,
1212
...
@@ -22,60 +22,31 @@ in rec {
2222
};
2323
};
2424

25-
flakeUrl = {
26-
config,
27-
lib,
28-
...
29-
}: lib.escapeShellArg (
30-
if config.actionRun.facts != {}
31-
then with config.preset.github-ci; "github:${repo}/${sha}"
32-
else "."
33-
);
34-
3525
# the attribute name in `hydraJobs` for the current system
3626
os = {
3727
x86_64-linux = "linux";
3828
x86_64-darwin = "macos";
3929
}.${system};
4030

41-
# returns flattened attrset of `hydraJobs.${os}` and system-agnostic hydra jobs
42-
systemHydraJobs = hydraJobs:
43-
lib.pipe hydraJobs.${os} [
44-
(__mapAttrs (_: flattenTree))
45-
(__mapAttrs (category: lib.mapAttrs' (jobName: lib.nameValuePair "${os}.${category}.${jobName}")))
46-
__attrValues
47-
(__foldl' lib.mergeAttrs {})
48-
]
49-
// { inherit (hydraJobs) build-version cardano-deployment; };
50-
51-
# returns attrset of tullia tasks named with the given prefix
52-
# that run the corresponding task and depend on each other in the order given
53-
taskSequence = taskNamePrefix: taskNames: lib.listToAttrs (
54-
lib.imap0 (i: taskName: lib.nameValuePair
55-
(taskNamePrefix + taskName)
56-
({...}: {
57-
imports = [tasks.${taskName}];
58-
after = lib.optional (i > 0) (
59-
taskNamePrefix + __elemAt taskNames (i - 1)
60-
);
61-
})
62-
) taskNames
63-
);
31+
mkFlakeUrl = {config, ...}:
32+
if config.actionRun.facts != {}
33+
then with config.preset.github-ci; "github:${repo}/${sha}"
34+
else ".";
6435

65-
# returns attrset of tullia tasks that run the given hydra jobs sequentially in lexicographical order
66-
hydraJobsTaskSequence = taskNamePrefix: hydraJobs: taskSequence taskNamePrefix (__attrNames hydraJobs);
36+
hydraJobTasks = flakeOutputTasks ["hydraJobs" os] self mkFlakeUrl;
37+
hydraJobPrTasks = flakeOutputTasks ["hydraJobsPr" os] self mkFlakeUrl;
6738

68-
ciPushTasks = hydraJobsTaskSequence "ci/push/" (systemHydraJobs self.outputs.hydraJobs);
69-
ciPrTasks = hydraJobsTaskSequence "ci/pr/" (systemHydraJobs self.outputs.hydraJobsPr);
39+
ciPushTasks = taskSequence "ci/push/" hydraJobTasks (__attrNames hydraJobTasks);
40+
ciPrTasks = taskSequence "ci/pr/" hydraJobPrTasks (__attrNames hydraJobPrTasks);
7041
in
71-
(__mapAttrs (jobName: _: (args: {
72-
imports = [common];
42+
(__mapAttrs (jobName: task: {config, ...}: {
43+
imports = [common task];
7344

74-
command.text = ''
75-
job=${flakeUrl args}#hydraJobs.${lib.escapeShellArg jobName}
76-
echo Building "$job"…
77-
nix build -L "$job"
78-
'';
45+
# drvToTask.flakeUrl = __trace (__attrNames config.actionRun.facts) (
46+
# if config.actionRun.facts != {}
47+
# then with config.preset.github-ci; "github:${repo}/${sha}"
48+
# else "."
49+
# );
7950

8051
# some hydra jobs run NixOS tests
8152
env.NIX_CONFIG = ''
@@ -84,16 +55,16 @@ in rec {
8455

8556
memory = 1024 * 8;
8657
nomad.resources.cpu = 10000;
87-
})) (systemHydraJobs self.outputs.hydraJobs))
58+
}) hydraJobTasks)
8859
// ciPushTasks
8960
// ciPrTasks
9061
// {
91-
"ci/push" = {...}: {
62+
"ci/push" = {lib, ...}: {
9263
imports = [common];
9364
after = [(lib.last (__attrNames ciPushTasks))];
9465
};
9566

96-
"ci/pr" = {...}: {
67+
"ci/pr" = {lib, ...}: {
9768
imports = [common];
9869
after = [(lib.last (__attrNames ciPrTasks))];
9970
};

0 commit comments

Comments
 (0)