fix the way how environment variables, especially PATH is handled

This commit is contained in:
Jaka Hudoklin 2014-03-07 17:57:45 +01:00
parent 9391516e62
commit d7fe7d18fe
3 changed files with 14 additions and 6 deletions

View File

@ -28,6 +28,7 @@ let
startServices = pkgs.writeScript "startServices" ''
#!/bin/sh
export STATEDIR="${"\$"}{STATEDIR-$(pwd)/var}"
export PATH="${pkgs.coreutils}/bin"
mkdir -p $STATEDIR/{run,log}

View File

@ -16,6 +16,10 @@ let
PATH = "/some/path";
};
};
path = mkOption {
default = [];
description = "Current directory when running the command";
};
stopsignal = mkOption {
default = "TERM";
};
@ -75,7 +79,13 @@ in {
''
[program:${name}]
command=${cfg.command}
environment=${concatMapStrings (name: "${name}=\"${toString (getAttr name cfg.environment)}\",") (attrNames cfg.environment)}
environment=${concatStrings
(mapAttrsToList (name: value: "${name}=\"${value}\",") (
cfg.environment // { PATH = concatStringsSep ":"
[("%(ENV_PATH)s") (cfg.path) (maybeAttr "PATH" "" cfg.environment)];
}
)
)}
directory=${cfg.directory}
redirect_stderr=true
startsecs=${toString cfg.startsecs}

View File

@ -49,11 +49,8 @@ in {
name = name;
value = {
command = pkgs.writeScript "${name}-run" (configToCommand name cfg);
environment = (if hasAttr "environment" cfg then cfg.environment else {}) //
(if hasAttr "path" cfg then
{ PATH = "%(ENV_PATH)s:" + concatStringsSep ":" (map (prg: "${prg}/bin") cfg.path); }
else {
PATH="%(ENV_PATH)s"; });
environment = cfg.environment;
path = cfg.path;
stopsignal = if hasAttr "KillSignal" cfg.serviceConfig then
substring 3 (stringLength cfg.serviceConfig.KillSignal) cfg.serviceConfig.KillSignal
else "TERM";