mirror of
https://github.com/kiberpipa/nix-rehash.git
synced 2024-09-11 11:55:33 +03:00
fix the way how environment variables, especially PATH is handled
This commit is contained in:
parent
9391516e62
commit
d7fe7d18fe
@ -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}
|
||||
|
||||
|
@ -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}
|
||||
|
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user