mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
Merge pull request #153589 from abbradar/uwsgi-fixes
uWSGI configuration generation fixes
This commit is contained in:
commit
e8daaa85d4
1 changed files with 7 additions and 9 deletions
|
@ -20,10 +20,11 @@ let
|
||||||
|
|
||||||
buildCfg = name: c:
|
buildCfg = name: c:
|
||||||
let
|
let
|
||||||
plugins =
|
plugins' =
|
||||||
if any (n: !any (m: m == n) cfg.plugins) (c.plugins or [])
|
if any (n: !any (m: m == n) cfg.plugins) (c.plugins or [])
|
||||||
then throw "`plugins` attribute in uWSGI configuration contains plugins not in config.services.uwsgi.plugins"
|
then throw "`plugins` attribute in uWSGI configuration contains plugins not in config.services.uwsgi.plugins"
|
||||||
else c.plugins or cfg.plugins;
|
else c.plugins or cfg.plugins;
|
||||||
|
plugins = unique plugins';
|
||||||
|
|
||||||
hasPython = v: filter (n: n == "python${v}") plugins != [];
|
hasPython = v: filter (n: n == "python${v}") plugins != [];
|
||||||
hasPython2 = hasPython "2";
|
hasPython2 = hasPython "2";
|
||||||
|
@ -48,13 +49,10 @@ let
|
||||||
pyhome = "${pythonEnv}";
|
pyhome = "${pythonEnv}";
|
||||||
env =
|
env =
|
||||||
# Argh, uwsgi expects list of key-values there instead of a dictionary.
|
# Argh, uwsgi expects list of key-values there instead of a dictionary.
|
||||||
let env' = c.env or [];
|
let envs = partition (hasPrefix "PATH=") (c.env or []);
|
||||||
getPath =
|
oldPaths = map (x: substring (stringLength "PATH=") (stringLength x) x) envs.right;
|
||||||
x: if hasPrefix "PATH=" x
|
paths = oldPaths ++ [ "${pythonEnv}/bin" ];
|
||||||
then substring (stringLength "PATH=") (stringLength x) x
|
in [ "PATH=${concatStringsSep ":" paths}" ] ++ envs.wrong;
|
||||||
else null;
|
|
||||||
oldPaths = filter (x: x != null) (map getPath env');
|
|
||||||
in env' ++ [ "PATH=${optionalString (oldPaths != []) "${last oldPaths}:"}${pythonEnv}/bin" ];
|
|
||||||
}
|
}
|
||||||
else if isEmperor
|
else if isEmperor
|
||||||
then {
|
then {
|
||||||
|
@ -225,7 +223,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
services.uwsgi.package = pkgs.uwsgi.override {
|
services.uwsgi.package = pkgs.uwsgi.override {
|
||||||
inherit (cfg) plugins;
|
plugins = unique cfg.plugins;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue