1
1
self : system :
2
2
3
3
let
4
- inherit ( self . inputs . nixpkgs ) lib ;
5
- inherit ( self . inputs . utils . lib ) flattenTree ;
6
-
7
4
ciInputName = "GitHub event" ;
8
5
in rec {
9
6
tasks = let
7
+ inherit ( self . inputs . nixpkgs ) lib ;
8
+ inherit ( self . inputs . tullia ) flakeOutputTasks taskSequence ;
9
+
10
10
common = {
11
11
config ,
12
12
...
@@ -22,60 +22,31 @@ in rec {
22
22
} ;
23
23
} ;
24
24
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
-
35
25
# the attribute name in `hydraJobs` for the current system
36
26
os = {
37
27
x86_64-linux = "linux" ;
38
28
x86_64-darwin = "macos" ;
39
29
} . ${ system } ;
40
30
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 "." ;
64
35
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 ;
67
38
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 ) ;
70
41
in
71
- ( __mapAttrs ( jobName : _ : ( args : {
72
- imports = [ common ] ;
42
+ ( __mapAttrs ( jobName : task : { config , ... } : {
43
+ imports = [ common task ] ;
73
44
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
+ # ) ;
79
50
80
51
# some hydra jobs run NixOS tests
81
52
env . NIX_CONFIG = ''
@@ -84,16 +55,16 @@ in rec {
84
55
85
56
memory = 1024 * 8 ;
86
57
nomad . resources . cpu = 10000 ;
87
- } ) ) ( systemHydraJobs self . outputs . hydraJobs ) )
58
+ } ) hydraJobTasks )
88
59
// ciPushTasks
89
60
// ciPrTasks
90
61
// {
91
- "ci/push" = { ...} : {
62
+ "ci/push" = { lib , ...} : {
92
63
imports = [ common ] ;
93
64
after = [ ( lib . last ( __attrNames ciPushTasks ) ) ] ;
94
65
} ;
95
66
96
- "ci/pr" = { ...} : {
67
+ "ci/pr" = { lib , ...} : {
97
68
imports = [ common ] ;
98
69
after = [ ( lib . last ( __attrNames ciPrTasks ) ) ] ;
99
70
} ;
0 commit comments