-
Notifications
You must be signed in to change notification settings - Fork 2
/
jobs.nix
47 lines (45 loc) · 1.42 KB
/
jobs.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
47
topLevel@{ flake-parts-lib, inputs, ... }: {
imports = [
./systems.nix
./runtime.nix
inputs.flake-parts.flakeModules.flakeModules
];
flake.flakeModules.jobs = {
imports = [
topLevel.config.flake.flakeModules.systems
topLevel.config.flake.flakeModules.runtime
];
options.perSystem = flake-parts-lib.mkPerSystemOption (perSystem@{ lib, config, ... }: {
options.ml-ops.job = lib.mkOption {
type = lib.types.deferredModule;
description = lib.mdDoc ''
The shared options among all jobs.
For example, config of `perSystem.ml-ops.job.xxx` will be copied to all `perSystem.ml-ops.jobs.<name>.xxx`.
'';
};
config.ml-ops.job = { config, ... }: {
imports = [ perSystem.config.ml-ops.runtime ];
options.launchers = lib.mkOption {
type = lib.types.attrsOf (lib.types.submoduleWith {
modules = [ config.launcher ];
});
default = { };
};
};
options.ml-ops.jobs = lib.mkOption {
default = { };
# TODO: Switch to `lazyAttrsOf` if `attrsOf` resulted in issues
type = lib.types.attrsOf (lib.types.submoduleWith {
modules = [
config.ml-ops.job
];
});
};
config.devenv.shells = lib.mapAttrs
(name: job: {
imports = [ job.devenvShellModule ];
})
config.ml-ops.jobs;
});
};
}