summaryrefslogtreecommitdiff
path: root/modules/launchd
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2017-05-15 08:34:53 +0200
committerDaiderd Jordan <daiderd@gmail.com>2017-05-15 08:34:53 +0200
commit7ca9f3d5bb32b45733ed16c54264823adf03aebf (patch)
treea816929db86ca90d562041bcd3173ccfd8ae6a4a /modules/launchd
parentfa03cd4939abb5cc150bd3205db268b3723be680 (diff)
launchd: add script option for services
Diffstat (limited to 'modules/launchd')
-rw-r--r--modules/launchd/default.nix16
1 files changed, 14 insertions, 2 deletions
diff --git a/modules/launchd/default.nix b/modules/launchd/default.nix
index 3a7bfea..7505937 100644
--- a/modules/launchd/default.nix
+++ b/modules/launchd/default.nix
@@ -5,6 +5,8 @@ with lib;
let
+ inherit (pkgs) stdenv;
+
cfg = config.launchd;
toEnvironmentText = name: value: {
@@ -51,6 +53,12 @@ let
description = "Command executed as the service's main process.";
};
+ script = mkOption {
+ type = types.lines;
+ default = "";
+ description = "Shell commands executed as the service's main process.";
+ };
+
# preStart = mkOption {
# type = types.lines;
# default = "";
@@ -75,6 +83,12 @@ let
};
config = {
+ command = mkIf (config.script != "") (pkgs.writeScript "${name}-start" ''
+ #! ${stdenv.shell}
+
+ ${config.script}
+ '');
+
serviceConfig.Label = mkDefault "org.nixos.${name}";
serviceConfig.ProgramArguments = mkIf (cmd != "") [ "/bin/sh" "-c" "exec ${cmd}" ];
serviceConfig.EnvironmentVariables = mkIf (env != {}) env;
@@ -85,7 +99,6 @@ in
{
options = {
-
launchd.envVariables = mkOption {
type = types.attrsOf (types.either types.str (types.listOf types.str));
default = {};
@@ -161,7 +174,6 @@ in
5. When the user logs out, it sends a SIGTERM signal to all of the user agents that it started.
'';
};
-
};
config = {