2016-11-01 21:25:22 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with import ./lib.nix { inherit lib; };
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.launchd;
|
|
|
|
|
2016-12-01 23:56:20 +01:00
|
|
|
toEnvironmentText = name: value: {
|
|
|
|
name = "${value.serviceConfig.Label}.plist";
|
|
|
|
value.text = toPLIST value.serviceConfig;
|
|
|
|
};
|
|
|
|
|
2016-11-01 21:25:22 +01:00
|
|
|
launchdConfig = import ./launchd.nix;
|
|
|
|
|
|
|
|
serviceOptions =
|
|
|
|
{ config, name, ... }:
|
|
|
|
{ options = {
|
|
|
|
serviceConfig = mkOption {
|
|
|
|
type = types.submodule launchdConfig;
|
|
|
|
example =
|
|
|
|
{ Program = "/run/current-system/sw/bin/nix-daemon";
|
|
|
|
KeepAlive = true;
|
|
|
|
};
|
|
|
|
default = {};
|
|
|
|
description = ''
|
|
|
|
Each attribute in this set specifies an option for a <key> in the plist.
|
|
|
|
https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
serviceConfig.Label = mkDefault "org.nixos.${name}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-12-01 23:56:20 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2016-11-01 21:25:22 +01:00
|
|
|
options = {
|
|
|
|
|
|
|
|
launchd.agents = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = types.attrsOf (types.submodule serviceOptions);
|
|
|
|
description = "Definition of launchd agents.";
|
|
|
|
};
|
|
|
|
|
|
|
|
launchd.daemons = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = types.attrsOf (types.submodule serviceOptions);
|
|
|
|
description = "Definition of launchd daemons.";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
|
2016-12-01 23:56:20 +01:00
|
|
|
environment.launchAgents = mapAttrs' toEnvironmentText cfg.agents;
|
|
|
|
environment.launchDaemons = mapAttrs' toEnvironmentText cfg.daemons;
|
2016-11-01 21:25:22 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
}
|