mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-21 05:04:00 +00:00
37 lines
645 B
Nix
37 lines
645 B
Nix
|
# This file defines functions to handle upstart-jobs.
|
||
|
{pkgs, config, ...}:
|
||
|
|
||
|
let
|
||
|
inherit (pkgs.lib) filter findSingle;
|
||
|
jobs = config.services.extraJobs;
|
||
|
|
||
|
primaryEvents = [
|
||
|
"startup"
|
||
|
"shutdown"
|
||
|
"never"
|
||
|
];
|
||
|
|
||
|
upstartJobsTools = rec {
|
||
|
exists = name:
|
||
|
let
|
||
|
found = filter
|
||
|
(j: j ? name && j.name == name)
|
||
|
(jobs ++ map (name: {inherit name;}) primaryEvents);
|
||
|
in found != [];
|
||
|
|
||
|
check = name:
|
||
|
if exists name then
|
||
|
name
|
||
|
else
|
||
|
abort "Undefined upstart job name: ${name}.";
|
||
|
};
|
||
|
in
|
||
|
|
||
|
{
|
||
|
services = {
|
||
|
tools = {
|
||
|
upstartJobs = upstartJobsTools;
|
||
|
};
|
||
|
};
|
||
|
}
|