Merge pull request #317035 from ck3d/fix-node-red-path

nixos/node-red: fix passthru of PATH
This commit is contained in:
Markus Kowalewski 2024-06-09 20:13:58 +00:00 committed by GitHub
commit b98e90213d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,15 +5,6 @@ with lib;
let
cfg = config.services.node-red;
defaultUser = "node-red";
finalPackage = if cfg.withNpmAndGcc then node-red_withNpmAndGcc else cfg.package;
node-red_withNpmAndGcc = pkgs.runCommand "node-red" {
nativeBuildInputs = [ pkgs.makeWrapper ];
}
''
mkdir -p $out/bin
makeWrapper ${pkgs.nodePackages.node-red}/bin/node-red $out/bin/node-red \
--set PATH '${lib.makeBinPath [ pkgs.nodePackages.npm pkgs.gcc ]}:$PATH' \
'';
in
{
options.services.node-red = {
@ -127,11 +118,12 @@ in
environment = {
HOME = cfg.userDir;
};
path = lib.optionals cfg.withNpmAndGcc [ pkgs.nodePackages.npm pkgs.gcc ];
serviceConfig = mkMerge [
{
User = cfg.user;
Group = cfg.group;
ExecStart = "${finalPackage}/bin/node-red ${pkgs.lib.optionalString cfg.safe "--safe"} --settings ${cfg.configFile} --port ${toString cfg.port} --userDir ${cfg.userDir} ${concatStringsSep " " (mapAttrsToList (name: value: "-D ${name}=${value}") cfg.define)}";
ExecStart = "${cfg.package}/bin/node-red ${pkgs.lib.optionalString cfg.safe "--safe"} --settings ${cfg.configFile} --port ${toString cfg.port} --userDir ${cfg.userDir} ${concatStringsSep " " (mapAttrsToList (name: value: "-D ${name}=${value}") cfg.define)}";
PrivateTmp = true;
Restart = "always";
WorkingDirectory = cfg.userDir;