mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-11 21:06:19 +03:00
Merge branch 'master' into closure-size
Beware that stdenv doesn't build. It seems something more will be needed than just resolution of merge conflicts.
This commit is contained in:
commit
ab15a62c68
1108 changed files with 76254 additions and 11297 deletions
78
nixos/modules/services/web-servers/apache-httpd/foswiki.nix
Normal file
78
nixos/modules/services/web-servers/apache-httpd/foswiki.nix
Normal file
|
@ -0,0 +1,78 @@
|
|||
{ config, pkgs, lib, serverInfo, ... }:
|
||||
let
|
||||
inherit (pkgs) foswiki;
|
||||
inherit (serverInfo.serverConfig) user group;
|
||||
inherit (config) vardir;
|
||||
in
|
||||
{
|
||||
options.vardir = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
default = "/var/www/foswiki";
|
||||
description = "The directory where variable foswiki data will be stored and served from.";
|
||||
};
|
||||
|
||||
# TODO: this will probably need to be better customizable
|
||||
extraConfig =
|
||||
let httpd-conf = pkgs.runCommand "foswiki-httpd.conf"
|
||||
{ preferLocalBuild = true; }
|
||||
''
|
||||
substitute '${foswiki}/foswiki_httpd_conf.txt' "$out" \
|
||||
--replace /var/www/foswiki/ "${vardir}/"
|
||||
'';
|
||||
in
|
||||
''
|
||||
RewriteEngine on
|
||||
RewriteRule /foswiki/(.*) ${vardir}/$1
|
||||
|
||||
<Directory "${vardir}">
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
Include ${httpd-conf}
|
||||
<Directory "${vardir}/pub">
|
||||
Options FollowSymlinks
|
||||
</Directory>
|
||||
'';
|
||||
|
||||
/** This handles initial setup and updates.
|
||||
It will probably need some tweaking, maybe per-site. */
|
||||
startupScript = pkgs.writeScript "foswiki_startup.sh" (
|
||||
let storeLink = "${vardir}/package"; in
|
||||
''
|
||||
[ -e '${storeLink}' ] || needs_setup=1
|
||||
mkdir -p '${vardir}'
|
||||
cd '${vardir}'
|
||||
ln -sf -T '${foswiki}' '${storeLink}'
|
||||
|
||||
if [ -n "$needs_setup" ]; then # do initial setup
|
||||
mkdir -p bin lib
|
||||
# setup most of data/ as copies only
|
||||
cp -r '${foswiki}'/data '${vardir}/'
|
||||
rm -r '${vardir}'/data/{System,mime.types}
|
||||
ln -sr -t '${vardir}/data/' '${storeLink}'/data/{System,mime.types}
|
||||
|
||||
ln -sr '${storeLink}/locale' .
|
||||
|
||||
mkdir pub
|
||||
ln -sr '${storeLink}/pub/System' pub/
|
||||
|
||||
mkdir templates
|
||||
ln -sr '${storeLink}'/templates/* templates/
|
||||
|
||||
ln -sr '${storeLink}/tools' .
|
||||
|
||||
mkdir -p '${vardir}'/working/{logs,tmp}
|
||||
ln -sr '${storeLink}/working/README' working/ # used to check dir validity
|
||||
|
||||
chown -R '${user}:${group}' .
|
||||
chmod +w -R .
|
||||
fi
|
||||
|
||||
# bin/* and lib/* shall always be overwritten, in case files are added
|
||||
ln -srf '${storeLink}'/bin/* '${vardir}/bin/'
|
||||
ln -srf '${storeLink}'/lib/* '${vardir}/lib/'
|
||||
''
|
||||
/* Symlinking bin/ one-by-one ensures that ${vardir}/lib/LocalSite.cfg
|
||||
is used instead of ${foswiki}/... */
|
||||
);
|
||||
}
|
|
@ -32,17 +32,27 @@ let
|
|||
self = pythonPackages;
|
||||
};
|
||||
|
||||
json = builtins.toJSON {
|
||||
penv = python.buildEnv.override {
|
||||
extraLibs = (c.pythonPackages or (self: [])) pythonPackages;
|
||||
};
|
||||
|
||||
uwsgiCfg = {
|
||||
uwsgi =
|
||||
if c.type == "normal"
|
||||
then {
|
||||
inherit plugins;
|
||||
} // removeAttrs c [ "type" "pythonPackages" ]
|
||||
// optionalAttrs (python != null) {
|
||||
pythonpath = "@PYTHONPATH@";
|
||||
env = (c.env or {}) // {
|
||||
PATH = optionalString (c ? env.PATH) "${c.env.PATH}:" + "@PATH@";
|
||||
};
|
||||
pythonpath = "${penv}/${python.sitePackages}";
|
||||
env =
|
||||
# Argh, uwsgi expects list of key-values there instead of a dictionary.
|
||||
let env' = c.env or [];
|
||||
getPath =
|
||||
x: if hasPrefix "PATH=" x
|
||||
then substring (stringLength "PATH=") (stringLength x) x
|
||||
else null;
|
||||
oldPaths = filter (x: x != null) (map getPath env');
|
||||
in env' ++ [ "PATH=${optionalString (oldPaths != []) "${last oldPaths}:"}${penv}/bin" ];
|
||||
}
|
||||
else if c.type == "emperor"
|
||||
then {
|
||||
|
@ -55,35 +65,7 @@ let
|
|||
else throw "`type` attribute in UWSGI configuration should be either 'normal' or 'emperor'";
|
||||
};
|
||||
|
||||
in
|
||||
if python == null || c.type != "normal"
|
||||
then pkgs.writeTextDir "${name}.json" json
|
||||
else pkgs.stdenv.mkDerivation {
|
||||
name = "uwsgi-config";
|
||||
inherit json;
|
||||
passAsFile = [ "json" ];
|
||||
nativeBuildInputs = [ pythonPackages.wrapPython ];
|
||||
pythonInputs = (c.pythonPackages or (self: [])) pythonPackages;
|
||||
|
||||
buildCommand = ''
|
||||
mkdir $out
|
||||
declare -A pythonPathsSeen=()
|
||||
program_PYTHONPATH=
|
||||
program_PATH=
|
||||
if [ -n "$pythonInputs" ]; then
|
||||
for i in $pythonInputs; do
|
||||
_addToPythonPath $i
|
||||
done
|
||||
fi
|
||||
# A hack to replace "@PYTHONPATH@" with a JSON list
|
||||
if [ -n "$program_PYTHONPATH" ]; then
|
||||
program_PYTHONPATH="\"''${program_PYTHONPATH//:/\",\"}\""
|
||||
fi
|
||||
substitute $jsonPath $out/${name}.json \
|
||||
--replace '"@PYTHONPATH@"' "[$program_PYTHONPATH]" \
|
||||
--subst-var-by PATH "$program_PATH"
|
||||
'';
|
||||
};
|
||||
in pkgs.writeTextDir "${name}.json" (builtins.toJSON uwsgiCfg);
|
||||
|
||||
in {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue