Merge master into staging-next
This commit is contained in:
@@ -163,7 +163,8 @@
|
||||
Most of the httpd subservices packaged with NixOS have been replaced with
|
||||
full NixOS modules including LimeSurvey, WordPress, and Zabbix. These
|
||||
modules can be enabled using the <option>services.limesurvey.enable</option>,
|
||||
<option>services.wordpress.enable</option>, and <option>services.zabbixWeb.enable</option> options.
|
||||
<option>services.mediawiki.enable</option>, <option>services.wordpress.enable</option>,
|
||||
and <option>services.zabbixWeb.enable</option> options.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
{ config, pkgs ,lib ,... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options.xdg.portal = {
|
||||
enable =
|
||||
mkEnableOption "<link xlink:href='https://github.com/flatpak/xdg-desktop-portal'>xdg desktop integration</link>"//{
|
||||
default = config.services.xserver.enable;
|
||||
default = false;
|
||||
};
|
||||
|
||||
extraPortals = mkOption {
|
||||
@@ -19,6 +21,17 @@ with lib;
|
||||
environments you probably want to add them yourself.
|
||||
'';
|
||||
};
|
||||
|
||||
gtkUsePortal = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Sets environment variable <literal>GTK_USE_PORTAL</literal> to <literal>1</literal>.
|
||||
This is needed for packages ran outside Flatpak to respect and use XDG Desktop Portals.
|
||||
For example, you'd need to set this for non-flatpak Firefox to use native filechoosers.
|
||||
Defaults to <literal>false</literal> to respect its opt-in nature.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
@@ -28,10 +41,17 @@ with lib;
|
||||
|
||||
in mkIf cfg.enable {
|
||||
|
||||
assertions = [
|
||||
{ assertion = (cfg.gtkUsePortal -> cfg.extraPortals != []);
|
||||
message = "Setting xdg.portal.gtkUsePortal to true requires a portal implementation in xdg.portal.extraPortals such as xdg-desktop-portal-gtk or xdg-desktop-portal-kde.";
|
||||
}
|
||||
];
|
||||
|
||||
services.dbus.packages = packages;
|
||||
systemd.packages = packages;
|
||||
|
||||
environment.variables = {
|
||||
GTK_USE_PORTAL = "1";
|
||||
GTK_USE_PORTAL = optional cfg.gtkUsePortal "1";
|
||||
XDG_DESKTOP_PORTAL_PATH = map (p: "${p}/share/xdg-desktop-portal/portals") cfg.extraPortals;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -519,6 +519,7 @@
|
||||
./services/monitoring/systemhealth.nix
|
||||
./services/monitoring/teamviewer.nix
|
||||
./services/monitoring/telegraf.nix
|
||||
./services/monitoring/thanos.nix
|
||||
./services/monitoring/ups.nix
|
||||
./services/monitoring/uptime.nix
|
||||
./services/monitoring/vnstat.nix
|
||||
@@ -780,6 +781,7 @@
|
||||
./services/web-apps/icingaweb2/module-monitoring.nix
|
||||
./services/web-apps/limesurvey.nix
|
||||
./services/web-apps/mattermost.nix
|
||||
./services/web-apps/mediawiki.nix
|
||||
./services/web-apps/miniflux.nix
|
||||
./services/web-apps/nextcloud.nix
|
||||
./services/web-apps/nexus.nix
|
||||
|
||||
@@ -26,6 +26,8 @@ with lib;
|
||||
|
||||
security.allowSimultaneousMultithreading = mkDefault false;
|
||||
|
||||
security.forcePageTableIsolation = mkDefault true;
|
||||
|
||||
security.virtualisation.flushL1DataCache = mkDefault "always";
|
||||
|
||||
security.apparmor.enable = mkDefault true;
|
||||
@@ -42,9 +44,6 @@ with lib;
|
||||
|
||||
# Disable legacy virtual syscalls
|
||||
"vsyscall=none"
|
||||
|
||||
# Enable PTI even if CPU claims to be safe from meltdown
|
||||
"pti=on"
|
||||
];
|
||||
|
||||
boot.blacklistedKernelModules = [
|
||||
|
||||
@@ -12,7 +12,7 @@ with lib;
|
||||
''
|
||||
# Set up the per-user profile.
|
||||
mkdir -m 0755 -p "$NIX_USER_PROFILE_DIR"
|
||||
if [ "$(stat --printf '%u' "$NIX_USER_PROFILE_DIR")" != "$(id -u)" ]; then
|
||||
if [ "$(stat -c '%u' "$NIX_USER_PROFILE_DIR")" != "$(id -u)" ]; then
|
||||
echo "WARNING: the per-user profile dir $NIX_USER_PROFILE_DIR should belong to user id $(id -u)" >&2
|
||||
fi
|
||||
|
||||
@@ -34,7 +34,7 @@ with lib;
|
||||
# Create the per-user garbage collector roots directory.
|
||||
NIX_USER_GCROOTS_DIR="/nix/var/nix/gcroots/per-user/$USER"
|
||||
mkdir -m 0755 -p "$NIX_USER_GCROOTS_DIR"
|
||||
if [ "$(stat --printf '%u' "$NIX_USER_GCROOTS_DIR")" != "$(id -u)" ]; then
|
||||
if [ "$(stat -c '%u' "$NIX_USER_GCROOTS_DIR")" != "$(id -u)" ]; then
|
||||
echo "WARNING: the per-user gcroots dir $NIX_USER_GCROOTS_DIR should belong to user id $(id -u)" >&2
|
||||
fi
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ let
|
||||
|
||||
knownHostsText = (flip (concatMapStringsSep "\n") knownHosts
|
||||
(h: assert h.hostNames != [];
|
||||
concatStringsSep "," h.hostNames + " "
|
||||
optionalString h.certAuthority "@cert-authority " + concatStringsSep "," h.hostNames + " "
|
||||
+ (if h.publicKey != null then h.publicKey else readFile h.publicKeyFile)
|
||||
)) + "\n";
|
||||
|
||||
@@ -128,6 +128,14 @@ in
|
||||
default = {};
|
||||
type = types.loaOf (types.submodule ({ name, ... }: {
|
||||
options = {
|
||||
certAuthority = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
This public key is an SSH certificate authority, rather than an
|
||||
individual host's key.
|
||||
'';
|
||||
};
|
||||
hostNames = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
|
||||
@@ -26,6 +26,7 @@ in
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.xonsh;
|
||||
example = literalExample "pkgs.xonsh.override { configFile = \"/path/to/xonshrc\"; }";
|
||||
description = ''
|
||||
xonsh package to use.
|
||||
@@ -46,11 +47,11 @@ in
|
||||
|
||||
environment.etc."xonshrc".text = cfg.config;
|
||||
|
||||
environment.systemPackages = [ pkgs.xonsh ];
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
|
||||
environment.shells =
|
||||
[ "/run/current-system/sw/bin/xonsh"
|
||||
"${pkgs.xonsh}/bin/xonsh"
|
||||
"${cfg.package}/bin/xonsh"
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
@@ -54,6 +54,18 @@ with lib;
|
||||
'';
|
||||
};
|
||||
|
||||
security.forcePageTableIsolation = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to force-enable the Page Table Isolation (PTI) Linux kernel
|
||||
feature even on CPU models that claim to be safe from Meltdown.
|
||||
|
||||
This hardening feature is most beneficial to systems that run untrusted
|
||||
workloads that rely on address space isolation for security.
|
||||
'';
|
||||
};
|
||||
|
||||
security.virtualisation.flushL1DataCache = mkOption {
|
||||
type = types.nullOr (types.enum [ "never" "cond" "always" ]);
|
||||
default = null;
|
||||
@@ -114,6 +126,10 @@ with lib;
|
||||
boot.kernelParams = [ "nosmt" ];
|
||||
})
|
||||
|
||||
(mkIf config.security.forcePageTableIsolation {
|
||||
boot.kernelParams = [ "pti=on" ];
|
||||
})
|
||||
|
||||
(mkIf (config.security.virtualisation.flushL1DataCache != null) {
|
||||
boot.kernelParams = [ "kvm-intel.vmentry_l1d_flush=${config.security.virtualisation.flushL1DataCache}" ];
|
||||
})
|
||||
|
||||
@@ -22,6 +22,12 @@ in {
|
||||
###### implementation
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
assertions = [
|
||||
{ assertion = (config.xdg.portal.enable == true);
|
||||
message = "To use Flatpak you must enable XDG Desktop Portals with xdg.portal.enable.";
|
||||
}
|
||||
];
|
||||
|
||||
environment.systemPackages = [ pkgs.flatpak ];
|
||||
|
||||
services.dbus.packages = [ pkgs.flatpak ];
|
||||
|
||||
@@ -467,7 +467,7 @@ in
|
||||
fi
|
||||
'';
|
||||
|
||||
nix.nrBuildUsers = mkDefault (lib.max 32 cfg.maxJobs);
|
||||
nix.nrBuildUsers = mkDefault (lib.max 32 (if cfg.maxJobs == "auto" then 0 else cfg.maxJobs));
|
||||
|
||||
users.users = nixbldUsers;
|
||||
|
||||
|
||||
@@ -411,7 +411,7 @@ in {
|
||||
} else {
|
||||
cert = "${cfg.pki.manual.server.cert}";
|
||||
key = "${cfg.pki.manual.server.key}";
|
||||
crl = "${cfg.pki.manual.server.crl}";
|
||||
${mapNullable (_: "crl") cfg.pki.manual.server.crl} = "${cfg.pki.manual.server.crl}";
|
||||
});
|
||||
|
||||
ca.cert = if needToCreateCA then "${cfg.dataDir}/keys/ca.cert"
|
||||
|
||||
@@ -0,0 +1,801 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.thanos;
|
||||
|
||||
nullOpt = type: description: mkOption {
|
||||
type = types.nullOr type;
|
||||
default = null;
|
||||
inherit description;
|
||||
};
|
||||
|
||||
optionToArgs = opt: v : optional (v != null) ''--${opt}="${toString v}"'';
|
||||
flagToArgs = opt: v : optional v ''--${opt}'';
|
||||
listToArgs = opt: vs : map (v: ''--${opt}="${v}"'') vs;
|
||||
attrsToArgs = opt: kvs: mapAttrsToList (k: v: ''--${opt}=${k}=\"${v}\"'') kvs;
|
||||
|
||||
mkParamDef = type: default: description: mkParam type (description + ''
|
||||
|
||||
Defaults to <literal>${toString default}</literal> in Thanos
|
||||
when set to <literal>null</literal>.
|
||||
'');
|
||||
|
||||
mkParam = type: description: {
|
||||
toArgs = optionToArgs;
|
||||
option = nullOpt type description;
|
||||
};
|
||||
|
||||
mkFlagParam = description: {
|
||||
toArgs = flagToArgs;
|
||||
option = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
inherit description;
|
||||
};
|
||||
};
|
||||
|
||||
mkListParam = opt: description: {
|
||||
toArgs = _opt: listToArgs opt;
|
||||
option = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
inherit description;
|
||||
};
|
||||
};
|
||||
|
||||
mkAttrsParam = opt: description: {
|
||||
toArgs = _opt: attrsToArgs opt;
|
||||
option = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = {};
|
||||
inherit description;
|
||||
};
|
||||
};
|
||||
|
||||
mkStateDirParam = opt: default: description: {
|
||||
toArgs = _opt: stateDir: optionToArgs opt "/var/lib/${stateDir}";
|
||||
option = mkOption {
|
||||
type = types.str;
|
||||
inherit default;
|
||||
inherit description;
|
||||
};
|
||||
};
|
||||
|
||||
toYAML = name: attrs: pkgs.runCommandNoCC name {
|
||||
preferLocalBuild = true;
|
||||
json = builtins.toFile "${name}.json" (builtins.toJSON attrs);
|
||||
nativeBuildInputs = [ pkgs.remarshal ];
|
||||
} ''json2yaml -i $json -o $out'';
|
||||
|
||||
thanos = cmd: "${cfg.package}/bin/thanos ${cmd}" +
|
||||
(let args = cfg."${cmd}".arguments;
|
||||
in optionalString (length args != 0) (" \\\n " +
|
||||
concatStringsSep " \\\n " args));
|
||||
|
||||
argumentsOf = cmd: concatLists (collect isList
|
||||
(flip mapParamsRecursive params."${cmd}" (path: param:
|
||||
let opt = concatStringsSep "." path;
|
||||
v = getAttrFromPath path cfg."${cmd}";
|
||||
in param.toArgs opt v)));
|
||||
|
||||
mkArgumentsOption = cmd: mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = argumentsOf cmd;
|
||||
description = ''
|
||||
Arguments to the <literal>thanos ${cmd}</literal> command.
|
||||
|
||||
Defaults to a list of arguments formed by converting the structured
|
||||
options of <option>services.thanos.${cmd}</option> to a list of arguments.
|
||||
|
||||
Overriding this option will cause none of the structured options to have
|
||||
any effect. So only set this if you know what you're doing!
|
||||
'';
|
||||
};
|
||||
|
||||
mapParamsRecursive =
|
||||
let noParam = attr: !(attr ? "toArgs" && attr ? "option");
|
||||
in mapAttrsRecursiveCond noParam;
|
||||
|
||||
paramsToOptions = mapParamsRecursive (_path: param: param.option);
|
||||
|
||||
params = {
|
||||
|
||||
log = {
|
||||
|
||||
log.level = mkParamDef (types.enum ["debug" "info" "warn" "error" "fatal"]) "info" ''
|
||||
Log filtering level.
|
||||
'';
|
||||
|
||||
log.format = mkParam types.str ''
|
||||
Log format to use.
|
||||
'';
|
||||
};
|
||||
|
||||
tracing = cfg: {
|
||||
tracing.config-file = {
|
||||
toArgs = _opt: path: optionToArgs "tracing.config-file" path;
|
||||
option = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = if cfg.tracing.config == null then null
|
||||
else toString (toYAML "tracing.yaml" cfg.tracing.config);
|
||||
defaultText = ''
|
||||
if config.services.thanos.<cmd>.tracing.config == null then null
|
||||
else toString (toYAML "tracing.yaml" config.services.thanos.<cmd>.tracing.config);
|
||||
'';
|
||||
description = ''
|
||||
Path to YAML file that contains tracing configuration.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
tracing.config =
|
||||
{
|
||||
toArgs = _opt: _attrs: [];
|
||||
option = nullOpt types.attrs ''
|
||||
Tracing configuration.
|
||||
|
||||
When not <literal>null</literal> the attribute set gets converted to
|
||||
a YAML file and stored in the Nix store. The option
|
||||
<option>tracing.config-file</option> will default to its path.
|
||||
|
||||
If <option>tracing.config-file</option> is set this option has no effect.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
common = cfg: params.log // params.tracing cfg // {
|
||||
|
||||
http-address = mkParamDef types.str "0.0.0.0:10902" ''
|
||||
Listen <literal>host:port</literal> for HTTP endpoints.
|
||||
'';
|
||||
|
||||
grpc-address = mkParamDef types.str "0.0.0.0:10901" ''
|
||||
Listen <literal>ip:port</literal> address for gRPC endpoints (StoreAPI).
|
||||
|
||||
Make sure this address is routable from other components.
|
||||
'';
|
||||
|
||||
grpc-server-tls-cert = mkParam types.str ''
|
||||
TLS Certificate for gRPC server, leave blank to disable TLS
|
||||
'';
|
||||
|
||||
grpc-server-tls-key = mkParam types.str ''
|
||||
TLS Key for the gRPC server, leave blank to disable TLS
|
||||
'';
|
||||
|
||||
grpc-server-tls-client-ca = mkParam types.str ''
|
||||
TLS CA to verify clients against.
|
||||
|
||||
If no client CA is specified, there is no client verification on server side.
|
||||
(tls.NoClientCert)
|
||||
'';
|
||||
};
|
||||
|
||||
objstore = cfg: {
|
||||
|
||||
objstore.config-file = {
|
||||
toArgs = _opt: path: optionToArgs "objstore.config-file" path;
|
||||
option = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = if cfg.objstore.config == null then null
|
||||
else toString (toYAML "objstore.yaml" cfg.objstore.config);
|
||||
defaultText = ''
|
||||
if config.services.thanos.<cmd>.objstore.config == null then null
|
||||
else toString (toYAML "objstore.yaml" config.services.thanos.<cmd>.objstore.config);
|
||||
'';
|
||||
description = ''
|
||||
Path to YAML file that contains object store configuration.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
objstore.config =
|
||||
{
|
||||
toArgs = _opt: _attrs: [];
|
||||
option = nullOpt types.attrs ''
|
||||
Object store configuration.
|
||||
|
||||
When not <literal>null</literal> the attribute set gets converted to
|
||||
a YAML file and stored in the Nix store. The option
|
||||
<option>objstore.config-file</option> will default to its path.
|
||||
|
||||
If <option>objstore.config-file</option> is set this option has no effect.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
sidecar = params.common cfg.sidecar // params.objstore cfg.sidecar // {
|
||||
|
||||
prometheus.url = mkParamDef types.str "http://localhost:9090" ''
|
||||
URL at which to reach Prometheus's API.
|
||||
|
||||
For better performance use local network.
|
||||
'';
|
||||
|
||||
tsdb.path = {
|
||||
toArgs = optionToArgs;
|
||||
option = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/lib/${config.services.prometheus2.stateDir}/data";
|
||||
defaultText = "/var/lib/\${config.services.prometheus2.stateDir}/data";
|
||||
description = ''
|
||||
Data directory of TSDB.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
reloader.config-file = mkParam types.str ''
|
||||
Config file watched by the reloader.
|
||||
'';
|
||||
|
||||
reloader.config-envsubst-file = mkParam types.str ''
|
||||
Output file for environment variable substituted config file.
|
||||
'';
|
||||
|
||||
reloader.rule-dirs = mkListParam "reloader.rule-dir" ''
|
||||
Rule directories for the reloader to refresh.
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
store = params.common cfg.store // params.objstore cfg.store // {
|
||||
|
||||
stateDir = mkStateDirParam "data-dir" "thanos-store" ''
|
||||
Data directory relative to <literal>/var/lib</literal>
|
||||
in which to cache remote blocks.
|
||||
'';
|
||||
|
||||
index-cache-size = mkParamDef types.str "250MB" ''
|
||||
Maximum size of items held in the index cache.
|
||||
'';
|
||||
|
||||
chunk-pool-size = mkParamDef types.str "2GB" ''
|
||||
Maximum size of concurrently allocatable bytes for chunks.
|
||||
'';
|
||||
|
||||
store.grpc.series-sample-limit = mkParamDef types.int 0 ''
|
||||
Maximum amount of samples returned via a single Series call.
|
||||
|
||||
<literal>0</literal> means no limit.
|
||||
|
||||
NOTE: for efficiency we take 120 as the number of samples in chunk (it
|
||||
cannot be bigger than that), so the actual number of samples might be
|
||||
lower, even though the maximum could be hit.
|
||||
'';
|
||||
|
||||
store.grpc.series-max-concurrency = mkParamDef types.int 20 ''
|
||||
Maximum number of concurrent Series calls.
|
||||
'';
|
||||
|
||||
sync-block-duration = mkParamDef types.str "3m" ''
|
||||
Repeat interval for syncing the blocks between local and remote view.
|
||||
'';
|
||||
|
||||
block-sync-concurrency = mkParamDef types.int 20 ''
|
||||
Number of goroutines to use when syncing blocks from object storage.
|
||||
'';
|
||||
};
|
||||
|
||||
query = params.common cfg.query // {
|
||||
|
||||
grpc-client-tls-secure = mkFlagParam ''
|
||||
Use TLS when talking to the gRPC server
|
||||
'';
|
||||
|
||||
grpc-client-tls-cert = mkParam types.str ''
|
||||
TLS Certificates to use to identify this client to the server
|
||||
'';
|
||||
|
||||
grpc-client-tls-key = mkParam types.str ''
|
||||
TLS Key for the client's certificate
|
||||
'';
|
||||
|
||||
grpc-client-tls-ca = mkParam types.str ''
|
||||
TLS CA Certificates to use to verify gRPC servers
|
||||
'';
|
||||
|
||||
grpc-client-server-name = mkParam types.str ''
|
||||
Server name to verify the hostname on the returned gRPC certificates.
|
||||
See <link xlink:href="https://tools.ietf.org/html/rfc4366#section-3.1"/>
|
||||
'';
|
||||
|
||||
web.route-prefix = mkParam types.str ''
|
||||
Prefix for API and UI endpoints.
|
||||
|
||||
This allows thanos UI to be served on a sub-path. This option is
|
||||
analogous to <option>web.route-prefix</option> of Promethus.
|
||||
'';
|
||||
|
||||
web.external-prefix = mkParam types.str ''
|
||||
Static prefix for all HTML links and redirect URLs in the UI query web
|
||||
interface.
|
||||
|
||||
Actual endpoints are still served on / or the
|
||||
<option>web.route-prefix</option>. This allows thanos UI to be served
|
||||
behind a reverse proxy that strips a URL sub-path.
|
||||
'';
|
||||
|
||||
web.prefix-header = mkParam types.str ''
|
||||
Name of HTTP request header used for dynamic prefixing of UI links and
|
||||
redirects.
|
||||
|
||||
This option is ignored if the option
|
||||
<literal>web.external-prefix</literal> is set.
|
||||
|
||||
Security risk: enable this option only if a reverse proxy in front of
|
||||
thanos is resetting the header.
|
||||
|
||||
The setting <literal>web.prefix-header="X-Forwarded-Prefix"</literal>
|
||||
can be useful, for example, if Thanos UI is served via Traefik reverse
|
||||
proxy with <literal>PathPrefixStrip</literal> option enabled, which
|
||||
sends the stripped prefix value in <literal>X-Forwarded-Prefix</literal>
|
||||
header. This allows thanos UI to be served on a sub-path.
|
||||
'';
|
||||
|
||||
query.timeout = mkParamDef types.str "2m" ''
|
||||
Maximum time to process query by query node.
|
||||
'';
|
||||
|
||||
query.max-concurrent = mkParamDef types.int 20 ''
|
||||
Maximum number of queries processed concurrently by query node.
|
||||
'';
|
||||
|
||||
query.replica-label = mkParam types.str ''
|
||||
Label to treat as a replica indicator along which data is
|
||||
deduplicated.
|
||||
|
||||
Still you will be able to query without deduplication using
|
||||
<literal>dedup=false</literal> parameter.
|
||||
'';
|
||||
|
||||
selector-labels = mkAttrsParam "selector-label" ''
|
||||
Query selector labels that will be exposed in info endpoint.
|
||||
'';
|
||||
|
||||
store.addresses = mkListParam "store" ''
|
||||
Addresses of statically configured store API servers.
|
||||
|
||||
The scheme may be prefixed with <literal>dns+</literal> or
|
||||
<literal>dnssrv+</literal> to detect store API servers through
|
||||
respective DNS lookups.
|
||||
'';
|
||||
|
||||
store.sd-files = mkListParam "store.sd-files" ''
|
||||
Path to files that contain addresses of store API servers. The path
|
||||
can be a glob pattern.
|
||||
'';
|
||||
|
||||
store.sd-interval = mkParamDef types.str "5m" ''
|
||||
Refresh interval to re-read file SD files. It is used as a resync fallback.
|
||||
'';
|
||||
|
||||
store.sd-dns-interval = mkParamDef types.str "30s" ''
|
||||
Interval between DNS resolutions.
|
||||
'';
|
||||
|
||||
store.unhealthy-timeout = mkParamDef types.str "5m" ''
|
||||
Timeout before an unhealthy store is cleaned from the store UI page.
|
||||
'';
|
||||
|
||||
query.auto-downsampling = mkFlagParam ''
|
||||
Enable automatic adjustment (step / 5) to what source of data should
|
||||
be used in store gateways if no
|
||||
<literal>max_source_resolution</literal> param is specified.
|
||||
'';
|
||||
|
||||
query.partial-response = mkFlagParam ''
|
||||
Enable partial response for queries if no
|
||||
<literal>partial_response</literal> param is specified.
|
||||
'';
|
||||
|
||||
query.default-evaluation-interval = mkParamDef types.str "1m" ''
|
||||
Set default evaluation interval for sub queries.
|
||||
'';
|
||||
|
||||
store.response-timeout = mkParamDef types.str "0ms" ''
|
||||
If a Store doesn't send any data in this specified duration then a
|
||||
Store will be ignored and partial data will be returned if it's
|
||||
enabled. <literal>0</literal> disables timeout.
|
||||
'';
|
||||
};
|
||||
|
||||
rule = params.common cfg.rule // params.objstore cfg.rule // {
|
||||
|
||||
labels = mkAttrsParam "label" ''
|
||||
Labels to be applied to all generated metrics.
|
||||
|
||||
Similar to external labels for Prometheus,
|
||||
used to identify ruler and its blocks as unique source.
|
||||
'';
|
||||
|
||||
stateDir = mkStateDirParam "data-dir" "thanos-rule" ''
|
||||
Data directory relative to <literal>/var/lib</literal>.
|
||||
'';
|
||||
|
||||
rule-files = mkListParam "rule-file" ''
|
||||
Rule files that should be used by rule manager. Can be in glob format.
|
||||
'';
|
||||
|
||||
eval-interval = mkParamDef types.str "30s" ''
|
||||
The default evaluation interval to use.
|
||||
'';
|
||||
|
||||
tsdb.block-duration = mkParamDef types.str "2h" ''
|
||||
Block duration for TSDB block.
|
||||
'';
|
||||
|
||||
tsdb.retention = mkParamDef types.str "48h" ''
|
||||
Block retention time on local disk.
|
||||
'';
|
||||
|
||||
alertmanagers.urls = mkListParam "alertmanagers.url" ''
|
||||
Alertmanager replica URLs to push firing alerts.
|
||||
|
||||
Ruler claims success if push to at least one alertmanager from
|
||||
discovered succeeds. The scheme may be prefixed with
|
||||
<literal>dns+</literal> or <literal>dnssrv+</literal> to detect
|
||||
Alertmanager IPs through respective DNS lookups. The port defaults to
|
||||
<literal>9093</literal> or the SRV record's value. The URL path is
|
||||
used as a prefix for the regular Alertmanager API path.
|
||||
'';
|
||||
|
||||
alertmanagers.send-timeout = mkParamDef types.str "10s" ''
|
||||
Timeout for sending alerts to alertmanager.
|
||||
'';
|
||||
|
||||
alert.query-url = mkParam types.str ''
|
||||
The external Thanos Query URL that would be set in all alerts 'Source' field.
|
||||
'';
|
||||
|
||||
alert.label-drop = mkListParam "alert.label-drop" ''
|
||||
Labels by name to drop before sending to alertmanager.
|
||||
|
||||
This allows alert to be deduplicated on replica label.
|
||||
|
||||
Similar Prometheus alert relabelling
|
||||
'';
|
||||
|
||||
web.route-prefix = mkParam types.str ''
|
||||
Prefix for API and UI endpoints.
|
||||
|
||||
This allows thanos UI to be served on a sub-path.
|
||||
|
||||
This option is analogous to <literal>--web.route-prefix</literal> of Promethus.
|
||||
'';
|
||||
|
||||
web.external-prefix = mkParam types.str ''
|
||||
Static prefix for all HTML links and redirect URLs in the UI query web
|
||||
interface.
|
||||
|
||||
Actual endpoints are still served on / or the
|
||||
<option>web.route-prefix</option>. This allows thanos UI to be served
|
||||
behind a reverse proxy that strips a URL sub-path.
|
||||
'';
|
||||
|
||||
web.prefix-header = mkParam types.str ''
|
||||
Name of HTTP request header used for dynamic prefixing of UI links and
|
||||
redirects.
|
||||
|
||||
This option is ignored if the option
|
||||
<option>web.external-prefix</option> is set.
|
||||
|
||||
Security risk: enable this option only if a reverse proxy in front of
|
||||
thanos is resetting the header.
|
||||
|
||||
The header <literal>X-Forwarded-Prefix</literal> can be useful, for
|
||||
example, if Thanos UI is served via Traefik reverse proxy with
|
||||
<literal>PathPrefixStrip</literal> option enabled, which sends the
|
||||
stripped prefix value in <literal>X-Forwarded-Prefix</literal>
|
||||
header. This allows thanos UI to be served on a sub-path.
|
||||
'';
|
||||
|
||||
query.addresses = mkListParam "query" ''
|
||||
Addresses of statically configured query API servers.
|
||||
|
||||
The scheme may be prefixed with <literal>dns+</literal> or
|
||||
<literal>dnssrv+</literal> to detect query API servers through
|
||||
respective DNS lookups.
|
||||
'';
|
||||
|
||||
query.sd-files = mkListParam "query.sd-files" ''
|
||||
Path to file that contain addresses of query peers.
|
||||
The path can be a glob pattern.
|
||||
'';
|
||||
|
||||
query.sd-interval = mkParamDef types.str "5m" ''
|
||||
Refresh interval to re-read file SD files. (used as a fallback)
|
||||
'';
|
||||
|
||||
query.sd-dns-interval = mkParamDef types.str "30s" ''
|
||||
Interval between DNS resolutions.
|
||||
'';
|
||||
};
|
||||
|
||||
compact = params.log // params.tracing cfg.compact // params.objstore cfg.compact // {
|
||||
|
||||
http-address = mkParamDef types.str "0.0.0.0:10902" ''
|
||||
Listen <literal>host:port</literal> for HTTP endpoints.
|
||||
'';
|
||||
|
||||
stateDir = mkStateDirParam "data-dir" "thanos-compact" ''
|
||||
Data directory relative to <literal>/var/lib</literal>
|
||||
in which to cache blocks and process compactions.
|
||||
'';
|
||||
|
||||
consistency-delay = mkParamDef types.str "30m" ''
|
||||
Minimum age of fresh (non-compacted) blocks before they are being
|
||||
processed. Malformed blocks older than the maximum of consistency-delay
|
||||
and 30m0s will be removed.
|
||||
'';
|
||||
|
||||
retention.resolution-raw = mkParamDef types.str "0d" ''
|
||||
How long to retain raw samples in bucket.
|
||||
|
||||
<literal>0d</literal> - disables this retention
|
||||
'';
|
||||
|
||||
retention.resolution-5m = mkParamDef types.str "0d" ''
|
||||
How long to retain samples of resolution 1 (5 minutes) in bucket.
|
||||
|
||||
<literal>0d</literal> - disables this retention
|
||||
'';
|
||||
|
||||
retention.resolution-1h = mkParamDef types.str "0d" ''
|
||||
How long to retain samples of resolution 2 (1 hour) in bucket.
|
||||
|
||||
<literal>0d</literal> - disables this retention
|
||||
'';
|
||||
|
||||
startAt = {
|
||||
toArgs = _opt: startAt: flagToArgs "wait" (startAt == null);
|
||||
option = nullOpt types.str ''
|
||||
When this option is set to a <literal>systemd.time</literal>
|
||||
specification the Thanos compactor will run at the specified period.
|
||||
|
||||
When this option is <literal>null</literal> the Thanos compactor service
|
||||
will run continuously. So it will not exit after all compactions have
|
||||
been processed but wait for new work.
|
||||
'';
|
||||
};
|
||||
|
||||
block-sync-concurrency = mkParamDef types.int 20 ''
|
||||
Number of goroutines to use when syncing block metadata from object storage.
|
||||
'';
|
||||
|
||||
compact.concurrency = mkParamDef types.int 1 ''
|
||||
Number of goroutines to use when compacting groups.
|
||||
'';
|
||||
};
|
||||
|
||||
downsample = params.log // params.tracing cfg.downsample // params.objstore cfg.downsample // {
|
||||
|
||||
stateDir = mkStateDirParam "data-dir" "thanos-downsample" ''
|
||||
Data directory relative to <literal>/var/lib</literal>
|
||||
in which to cache blocks and process downsamplings.
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
receive = params.common cfg.receive // params.objstore cfg.receive // {
|
||||
|
||||
remote-write.address = mkParamDef types.str "0.0.0.0:19291" ''
|
||||
Address to listen on for remote write requests.
|
||||
'';
|
||||
|
||||
stateDir = mkStateDirParam "tsdb.path" "thanos-receive" ''
|
||||
Data directory relative to <literal>/var/lib</literal> of TSDB.
|
||||
'';
|
||||
|
||||
labels = mkAttrsParam "labels" ''
|
||||
External labels to announce.
|
||||
|
||||
This flag will be removed in the future when handling multiple tsdb
|
||||
instances is added.
|
||||
'';
|
||||
|
||||
tsdb.retention = mkParamDef types.str "15d" ''
|
||||
How long to retain raw samples on local storage.
|
||||
|
||||
<literal>0d</literal> - disables this retention
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
assertRelativeStateDir = cmd: {
|
||||
assertions = [
|
||||
{
|
||||
assertion = !hasPrefix "/" cfg."${cmd}".stateDir;
|
||||
message =
|
||||
"The option services.thanos.${cmd}.stateDir should not be an absolute directory." +
|
||||
" It should be a directory relative to /var/lib.";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
in {
|
||||
|
||||
options.services.thanos = {
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.thanos;
|
||||
defaultText = "pkgs.thanos";
|
||||
description = ''
|
||||
The thanos package that should be used.
|
||||
'';
|
||||
};
|
||||
|
||||
sidecar = paramsToOptions params.sidecar // {
|
||||
enable = mkEnableOption
|
||||
"the Thanos sidecar for Prometheus server";
|
||||
arguments = mkArgumentsOption "sidecar";
|
||||
};
|
||||
|
||||
store = paramsToOptions params.store // {
|
||||
enable = mkEnableOption
|
||||
"the Thanos store node giving access to blocks in a bucket provider.";
|
||||
arguments = mkArgumentsOption "store";
|
||||
};
|
||||
|
||||
query = paramsToOptions params.query // {
|
||||
enable = mkEnableOption
|
||||
("the Thanos query node exposing PromQL enabled Query API " +
|
||||
"with data retrieved from multiple store nodes");
|
||||
arguments = mkArgumentsOption "query";
|
||||
};
|
||||
|
||||
rule = paramsToOptions params.rule // {
|
||||
enable = mkEnableOption
|
||||
("the Thanos ruler service which evaluates Prometheus rules against" +
|
||||
" given Query nodes, exposing Store API and storing old blocks in bucket");
|
||||
arguments = mkArgumentsOption "rule";
|
||||
};
|
||||
|
||||
compact = paramsToOptions params.compact // {
|
||||
enable = mkEnableOption
|
||||
"the Thanos compactor which continuously compacts blocks in an object store bucket";
|
||||
arguments = mkArgumentsOption "compact";
|
||||
};
|
||||
|
||||
downsample = paramsToOptions params.downsample // {
|
||||
enable = mkEnableOption
|
||||
"the Thanos downsampler which continuously downsamples blocks in an object store bucket";
|
||||
arguments = mkArgumentsOption "downsample";
|
||||
};
|
||||
|
||||
receive = paramsToOptions params.receive // {
|
||||
enable = mkEnableOption
|
||||
("the Thanos receiver which accept Prometheus remote write API requests " +
|
||||
"and write to local tsdb (EXPERIMENTAL, this may change drastically without notice)");
|
||||
arguments = mkArgumentsOption "receive";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkMerge [
|
||||
|
||||
(mkIf cfg.sidecar.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.services.prometheus2.enable;
|
||||
message =
|
||||
"Please enable services.prometheus2 when enabling services.thanos.sidecar.";
|
||||
}
|
||||
{
|
||||
assertion = !(config.services.prometheus2.globalConfig.external_labels == null ||
|
||||
config.services.prometheus2.globalConfig.external_labels == {});
|
||||
message =
|
||||
"services.thanos.sidecar requires uniquely identifying external labels " +
|
||||
"to be configured in the Prometheus server. " +
|
||||
"Please set services.prometheus2.globalConfig.external_labels.";
|
||||
}
|
||||
];
|
||||
systemd.services.thanos-sidecar = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" "prometheus2.service" ];
|
||||
serviceConfig = {
|
||||
User = "prometheus";
|
||||
Restart = "always";
|
||||
ExecStart = thanos "sidecar";
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.store.enable (mkMerge [
|
||||
(assertRelativeStateDir "store")
|
||||
{
|
||||
systemd.services.thanos-store = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
DynamicUser = true;
|
||||
StateDirectory = cfg.store.stateDir;
|
||||
Restart = "always";
|
||||
ExecStart = thanos "store";
|
||||
};
|
||||
};
|
||||
}
|
||||
]))
|
||||
|
||||
(mkIf cfg.query.enable {
|
||||
systemd.services.thanos-query = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
DynamicUser = true;
|
||||
Restart = "always";
|
||||
ExecStart = thanos "query";
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.rule.enable (mkMerge [
|
||||
(assertRelativeStateDir "rule")
|
||||
{
|
||||
systemd.services.thanos-rule = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
DynamicUser = true;
|
||||
StateDirectory = cfg.rule.stateDir;
|
||||
Restart = "always";
|
||||
ExecStart = thanos "rule";
|
||||
};
|
||||
};
|
||||
}
|
||||
]))
|
||||
|
||||
(mkIf cfg.compact.enable (mkMerge [
|
||||
(assertRelativeStateDir "compact")
|
||||
{
|
||||
systemd.services.thanos-compact =
|
||||
let wait = cfg.compact.startAt == null; in {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
Type = if wait then "simple" else "oneshot";
|
||||
Restart = if wait then "always" else "no";
|
||||
DynamicUser = true;
|
||||
StateDirectory = cfg.compact.stateDir;
|
||||
ExecStart = thanos "compact";
|
||||
};
|
||||
} // optionalAttrs (!wait) { inherit (cfg.compact) startAt; };
|
||||
}
|
||||
]))
|
||||
|
||||
(mkIf cfg.downsample.enable (mkMerge [
|
||||
(assertRelativeStateDir "downsample")
|
||||
{
|
||||
systemd.services.thanos-downsample = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
DynamicUser = true;
|
||||
StateDirectory = cfg.downsample.stateDir;
|
||||
Restart = "always";
|
||||
ExecStart = thanos "downsample";
|
||||
};
|
||||
};
|
||||
}
|
||||
]))
|
||||
|
||||
(mkIf cfg.receive.enable (mkMerge [
|
||||
(assertRelativeStateDir "receive")
|
||||
{
|
||||
systemd.services.thanos-receive = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
DynamicUser = true;
|
||||
StateDirectory = cfg.receive.stateDir;
|
||||
Restart = "always";
|
||||
ExecStart = thanos "receive";
|
||||
};
|
||||
};
|
||||
}
|
||||
]))
|
||||
|
||||
];
|
||||
}
|
||||
@@ -177,7 +177,7 @@ in {
|
||||
basePackages = mkOption {
|
||||
type = types.attrsOf types.package;
|
||||
default = { inherit (pkgs)
|
||||
networkmanager modemmanager wpa_supplicant
|
||||
networkmanager modemmanager wpa_supplicant crda
|
||||
networkmanager-openvpn networkmanager-vpnc
|
||||
networkmanager-openconnect networkmanager-fortisslvpn
|
||||
networkmanager-l2tp networkmanager-iodine; };
|
||||
|
||||
@@ -204,6 +204,7 @@ in {
|
||||
environment.systemPackages = [ pkgs.wpa_supplicant ];
|
||||
|
||||
services.dbus.packages = [ pkgs.wpa_supplicant ];
|
||||
services.udev.packages = [ pkgs.crda ];
|
||||
|
||||
# FIXME: start a separate wpa_supplicant instance per interface.
|
||||
systemd.services.wpa_supplicant = let
|
||||
|
||||
@@ -0,0 +1,473 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
|
||||
inherit (lib) mkDefault mkEnableOption mkForce mkIf mkMerge mkOption;
|
||||
inherit (lib) concatStringsSep literalExample mapAttrsToList optional optionals optionalString types;
|
||||
|
||||
cfg = config.services.mediawiki;
|
||||
fpm = config.services.phpfpm.pools.mediawiki;
|
||||
user = "mediawiki";
|
||||
group = config.services.httpd.group;
|
||||
cacheDir = "/var/cache/mediawiki";
|
||||
stateDir = "/var/lib/mediawiki";
|
||||
|
||||
pkg = pkgs.stdenv.mkDerivation rec {
|
||||
pname = "mediawiki-full";
|
||||
version = src.version;
|
||||
src = cfg.package;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r * $out/
|
||||
|
||||
rm -rf $out/share/mediawiki/skins/*
|
||||
rm -rf $out/share/mediawiki/extensions/*
|
||||
|
||||
${concatStringsSep "\n" (mapAttrsToList (k: v: ''
|
||||
ln -s ${v} $out/share/mediawiki/skins/${k}
|
||||
'') cfg.skins)}
|
||||
|
||||
${concatStringsSep "\n" (mapAttrsToList (k: v: ''
|
||||
ln -s ${v} $out/share/mediawiki/extensions/${k}
|
||||
'') cfg.extensions)}
|
||||
'';
|
||||
};
|
||||
|
||||
mediawikiScripts = pkgs.runCommand "mediawiki-scripts" {
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
preferLocalBuild = true;
|
||||
} ''
|
||||
mkdir -p $out/bin
|
||||
for i in changePassword.php createAndPromote.php userOptions.php edit.php nukePage.php update.php; do
|
||||
makeWrapper ${pkgs.php}/bin/php $out/bin/mediawiki-$(basename $i .php) \
|
||||
--set MEDIAWIKI_CONFIG ${mediawikiConfig} \
|
||||
--add-flags ${pkg}/share/mediawiki/maintenance/$i
|
||||
done
|
||||
'';
|
||||
|
||||
mediawikiConfig = pkgs.writeText "LocalSettings.php" ''
|
||||
<?php
|
||||
# Protect against web entry
|
||||
if ( !defined( 'MEDIAWIKI' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$wgSitename = "${cfg.name}";
|
||||
$wgMetaNamespace = false;
|
||||
|
||||
## The URL base path to the directory containing the wiki;
|
||||
## defaults for all runtime URL paths are based off of this.
|
||||
## For more information on customizing the URLs
|
||||
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
|
||||
## https://www.mediawiki.org/wiki/Manual:Short_URL
|
||||
$wgScriptPath = "";
|
||||
|
||||
## The protocol and server name to use in fully-qualified URLs
|
||||
$wgServer = "${if cfg.virtualHost.enableSSL then "https" else "http"}://${cfg.virtualHost.hostName}";
|
||||
|
||||
## The URL path to static resources (images, scripts, etc.)
|
||||
$wgResourceBasePath = $wgScriptPath;
|
||||
|
||||
## The URL path to the logo. Make sure you change this from the default,
|
||||
## or else you'll overwrite your logo when you upgrade!
|
||||
$wgLogo = "$wgResourceBasePath/resources/assets/wiki.png";
|
||||
|
||||
## UPO means: this is also a user preference option
|
||||
|
||||
$wgEnableEmail = true;
|
||||
$wgEnableUserEmail = true; # UPO
|
||||
|
||||
$wgEmergencyContact = "${if cfg.virtualHost.adminAddr != null then cfg.virtualHost.adminAddr else config.services.httpd.adminAddr}";
|
||||
$wgPasswordSender = $wgEmergencyContact;
|
||||
|
||||
$wgEnotifUserTalk = false; # UPO
|
||||
$wgEnotifWatchlist = false; # UPO
|
||||
$wgEmailAuthentication = true;
|
||||
|
||||
## Database settings
|
||||
$wgDBtype = "${cfg.database.type}";
|
||||
$wgDBserver = "${cfg.database.host}:${if cfg.database.socket != null then cfg.database.socket else toString cfg.database.port}";
|
||||
$wgDBname = "${cfg.database.name}";
|
||||
$wgDBuser = "${cfg.database.user}";
|
||||
${optionalString (cfg.database.passwordFile != null) "$wgDBpassword = file_get_contents(\"${cfg.database.passwordFile}\");"}
|
||||
|
||||
${optionalString (cfg.database.type == "mysql" && cfg.database.tablePrefix != null) ''
|
||||
# MySQL specific settings
|
||||
$wgDBprefix = "${cfg.database.tablePrefix}";
|
||||
''}
|
||||
|
||||
${optionalString (cfg.database.type == "mysql") ''
|
||||
# MySQL table options to use during installation or update
|
||||
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
|
||||
''}
|
||||
|
||||
## Shared memory settings
|
||||
$wgMainCacheType = CACHE_NONE;
|
||||
$wgMemCachedServers = [];
|
||||
|
||||
${optionalString (cfg.uploadsDir != null) ''
|
||||
$wgEnableUploads = true;
|
||||
$wgUploadDirectory = "${cfg.uploadsDir}";
|
||||
''}
|
||||
|
||||
$wgUseImageMagick = true;
|
||||
$wgImageMagickConvertCommand = "${pkgs.imagemagick}/bin/convert";
|
||||
|
||||
# InstantCommons allows wiki to use images from https://commons.wikimedia.org
|
||||
$wgUseInstantCommons = false;
|
||||
|
||||
# Periodically send a pingback to https://www.mediawiki.org/ with basic data
|
||||
# about this MediaWiki instance. The Wikimedia Foundation shares this data
|
||||
# with MediaWiki developers to help guide future development efforts.
|
||||
$wgPingback = true;
|
||||
|
||||
## If you use ImageMagick (or any other shell command) on a
|
||||
## Linux server, this will need to be set to the name of an
|
||||
## available UTF-8 locale
|
||||
$wgShellLocale = "C.UTF-8";
|
||||
|
||||
## Set $wgCacheDirectory to a writable directory on the web server
|
||||
## to make your wiki go slightly faster. The directory should not
|
||||
## be publically accessible from the web.
|
||||
$wgCacheDirectory = "${cacheDir}";
|
||||
|
||||
# Site language code, should be one of the list in ./languages/data/Names.php
|
||||
$wgLanguageCode = "en";
|
||||
|
||||
$wgSecretKey = file_get_contents("${stateDir}/secret.key");
|
||||
|
||||
# Changing this will log out all existing sessions.
|
||||
$wgAuthenticationTokenVersion = "";
|
||||
|
||||
## For attaching licensing metadata to pages, and displaying an
|
||||
## appropriate copyright notice / icon. GNU Free Documentation
|
||||
## License and Creative Commons licenses are supported so far.
|
||||
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
|
||||
$wgRightsUrl = "";
|
||||
$wgRightsText = "";
|
||||
$wgRightsIcon = "";
|
||||
|
||||
# Path to the GNU diff3 utility. Used for conflict resolution.
|
||||
$wgDiff = "${pkgs.diffutils}/bin/diff";
|
||||
$wgDiff3 = "${pkgs.diffutils}/bin/diff3";
|
||||
|
||||
# Enabled skins.
|
||||
${concatStringsSep "\n" (mapAttrsToList (k: v: "wfLoadSkin('${k}');") cfg.skins)}
|
||||
|
||||
# Enabled extensions.
|
||||
${concatStringsSep "\n" (mapAttrsToList (k: v: "wfLoadExtension('${k}');") cfg.extensions)}
|
||||
|
||||
|
||||
# End of automatically generated settings.
|
||||
# Add more configuration options below.
|
||||
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
|
||||
in
|
||||
{
|
||||
# interface
|
||||
options = {
|
||||
services.mediawiki = {
|
||||
|
||||
enable = mkEnableOption "MediaWiki";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.mediawiki;
|
||||
description = "Which MediaWiki package to use.";
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
default = "MediaWiki";
|
||||
example = "Foobar Wiki";
|
||||
description = "Name of the wiki.";
|
||||
};
|
||||
|
||||
uploadsDir = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = "${stateDir}/uploads";
|
||||
description = ''
|
||||
This directory is used for uploads of pictures. The directory passed here is automatically
|
||||
created and permissions adjusted as required.
|
||||
'';
|
||||
};
|
||||
|
||||
passwordFile = mkOption {
|
||||
type = types.path;
|
||||
description = "A file containing the initial password for the admin user.";
|
||||
example = "/run/keys/mediawiki-password";
|
||||
};
|
||||
|
||||
skins = mkOption {
|
||||
default = {};
|
||||
type = types.attrsOf types.path;
|
||||
description = ''
|
||||
List of paths whose content is copied to the 'skins'
|
||||
subdirectory of the MediaWiki installation.
|
||||
'';
|
||||
};
|
||||
|
||||
extensions = mkOption {
|
||||
default = {};
|
||||
type = types.attrsOf types.path;
|
||||
description = ''
|
||||
List of paths whose content is copied to the 'extensions'
|
||||
subdirectory of the MediaWiki installation.
|
||||
'';
|
||||
};
|
||||
|
||||
database = {
|
||||
type = mkOption {
|
||||
type = types.enum [ "mysql" "postgres" "sqlite" "mssql" "oracle" ];
|
||||
default = "mysql";
|
||||
description = "Database engine to use. MySQL/MariaDB is the database of choice by MediaWiki developers.";
|
||||
};
|
||||
|
||||
host = mkOption {
|
||||
type = types.str;
|
||||
default = "localhost";
|
||||
description = "Database host address.";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 3306;
|
||||
description = "Database host port.";
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = "mediawiki";
|
||||
description = "Database name.";
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "mediawiki";
|
||||
description = "Database user.";
|
||||
};
|
||||
|
||||
passwordFile = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
example = "/run/keys/mediawiki-dbpassword";
|
||||
description = ''
|
||||
A file containing the password corresponding to
|
||||
<option>database.user</option>.
|
||||
'';
|
||||
};
|
||||
|
||||
tablePrefix = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
If you only have access to a single database and wish to install more than
|
||||
one version of MediaWiki, or have other applications that also use the
|
||||
database, you can give the table names a unique prefix to stop any naming
|
||||
conflicts or confusion.
|
||||
See <link xlink:href='https://www.mediawiki.org/wiki/Manual:$wgDBprefix'/>.
|
||||
'';
|
||||
};
|
||||
|
||||
socket = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = if cfg.database.createLocally then "/run/mysqld/mysqld.sock" else null;
|
||||
defaultText = "/run/mysqld/mysqld.sock";
|
||||
description = "Path to the unix socket file to use for authentication.";
|
||||
};
|
||||
|
||||
createLocally = mkOption {
|
||||
type = types.bool;
|
||||
default = cfg.database.type == "mysql";
|
||||
defaultText = "true";
|
||||
description = ''
|
||||
Create the database and database user locally.
|
||||
This currently only applies if database type "mysql" is selected.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
virtualHost = mkOption {
|
||||
type = types.submodule ({
|
||||
options = import ../web-servers/apache-httpd/per-server-options.nix {
|
||||
inherit lib;
|
||||
forMainServer = false;
|
||||
};
|
||||
});
|
||||
example = literalExample ''
|
||||
{
|
||||
hostName = "mediawiki.example.org";
|
||||
enableSSL = true;
|
||||
adminAddr = "webmaster@example.org";
|
||||
sslServerCert = "/var/lib/acme/mediawiki.example.org/full.pem";
|
||||
sslServerKey = "/var/lib/acme/mediawiki.example.org/key.pem";
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Apache configuration can be done by adapting <option>services.httpd.virtualHosts</option>.
|
||||
See <xref linkend="opt-services.httpd.virtualHosts"/> for further information.
|
||||
'';
|
||||
};
|
||||
|
||||
poolConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = ''
|
||||
pm = dynamic
|
||||
pm.max_children = 32
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 2
|
||||
pm.max_spare_servers = 4
|
||||
pm.max_requests = 500
|
||||
'';
|
||||
description = ''
|
||||
Options for MediaWiki's PHP pool. See the documentation on <literal>php-fpm.conf</literal>
|
||||
for details on configuration directives.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
description = ''
|
||||
Any additional text to be appended to MediaWiki's
|
||||
LocalSettings.php configuration file. For configuration
|
||||
settings, see <link xlink:href="https://www.mediawiki.org/wiki/Manual:Configuration_settings"/>.
|
||||
'';
|
||||
default = "";
|
||||
example = ''
|
||||
$wgEnableEmail = false;
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
# implementation
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
assertions = [
|
||||
{ assertion = cfg.database.createLocally -> cfg.database.type == "mysql";
|
||||
message = "services.mediawiki.createLocally is currently only supported for database type 'mysql'";
|
||||
}
|
||||
{ assertion = cfg.database.createLocally -> cfg.database.user == user;
|
||||
message = "services.mediawiki.database.user must be set to ${user} if services.mediawiki.database.createLocally is set true";
|
||||
}
|
||||
{ assertion = cfg.database.createLocally -> cfg.database.socket != null;
|
||||
message = "services.mediawiki.database.socket must be set if services.mediawiki.database.createLocally is set to true";
|
||||
}
|
||||
{ assertion = cfg.database.createLocally -> cfg.database.passwordFile == null;
|
||||
message = "a password cannot be specified if services.mediawiki.database.createLocally is set to true";
|
||||
}
|
||||
];
|
||||
|
||||
services.mediawiki.skins = {
|
||||
MonoBook = "${cfg.package}/share/mediawiki/skins/MonoBook";
|
||||
Timeless = "${cfg.package}/share/mediawiki/skins/Timeless";
|
||||
Vector = "${cfg.package}/share/mediawiki/skins/Vector";
|
||||
};
|
||||
|
||||
services.mysql = mkIf cfg.database.createLocally {
|
||||
enable = true;
|
||||
package = mkDefault pkgs.mariadb;
|
||||
ensureDatabases = [ cfg.database.name ];
|
||||
ensureUsers = [
|
||||
{ name = cfg.database.user;
|
||||
ensurePermissions = { "${cfg.database.name}.*" = "ALL PRIVILEGES"; };
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
services.phpfpm.pools.mediawiki = {
|
||||
listen = "/run/phpfpm/mediawiki.sock";
|
||||
extraConfig = ''
|
||||
listen.owner = ${config.services.httpd.user}
|
||||
listen.group = ${config.services.httpd.group}
|
||||
user = ${user}
|
||||
group = ${group}
|
||||
|
||||
env[MEDIAWIKI_CONFIG] = ${mediawikiConfig}
|
||||
|
||||
${cfg.poolConfig}
|
||||
'';
|
||||
};
|
||||
|
||||
services.httpd = {
|
||||
enable = true;
|
||||
adminAddr = mkDefault cfg.virtualHost.adminAddr;
|
||||
extraModules = [ "proxy_fcgi" ];
|
||||
virtualHosts = [ (mkMerge [
|
||||
cfg.virtualHost {
|
||||
documentRoot = mkForce "${pkg}/share/mediawiki";
|
||||
extraConfig = ''
|
||||
<Directory "${pkg}/share/mediawiki">
|
||||
<FilesMatch "\.php$">
|
||||
<If "-f %{REQUEST_FILENAME}">
|
||||
SetHandler "proxy:unix:${fpm.listen}|fcgi://localhost/"
|
||||
</If>
|
||||
</FilesMatch>
|
||||
|
||||
Require all granted
|
||||
DirectoryIndex index.php
|
||||
AllowOverride All
|
||||
</Directory>
|
||||
'' + optionalString (cfg.uploadsDir != null) ''
|
||||
Alias "/images" "${cfg.uploadsDir}"
|
||||
<Directory "${cfg.uploadsDir}">
|
||||
Require all granted
|
||||
</Directory>
|
||||
'';
|
||||
}
|
||||
]) ];
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d '${stateDir}' 0750 ${user} ${group} - -"
|
||||
"d '${cacheDir}' 0750 ${user} ${group} - -"
|
||||
] ++ optionals (cfg.uploadsDir != null) [
|
||||
"d '${cfg.uploadsDir}' 0750 ${user} ${group} - -"
|
||||
"Z '${cfg.uploadsDir}' 0750 ${user} ${group} - -"
|
||||
];
|
||||
|
||||
systemd.services.mediawiki-init = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
before = [ "phpfpm-mediawiki.service" ];
|
||||
after = optional cfg.database.createLocally "mysql.service";
|
||||
script = ''
|
||||
if ! test -e "${stateDir}/secret.key"; then
|
||||
tr -dc A-Za-z0-9 </dev/urandom 2>/dev/null | head -c 64 > ${stateDir}/secret.key
|
||||
fi
|
||||
|
||||
echo "exit( wfGetDB( DB_MASTER )->tableExists( 'user' ) ? 1 : 0 );" | \
|
||||
${pkgs.php}/bin/php ${pkg}/share/mediawiki/maintenance/eval.php --conf ${mediawikiConfig} && \
|
||||
${pkgs.php}/bin/php ${pkg}/share/mediawiki/maintenance/install.php \
|
||||
--confpath /tmp \
|
||||
--scriptpath / \
|
||||
--dbserver ${cfg.database.host}${optionalString (cfg.database.socket != null) ":${cfg.database.socket}"} \
|
||||
--dbport ${toString cfg.database.port} \
|
||||
--dbname ${cfg.database.name} \
|
||||
${optionalString (cfg.database.tablePrefix != null) "--dbprefix ${cfg.database.tablePrefix}"} \
|
||||
--dbuser ${cfg.database.user} \
|
||||
${optionalString (cfg.database.passwordFile != null) "--dbpassfile ${cfg.database.passwordFile}"} \
|
||||
--passfile ${cfg.passwordFile} \
|
||||
${cfg.name} \
|
||||
admin
|
||||
|
||||
${pkgs.php}/bin/php ${pkg}/share/mediawiki/maintenance/update.php --conf ${mediawikiConfig} --quick
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = user;
|
||||
Group = group;
|
||||
PrivateTmp = true;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.httpd.after = optional (cfg.database.createLocally && cfg.database.type == "mysql") "mysql.service";
|
||||
|
||||
users.users.${user}.group = group;
|
||||
|
||||
environment.systemPackages = [ mediawikiScripts ];
|
||||
};
|
||||
}
|
||||
@@ -1,349 +0,0 @@
|
||||
{ config, lib, pkgs, serverInfo, php, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
httpd = serverInfo.serverConfig.package;
|
||||
|
||||
version24 = !versionOlder httpd.version "2.4";
|
||||
|
||||
allGranted = if version24 then ''
|
||||
Require all granted
|
||||
'' else ''
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
'';
|
||||
|
||||
mediawikiConfig = pkgs.writeText "LocalSettings.php"
|
||||
''
|
||||
<?php
|
||||
# Copied verbatim from the default (generated) LocalSettings.php.
|
||||
if( defined( 'MW_INSTALL_PATH' ) ) {
|
||||
$IP = MW_INSTALL_PATH;
|
||||
} else {
|
||||
$IP = dirname( __FILE__ );
|
||||
}
|
||||
|
||||
$path = array( $IP, "$IP/includes", "$IP/languages" );
|
||||
set_include_path( implode( PATH_SEPARATOR, $path ) . PATH_SEPARATOR . get_include_path() );
|
||||
|
||||
require_once( "$IP/includes/DefaultSettings.php" );
|
||||
|
||||
if ( $wgCommandLineMode ) {
|
||||
if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
|
||||
die( "This script must be run from the command line\n" );
|
||||
}
|
||||
}
|
||||
|
||||
$wgScriptPath = "${config.urlPrefix}";
|
||||
|
||||
# We probably need to set $wgSecretKey and $wgCacheEpoch.
|
||||
|
||||
# Paths to external programs.
|
||||
$wgDiff3 = "${pkgs.diffutils}/bin/diff3";
|
||||
$wgDiff = "${pkgs.diffutils}/bin/diff";
|
||||
$wgImageMagickConvertCommand = "${pkgs.imagemagick.out}/bin/convert";
|
||||
|
||||
#$wgDebugLogFile = "/tmp/mediawiki_debug_log.txt";
|
||||
|
||||
# Database configuration.
|
||||
$wgDBtype = "${config.dbType}";
|
||||
$wgDBserver = "${config.dbServer}";
|
||||
$wgDBuser = "${config.dbUser}";
|
||||
$wgDBpassword = "${config.dbPassword}";
|
||||
$wgDBname = "${config.dbName}";
|
||||
|
||||
# E-mail.
|
||||
$wgEmergencyContact = "${config.emergencyContact}";
|
||||
$wgPasswordSender = "${config.passwordSender}";
|
||||
|
||||
$wgSitename = "${config.siteName}";
|
||||
|
||||
${optionalString (config.logo != "") ''
|
||||
$wgLogo = "${config.logo}";
|
||||
''}
|
||||
|
||||
${optionalString (config.articleUrlPrefix != "") ''
|
||||
$wgArticlePath = "${config.articleUrlPrefix}/$1";
|
||||
''}
|
||||
|
||||
${optionalString config.enableUploads ''
|
||||
$wgEnableUploads = true;
|
||||
$wgUploadDirectory = "${config.uploadDir}";
|
||||
''}
|
||||
|
||||
${optionalString (config.defaultSkin != "") ''
|
||||
$wgDefaultSkin = "${config.defaultSkin}";
|
||||
''}
|
||||
|
||||
${config.extraConfig}
|
||||
?>
|
||||
'';
|
||||
|
||||
# Unpack Mediawiki and put the config file in its root directory.
|
||||
mediawikiRoot = pkgs.stdenv.mkDerivation rec {
|
||||
name= "mediawiki-1.31.1";
|
||||
|
||||
src = pkgs.fetchurl {
|
||||
url = "https://releases.wikimedia.org/mediawiki/1.31/${name}.tar.gz";
|
||||
sha256 = "13x48clij21cmysjkpnx68vggchrdasqp7b290j87xlfgjhdhnnf";
|
||||
};
|
||||
|
||||
skins = config.skins;
|
||||
extensions = config.extensions;
|
||||
|
||||
buildPhase =
|
||||
''
|
||||
for skin in $skins; do
|
||||
cp -prvd $skin/* skins/
|
||||
done
|
||||
for extension in $extensions; do
|
||||
cp -prvd $extension/* extensions/
|
||||
done
|
||||
''; # */
|
||||
|
||||
installPhase =
|
||||
''
|
||||
mkdir -p $out
|
||||
cp -r * $out
|
||||
cp ${mediawikiConfig} $out/LocalSettings.php
|
||||
sed -i \
|
||||
-e 's|/bin/bash|${pkgs.bash}/bin/bash|g' \
|
||||
-e 's|/usr/bin/timeout|${pkgs.coreutils}/bin/timeout|g' \
|
||||
$out/includes/shell/limit.sh \
|
||||
$out/includes/GlobalFunctions.php
|
||||
'';
|
||||
};
|
||||
|
||||
mediawikiScripts = pkgs.runCommand "mediawiki-${config.id}-scripts" {
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
preferLocalBuild = true;
|
||||
} ''
|
||||
mkdir -p $out/bin
|
||||
for i in changePassword.php createAndPromote.php userOptions.php edit.php nukePage.php update.php; do
|
||||
makeWrapper ${php}/bin/php $out/bin/mediawiki-${config.id}-$(basename $i .php) \
|
||||
--add-flags ${mediawikiRoot}/maintenance/$i
|
||||
done
|
||||
'';
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
extraConfig =
|
||||
''
|
||||
${optionalString config.enableUploads ''
|
||||
Alias ${config.urlPrefix}/images ${config.uploadDir}
|
||||
|
||||
<Directory ${config.uploadDir}>
|
||||
${allGranted}
|
||||
Options -Indexes
|
||||
</Directory>
|
||||
''}
|
||||
|
||||
${if config.urlPrefix != "" then "Alias ${config.urlPrefix} ${mediawikiRoot}" else ''
|
||||
RewriteEngine On
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
|
||||
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
|
||||
${concatMapStringsSep "\n" (u: "RewriteCond %{REQUEST_URI} !^${u.urlPath}") serverInfo.vhostConfig.servedDirs}
|
||||
${concatMapStringsSep "\n" (u: "RewriteCond %{REQUEST_URI} !^${u.urlPath}") serverInfo.vhostConfig.servedFiles}
|
||||
RewriteRule ${if config.enableUploads
|
||||
then "!^/images"
|
||||
else "^.*\$"
|
||||
} %{DOCUMENT_ROOT}/${if config.articleUrlPrefix == ""
|
||||
then ""
|
||||
else "${config.articleUrlPrefix}/"
|
||||
}index.php [L]
|
||||
''}
|
||||
|
||||
<Directory ${mediawikiRoot}>
|
||||
${allGranted}
|
||||
DirectoryIndex index.php
|
||||
</Directory>
|
||||
|
||||
${optionalString (config.articleUrlPrefix != "") ''
|
||||
Alias ${config.articleUrlPrefix} ${mediawikiRoot}/index.php
|
||||
''}
|
||||
'';
|
||||
|
||||
documentRoot = if config.urlPrefix == "" then mediawikiRoot else null;
|
||||
|
||||
enablePHP = true;
|
||||
|
||||
options = {
|
||||
|
||||
id = mkOption {
|
||||
default = "main";
|
||||
description = ''
|
||||
A unique identifier necessary to keep multiple MediaWiki server
|
||||
instances on the same machine apart. This is used to
|
||||
disambiguate the administrative scripts, which get names like
|
||||
mediawiki-$id-change-password.
|
||||
'';
|
||||
};
|
||||
|
||||
dbType = mkOption {
|
||||
default = "postgres";
|
||||
example = "mysql";
|
||||
description = "Database type.";
|
||||
};
|
||||
|
||||
dbName = mkOption {
|
||||
default = "mediawiki";
|
||||
description = "Name of the database that holds the MediaWiki data.";
|
||||
};
|
||||
|
||||
dbServer = mkOption {
|
||||
default = ""; # use a Unix domain socket
|
||||
example = "10.0.2.2";
|
||||
description = ''
|
||||
The location of the database server. Leave empty to use a
|
||||
database server running on the same machine through a Unix
|
||||
domain socket.
|
||||
'';
|
||||
};
|
||||
|
||||
dbUser = mkOption {
|
||||
default = "mediawiki";
|
||||
description = "The user name for accessing the database.";
|
||||
};
|
||||
|
||||
dbPassword = mkOption {
|
||||
default = "";
|
||||
example = "foobar";
|
||||
description = ''
|
||||
The password of the database user. Warning: this is stored in
|
||||
cleartext in the Nix store!
|
||||
'';
|
||||
};
|
||||
|
||||
emergencyContact = mkOption {
|
||||
default = serverInfo.serverConfig.adminAddr;
|
||||
example = "admin@example.com";
|
||||
description = ''
|
||||
Emergency contact e-mail address. Defaults to the Apache
|
||||
admin address.
|
||||
'';
|
||||
};
|
||||
|
||||
passwordSender = mkOption {
|
||||
default = serverInfo.serverConfig.adminAddr;
|
||||
example = "password@example.com";
|
||||
description = ''
|
||||
E-mail address from which password confirmations originate.
|
||||
Defaults to the Apache admin address.
|
||||
'';
|
||||
};
|
||||
|
||||
siteName = mkOption {
|
||||
default = "MediaWiki";
|
||||
example = "Foobar Wiki";
|
||||
description = "Name of the wiki";
|
||||
};
|
||||
|
||||
logo = mkOption {
|
||||
default = "";
|
||||
example = "/images/logo.png";
|
||||
description = "The URL of the site's logo (which should be a 135x135px image).";
|
||||
};
|
||||
|
||||
urlPrefix = mkOption {
|
||||
default = "/w";
|
||||
description = ''
|
||||
The URL prefix under which the Mediawiki service appears.
|
||||
'';
|
||||
};
|
||||
|
||||
articleUrlPrefix = mkOption {
|
||||
default = "/wiki";
|
||||
example = "";
|
||||
description = ''
|
||||
The URL prefix under which article pages appear,
|
||||
e.g. http://server/wiki/Page. Leave empty to use the main URL
|
||||
prefix, e.g. http://server/w/index.php?title=Page.
|
||||
'';
|
||||
};
|
||||
|
||||
enableUploads = mkOption {
|
||||
default = false;
|
||||
description = "Whether to enable file uploads.";
|
||||
};
|
||||
|
||||
uploadDir = mkOption {
|
||||
default = throw "You must specify `uploadDir'.";
|
||||
example = "/data/mediawiki-upload";
|
||||
description = "The directory that stores uploaded files.";
|
||||
};
|
||||
|
||||
defaultSkin = mkOption {
|
||||
default = "";
|
||||
example = "nostalgia";
|
||||
description = "Set this value to change the default skin used by MediaWiki.";
|
||||
};
|
||||
|
||||
skins = mkOption {
|
||||
default = [];
|
||||
type = types.listOf types.path;
|
||||
description =
|
||||
''
|
||||
List of paths whose content is copied to the ‘skins’
|
||||
subdirectory of the MediaWiki installation.
|
||||
'';
|
||||
};
|
||||
|
||||
extensions = mkOption {
|
||||
default = [];
|
||||
type = types.listOf types.path;
|
||||
description =
|
||||
''
|
||||
List of paths whose content is copied to the 'extensions'
|
||||
subdirectory of the MediaWiki installation.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
example =
|
||||
''
|
||||
$wgEnableEmail = false;
|
||||
'';
|
||||
description = ''
|
||||
Any additional text to be appended to MediaWiki's
|
||||
configuration file. This is a PHP script. For configuration
|
||||
settings, see <link xlink:href='https://www.mediawiki.org/wiki/Manual:Configuration_settings'/>.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
extraPath = [ mediawikiScripts ];
|
||||
|
||||
# !!! Need to specify that Apache has a dependency on PostgreSQL!
|
||||
|
||||
startupScript = pkgs.writeScript "mediawiki_startup.sh"
|
||||
# Initialise the database automagically if we're using a Postgres
|
||||
# server on localhost.
|
||||
(optionalString (config.dbType == "postgres" && config.dbServer == "") ''
|
||||
if ! ${pkgs.postgresql}/bin/psql -l | grep -q ' ${config.dbName} ' ; then
|
||||
${pkgs.postgresql}/bin/createuser --no-superuser --no-createdb --no-createrole "${config.dbUser}" || true
|
||||
${pkgs.postgresql}/bin/createdb "${config.dbName}" -O "${config.dbUser}"
|
||||
( echo 'CREATE LANGUAGE plpgsql;'
|
||||
cat ${mediawikiRoot}/maintenance/postgres/tables.sql
|
||||
echo 'CREATE TEXT SEARCH CONFIGURATION public.default ( COPY = pg_catalog.english );'
|
||||
echo COMMIT
|
||||
) | ${pkgs.postgresql}/bin/psql -U "${config.dbUser}" "${config.dbName}"
|
||||
fi
|
||||
${php}/bin/php ${mediawikiRoot}/maintenance/update.php
|
||||
'');
|
||||
|
||||
robotsEntries = optionalString (config.articleUrlPrefix != "")
|
||||
''
|
||||
User-agent: *
|
||||
Disallow: ${config.urlPrefix}/
|
||||
Disallow: ${config.articleUrlPrefix}/Special:Search
|
||||
Disallow: ${config.articleUrlPrefix}/Special:Random
|
||||
'';
|
||||
|
||||
}
|
||||
@@ -154,6 +154,7 @@ in {
|
||||
services.hardware.bolt.enable = mkDefault true;
|
||||
services.xserver.libinput.enable = mkDefault true; # for controlling touchpad settings via gnome control center
|
||||
systemd.packages = [ pkgs.gnome3.vino ];
|
||||
xdg.portal.enable = true;
|
||||
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
|
||||
|
||||
# If gnome3 is installed, build vim for gtk3 too.
|
||||
@@ -229,7 +230,7 @@ in {
|
||||
|
||||
# Use the correct gnome3 packageSet
|
||||
networking.networkmanager.basePackages =
|
||||
{ inherit (pkgs) networkmanager modemmanager wpa_supplicant;
|
||||
{ inherit (pkgs) networkmanager modemmanager wpa_supplicant crda;
|
||||
inherit (pkgs.gnome3) networkmanager-openvpn networkmanager-vpnc
|
||||
networkmanager-openconnect networkmanager-fortisslvpn
|
||||
networkmanager-iodine networkmanager-l2tp; };
|
||||
|
||||
@@ -147,7 +147,7 @@ in
|
||||
|
||||
networking.networkmanager.enable = mkDefault true;
|
||||
networking.networkmanager.basePackages =
|
||||
{ inherit (pkgs) networkmanager modemmanager wpa_supplicant;
|
||||
{ inherit (pkgs) networkmanager modemmanager wpa_supplicant crda;
|
||||
inherit (pkgs.gnome3) networkmanager-openvpn networkmanager-vpnc
|
||||
networkmanager-openconnect networkmanager-fortisslvpn
|
||||
networkmanager-iodine networkmanager-l2tp; };
|
||||
|
||||
@@ -170,7 +170,7 @@ in
|
||||
|
||||
xdg-user-dirs # Update user dirs as described in https://freedesktop.org/wiki/Software/xdg-user-dirs/
|
||||
]
|
||||
|
||||
|
||||
# Phonon audio backend
|
||||
++ lib.optional (cfg.phononBackend == "gstreamer") libsForQt5.phonon-backend-gstreamer
|
||||
++ lib.optional (cfg.phononBackend == "gstreamer" && cfg.enableQt4Support) pkgs.phonon-backend-gstreamer
|
||||
@@ -233,6 +233,7 @@ in
|
||||
security.pam.services.sddm.enableKwallet = true;
|
||||
security.pam.services.slim.enableKwallet = true;
|
||||
|
||||
xdg.portal.enable = true;
|
||||
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-kde ];
|
||||
|
||||
# Update the start menu for each user that is currently logged in
|
||||
|
||||
@@ -14,6 +14,9 @@ let
|
||||
# Alias so people can keep using "virtualbox" instead of "vboxvideo".
|
||||
virtualbox = { modules = [ xorg.xf86videovboxvideo ]; driverName = "vboxvideo"; };
|
||||
|
||||
# Alias so that "radeon" uses the xf86-video-ati driver.
|
||||
radeon = { modules = [ xorg.xf86videoati ]; driverName = "ati"; };
|
||||
|
||||
# modesetting does not have a xf86videomodesetting package as it is included in xorgserver
|
||||
modesetting = {};
|
||||
};
|
||||
@@ -241,7 +244,7 @@ in
|
||||
videoDrivers = mkOption {
|
||||
type = types.listOf types.str;
|
||||
# !!! We'd like "nv" here, but it segfaults the X server.
|
||||
default = [ "ati" "cirrus" "vesa" "vmware" "modesetting" ];
|
||||
default = [ "radeon" "cirrus" "vesa" "vmware" "modesetting" ];
|
||||
example = [
|
||||
"ati_unfree" "amdgpu" "amdgpu-pro"
|
||||
"nv" "nvidia" "nvidiaLegacy390" "nvidiaLegacy340" "nvidiaLegacy304"
|
||||
|
||||
@@ -18,6 +18,7 @@ in
|
||||
boot.initrd.extraUtilsCommands = mkIf inInitrd
|
||||
''
|
||||
copy_bin_and_libs ${pkgs.xfsprogs.bin}/bin/fsck.xfs
|
||||
copy_bin_and_libs ${pkgs.xfsprogs.bin}/bin/xfs_repair
|
||||
'';
|
||||
|
||||
# Trick just to set 'sh' after the extraUtils nuke-refs.
|
||||
|
||||
@@ -85,6 +85,7 @@ in
|
||||
flannel = handleTestOn ["x86_64-linux"] ./flannel.nix {};
|
||||
flatpak = handleTest ./flatpak.nix {};
|
||||
flatpak-builder = handleTest ./flatpak-builder.nix {};
|
||||
fluentd = handleTest ./fluentd.nix {};
|
||||
fsck = handleTest ./fsck.nix {};
|
||||
fwupd = handleTestOn ["x86_64-linux"] ./fwupd.nix {}; # libsmbios is unsupported on aarch64
|
||||
gdk-pixbuf = handleTest ./gdk-pixbuf.nix {};
|
||||
@@ -146,6 +147,7 @@ in
|
||||
mailcatcher = handleTest ./mailcatcher.nix {};
|
||||
mathics = handleTest ./mathics.nix {};
|
||||
matrix-synapse = handleTest ./matrix-synapse.nix {};
|
||||
mediawiki = handleTest ./mediawiki.nix {};
|
||||
memcached = handleTest ./memcached.nix {};
|
||||
mesos = handleTest ./mesos.nix {};
|
||||
miniflux = handleTest ./miniflux.nix {};
|
||||
|
||||
@@ -9,6 +9,7 @@ import ./make-test.nix ({ pkgs, ... }:
|
||||
|
||||
machine = { pkgs, ... }: {
|
||||
services.flatpak.enable = true;
|
||||
xdg.portal.enable = true;
|
||||
environment.systemPackages = with pkgs; [ gnome-desktop-testing flatpak-builder ] ++ flatpak-builder.installedTestsDependencies;
|
||||
virtualisation.diskSize = 2048;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import ./make-test.nix ({ pkgs, lib, ... }: {
|
||||
name = "fluentd";
|
||||
|
||||
machine = { pkgs, ... }: {
|
||||
services.fluentd = {
|
||||
enable = true;
|
||||
config = ''
|
||||
<source>
|
||||
@type http
|
||||
port 9880
|
||||
</source>
|
||||
|
||||
<match **>
|
||||
type copy
|
||||
<store>
|
||||
@type file
|
||||
format json
|
||||
path /tmp/fluentd
|
||||
symlink_path /tmp/current-log
|
||||
</store>
|
||||
<store>
|
||||
@type stdout
|
||||
</store>
|
||||
</match>
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
testScript = let
|
||||
testMessage = "an example log message";
|
||||
|
||||
payload = pkgs.writeText "test-message.json" (builtins.toJSON {
|
||||
inherit testMessage;
|
||||
});
|
||||
in ''
|
||||
$machine->start;
|
||||
$machine->waitForUnit('fluentd.service');
|
||||
$machine->waitForOpenPort(9880);
|
||||
|
||||
$machine->succeed("curl -fsSL -X POST -H 'Content-type: application/json' -d @${payload} http://localhost:9880/test.tag");
|
||||
|
||||
$machine->succeed("systemctl stop fluentd"); # blocking flush
|
||||
|
||||
$machine->succeed("grep '${testMessage}' /tmp/current-log");
|
||||
'';
|
||||
})
|
||||
@@ -0,0 +1,19 @@
|
||||
import ./make-test.nix ({ pkgs, lib, ... }: {
|
||||
name = "mediawiki";
|
||||
meta.maintainers = [ lib.maintainers.aanderse ];
|
||||
|
||||
machine =
|
||||
{ ... }:
|
||||
{ services.mediawiki.enable = true;
|
||||
services.mediawiki.virtualHost.hostName = "localhost";
|
||||
services.mediawiki.virtualHost.adminAddr = "root@example.com";
|
||||
services.mediawiki.passwordFile = pkgs.writeText "password" "correcthorsebatterystaple";
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
|
||||
$machine->waitForUnit('phpfpm-mediawiki.service');
|
||||
$machine->succeed('curl -L http://localhost/') =~ /MediaWiki has been installed/ or die;
|
||||
'';
|
||||
})
|
||||
+190
-18
@@ -1,9 +1,44 @@
|
||||
import ./make-test.nix {
|
||||
let
|
||||
grpcPort = 19090;
|
||||
queryPort = 9090;
|
||||
minioPort = 9000;
|
||||
pushgwPort = 9091;
|
||||
|
||||
s3 = {
|
||||
accessKey = "BKIKJAA5BMMU2RHO6IBB";
|
||||
secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12";
|
||||
};
|
||||
|
||||
objstore.config = {
|
||||
type = "S3";
|
||||
config = {
|
||||
bucket = "thanos-bucket";
|
||||
endpoint = "s3:${toString minioPort}";
|
||||
region = "us-east-1";
|
||||
access_key = s3.accessKey;
|
||||
secret_key = s3.secretKey;
|
||||
insecure = true;
|
||||
signature_version2 = false;
|
||||
encrypt_sse = false;
|
||||
put_user_metadata = {};
|
||||
http_config = {
|
||||
idle_conn_timeout = "0s";
|
||||
insecure_skip_verify = false;
|
||||
};
|
||||
trace = {
|
||||
enable = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
in import ./make-test.nix {
|
||||
name = "prometheus-2";
|
||||
|
||||
nodes = {
|
||||
one = { pkgs, ... }: {
|
||||
prometheus = { pkgs, ... }: {
|
||||
virtualisation.diskSize = 2 * 1024;
|
||||
environment.systemPackages = [ pkgs.jq ];
|
||||
networking.firewall.allowedTCPPorts = [ grpcPort ];
|
||||
services.prometheus2 = {
|
||||
enable = true;
|
||||
scrapeConfigs = [
|
||||
@@ -11,7 +46,7 @@ import ./make-test.nix {
|
||||
job_name = "prometheus";
|
||||
static_configs = [
|
||||
{
|
||||
targets = [ "127.0.0.1:9090" ];
|
||||
targets = [ "127.0.0.1:${toString queryPort}" ];
|
||||
labels = { instance = "localhost"; };
|
||||
}
|
||||
];
|
||||
@@ -21,7 +56,7 @@ import ./make-test.nix {
|
||||
scrape_interval = "1s";
|
||||
static_configs = [
|
||||
{
|
||||
targets = [ "127.0.0.1:9091" ];
|
||||
targets = [ "127.0.0.1:${toString pushgwPort}" ];
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -35,33 +70,170 @@ import ./make-test.nix {
|
||||
expr: count(up{job="prometheus"})
|
||||
''
|
||||
];
|
||||
globalConfig = {
|
||||
external_labels = {
|
||||
some_label = "required by thanos";
|
||||
};
|
||||
};
|
||||
extraFlags = [
|
||||
# Required by thanos
|
||||
"--storage.tsdb.min-block-duration=5s"
|
||||
"--storage.tsdb.max-block-duration=5s"
|
||||
];
|
||||
};
|
||||
services.prometheus.pushgateway = {
|
||||
enable = true;
|
||||
web.listen-address = ":${toString pushgwPort}";
|
||||
persistMetrics = true;
|
||||
persistence.interval = "1s";
|
||||
stateDir = "prometheus-pushgateway";
|
||||
};
|
||||
services.thanos = {
|
||||
sidecar = {
|
||||
enable = true;
|
||||
grpc-address = "0.0.0.0:${toString grpcPort}";
|
||||
inherit objstore;
|
||||
};
|
||||
|
||||
# TODO: Add some tests for these services:
|
||||
#rule = {
|
||||
# enable = true;
|
||||
# http-address = "0.0.0.0:19194";
|
||||
# grpc-address = "0.0.0.0:19193";
|
||||
# query.addresses = [
|
||||
# "localhost:19191"
|
||||
# ];
|
||||
# labels = {
|
||||
# just = "some";
|
||||
# nice = "labels";
|
||||
# };
|
||||
#};
|
||||
#
|
||||
#receive = {
|
||||
# http-address = "0.0.0.0:19195";
|
||||
# enable = true;
|
||||
# labels = {
|
||||
# just = "some";
|
||||
# nice = "labels";
|
||||
# };
|
||||
#};
|
||||
};
|
||||
};
|
||||
|
||||
query = { pkgs, ... }: {
|
||||
environment.systemPackages = [ pkgs.jq ];
|
||||
services.thanos.query = {
|
||||
enable = true;
|
||||
http-address = "0.0.0.0:${toString queryPort}";
|
||||
store.addresses = [
|
||||
"prometheus:${toString grpcPort}"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
store = { pkgs, ... }: {
|
||||
virtualisation.diskSize = 2 * 1024;
|
||||
environment.systemPackages = with pkgs; [ jq thanos ];
|
||||
services.thanos.store = {
|
||||
enable = true;
|
||||
http-address = "0.0.0.0:10902";
|
||||
grpc-address = "0.0.0.0:${toString grpcPort}";
|
||||
inherit objstore;
|
||||
sync-block-duration = "1s";
|
||||
};
|
||||
services.thanos.compact = {
|
||||
enable = true;
|
||||
http-address = "0.0.0.0:10903";
|
||||
inherit objstore;
|
||||
consistency-delay = "5s";
|
||||
};
|
||||
services.thanos.query = {
|
||||
enable = true;
|
||||
http-address = "0.0.0.0:${toString queryPort}";
|
||||
store.addresses = [
|
||||
"localhost:${toString grpcPort}"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
s3 = { pkgs, ... } : {
|
||||
# Minio requires at least 1GiB of free disk space to run.
|
||||
virtualisation.diskSize = 2 * 1024;
|
||||
networking.firewall.allowedTCPPorts = [ minioPort ];
|
||||
|
||||
services.minio = {
|
||||
enable = true;
|
||||
inherit (s3) accessKey secretKey;
|
||||
};
|
||||
|
||||
environment.systemPackages = [ pkgs.minio-client ];
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
$one->waitForUnit("prometheus2.service");
|
||||
$one->waitForOpenPort(9090);
|
||||
$one->succeed("curl -s http://127.0.0.1:9090/metrics");
|
||||
testScript = { nodes, ... } : ''
|
||||
# Before starting the other machines we first make sure that our S3 service is online
|
||||
# and has a bucket added for thanos:
|
||||
$s3->start;
|
||||
$s3->waitForUnit("minio.service");
|
||||
$s3->waitForOpenPort(${toString minioPort});
|
||||
$s3->succeed(
|
||||
"mc config host add minio " .
|
||||
"http://localhost:${toString minioPort} ${s3.accessKey} ${s3.secretKey} S3v4");
|
||||
$s3->succeed("mc mb minio/thanos-bucket");
|
||||
|
||||
# Let's test if pushing a metric to the pushgateway succeeds
|
||||
# and whether that metric gets ingested by prometheus.
|
||||
$one->waitForUnit("pushgateway.service");
|
||||
$one->succeed(
|
||||
# Now that s3 has started we can start the other machines:
|
||||
$prometheus->start;
|
||||
$query->start;
|
||||
$store->start;
|
||||
|
||||
# Check if prometheus responds to requests:
|
||||
$prometheus->waitForUnit("prometheus2.service");
|
||||
$prometheus->waitForOpenPort(${toString queryPort});
|
||||
$prometheus->succeed("curl -s http://127.0.0.1:${toString queryPort}/metrics");
|
||||
|
||||
# Let's test if pushing a metric to the pushgateway succeeds:
|
||||
$prometheus->waitForUnit("pushgateway.service");
|
||||
$prometheus->succeed(
|
||||
"echo 'some_metric 3.14' | " .
|
||||
"curl --data-binary \@- http://127.0.0.1:9091/metrics/job/some_job");
|
||||
$one->waitUntilSucceeds(
|
||||
"curl -sf 'http://127.0.0.1:9090/api/v1/query?query=some_metric' " .
|
||||
"| jq '.data.result[0].value[1]' | grep '\"3.14\"'");
|
||||
"curl --data-binary \@- http://127.0.0.1:${toString pushgwPort}/metrics/job/some_job");
|
||||
|
||||
# Now check whether that metric gets ingested by prometheus.
|
||||
# Since we'll check for the metric several times on different machines
|
||||
# we abstract the test using the following function:
|
||||
|
||||
# Function to check if the metric "some_metric" has been received and returns the correct value.
|
||||
local *Machine::waitForMetric = sub {
|
||||
my ($self) = @_;
|
||||
$self->waitUntilSucceeds(
|
||||
"curl -sf 'http://127.0.0.1:${toString queryPort}/api/v1/query?query=some_metric' " .
|
||||
"| jq '.data.result[0].value[1]' | grep '\"3.14\"'");
|
||||
};
|
||||
|
||||
$prometheus->waitForMetric;
|
||||
|
||||
# Let's test if the pushgateway persists metrics to the configured location.
|
||||
$one->waitUntilSucceeds("test -e /var/lib/prometheus-pushgateway/metrics");
|
||||
$prometheus->waitUntilSucceeds("test -e /var/lib/prometheus-pushgateway/metrics");
|
||||
|
||||
# Test thanos
|
||||
$prometheus->waitForUnit("thanos-sidecar.service");
|
||||
|
||||
# Test if the Thanos query service can correctly retrieve the metric that was send above.
|
||||
$query->waitForUnit("thanos-query.service");
|
||||
$query->waitForMetric;
|
||||
|
||||
# Test if the Thanos sidecar has correctly uploaded its TSDB to S3, if the
|
||||
# Thanos storage service has correctly downloaded it from S3 and if the Thanos
|
||||
# query service running on $store can correctly retrieve the metric:
|
||||
$store->waitForUnit("thanos-store.service");
|
||||
$store->waitForMetric;
|
||||
|
||||
$store->waitForUnit("thanos-compact.service");
|
||||
|
||||
# Test if the Thanos bucket command is able to retrieve blocks from the S3 bucket
|
||||
# and check if the blocks have the correct labels:
|
||||
$store->succeed(
|
||||
"thanos bucket ls" .
|
||||
" --objstore.config-file=${nodes.store.config.services.thanos.store.objstore.config-file}" .
|
||||
" --output=json | jq .thanos.labels.some_label | grep 'required by thanos'");
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user