1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-19 07:59:24 +03:00

Merge staging-next into staging

This commit is contained in:
github-actions[bot] 2022-11-19 18:01:53 +00:00 committed by GitHub
commit 14b4aa3fd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 412 additions and 146 deletions

View file

@ -35,7 +35,7 @@ let
'';
hashedPasswordDescription = ''
To generate a hashed password run `mkpasswd -m sha-512`.
To generate a hashed password run `mkpasswd`.
If set to an empty string (`""`), this user will
be able to log in without being asked for a password (but not via remote
@ -592,6 +592,26 @@ in {
'';
};
# Warn about user accounts with deprecated password hashing schemes
system.activationScripts.hashes = {
deps = [ "users" ];
text = ''
users=()
while IFS=: read -r user hash tail; do
if [[ "$hash" = "$"* && ! "$hash" =~ ^\$(y|gy|7|2b|2y|2a|6)\$ ]]; then
users+=("$user")
fi
done </etc/shadow
if (( "''${#users[@]}" )); then
echo "
WARNING: The following user accounts rely on password hashes that will
be removed in NixOS 23.05. They should be renewed as soon as possible."
printf ' - %s\n' "''${users[@]}"
fi
'';
};
# for backwards compatibility
system.activationScripts.groups = stringAfter [ "users" ] "";

View file

@ -718,6 +718,7 @@
./services/monitoring/teamviewer.nix
./services/monitoring/telegraf.nix
./services/monitoring/thanos.nix
./services/monitoring/tremor-rs.nix
./services/monitoring/tuptime.nix
./services/monitoring/unifi-poller.nix
./services/monitoring/ups.nix

View file

@ -0,0 +1,129 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.tremor-rs;
loggerSettingsFormat = pkgs.formats.yaml { };
loggerConfigFile = loggerSettingsFormat.generate "logger.yaml" cfg.loggerSettings;
in {
options = {
services.tremor-rs = {
enable = lib.mkEnableOption (lib.mdDoc "Tremor event- or stream-processing system");
troyFileList = mkOption {
type = types.listOf types.path;
default = [];
description = lib.mdDoc "List of troy files to load.";
};
tremorLibDir = mkOption {
type = types.path;
default = "";
description = lib.mdDoc "Directory where to find /lib containing tremor script files";
};
host = mkOption {
type = types.str;
default = "127.0.0.1";
description = lib.mdDoc "The host tremor should be listening on";
};
port = mkOption {
type = types.port;
default = 9898;
description = lib.mdDoc "the port tremor should be listening on";
};
loggerSettings = mkOption {
description = lib.mdDoc "Tremor logger configuration";
default = {};
type = loggerSettingsFormat.type;
example = {
refresh_rate = "30 seconds";
appenders.stdout.kind = "console";
root = {
level = "warn";
appenders = [ "stdout" ];
};
loggers = {
tremor_runtime = {
level = "debug";
appenders = [ "stdout" ];
additive = false;
};
tremor = {
level = "debug";
appenders = [ "stdout" ];
additive = false;
};
};
};
defaultText = literalExpression ''
{
refresh_rate = "30 seconds";
appenders.stdout.kind = "console";
root = {
level = "warn";
appenders = [ "stdout" ];
};
loggers = {
tremor_runtime = {
level = "debug";
appenders = [ "stdout" ];
additive = false;
};
tremor = {
level = "debug";
appenders = [ "stdout" ];
additive = false;
};
};
}
'';
};
};
};
config = mkIf (cfg.enable) {
environment.systemPackages = [ pkgs.tremor-rs ] ;
systemd.services.tremor-rs = {
description = "Tremor event- or stream-processing system";
wantedBy = [ "multi-user.target" ];
requires = [ "network-online.target" ];
after = [ "network-online.target" ];
environment.TREMOR_PATH = "${pkgs.tremor-rs}/lib:${cfg.tremorLibDir}";
serviceConfig = {
ExecStart = "${pkgs.tremor-rs}/bin/tremor --logger-config ${loggerConfigFile} server run ${concatStringsSep " " cfg.troyFileList} --api-host ${cfg.host}:${toString cfg.port}";
DynamicUser = true;
Restart = "always";
NoNewPrivileges = true;
PrivateTmp = true;
ProtectHome = true;
ProtectClock = true;
ProtectProc = "noaccess";
ProcSubset = "pid";
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectControlGroups = true;
ProtectHostname = true;
RestrictSUIDSGID = true;
RestrictRealtime = true;
RestrictNamespaces = true;
LockPersonality = true;
RemoveIPC = true;
SystemCallFilter = [ "@system-service" "~@privileged" ];
};
};
};
}

View file

@ -482,6 +482,10 @@ in
assertion = (cfg.database.useSSL && cfg.database.type == "postgresql") -> (cfg.database.caCert != null);
message = "A CA certificate must be specified (in 'services.keycloak.database.caCert') when PostgreSQL is used with SSL";
}
{
assertion = createLocalPostgreSQL -> config.services.postgresql.settings.standard_conforming_strings or true;
message = "Setting up a local PostgreSQL db for Keycloak requires `standard_conforming_strings` turned on to work reliably";
}
];
environment.systemPackages = [ keycloakBuild ];
@ -544,7 +548,13 @@ in
create_role="$(mktemp)"
trap 'rm -f "$create_role"' EXIT
# Read the password from the credentials directory and
# escape any single quotes by adding additional single
# quotes after them, following the rules laid out here:
# https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS
db_password="$(<"$CREDENTIALS_DIRECTORY/db_password")"
db_password="''${db_password//\'/\'\'}"
echo "CREATE ROLE keycloak WITH LOGIN PASSWORD '$db_password' CREATEDB" > "$create_role"
psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='keycloak'" | grep -q 1 || psql -tA --file="$create_role"
psql -tAc "SELECT 1 FROM pg_database WHERE datname = 'keycloak'" | grep -q 1 || psql -tAc 'CREATE DATABASE "keycloak" OWNER "keycloak"'
@ -566,8 +576,16 @@ in
script = ''
set -o errexit -o pipefail -o nounset -o errtrace
shopt -s inherit_errexit
# Read the password from the credentials directory and
# escape any single quotes by adding additional single
# quotes after them, following the rules laid out here:
# https://dev.mysql.com/doc/refman/8.0/en/string-literals.html
db_password="$(<"$CREDENTIALS_DIRECTORY/db_password")"
( echo "CREATE USER IF NOT EXISTS 'keycloak'@'localhost' IDENTIFIED BY '$db_password';"
db_password="''${db_password//\'/\'\'}"
( echo "SET sql_mode = 'NO_BACKSLASH_ESCAPES';"
echo "CREATE USER IF NOT EXISTS 'keycloak'@'localhost' IDENTIFIED BY '$db_password';"
echo "CREATE DATABASE IF NOT EXISTS keycloak CHARACTER SET utf8 COLLATE utf8_unicode_ci;"
echo "GRANT ALL PRIVILEGES ON keycloak.* TO 'keycloak'@'localhost';"
) | mysql -N
@ -632,12 +650,17 @@ in
${secretReplacements}
# Escape any backslashes in the db parameters, since
# they're otherwise unexpectedly read as escape
# sequences.
sed -i '/db-/ s|\\|\\\\|g' /run/keycloak/conf/keycloak.conf
'' + optionalString (cfg.sslCertificate != null && cfg.sslCertificateKey != null) ''
mkdir -p /run/keycloak/ssl
cp $CREDENTIALS_DIRECTORY/ssl_{cert,key} /run/keycloak/ssl/
'' + ''
export KEYCLOAK_ADMIN=admin
export KEYCLOAK_ADMIN_PASSWORD=${cfg.initialAdminPassword}
export KEYCLOAK_ADMIN_PASSWORD=${escapeShellArg cfg.initialAdminPassword}
kc.sh start --optimized
'';
};

View file

@ -342,6 +342,14 @@ checkFS() {
return 0
}
escapeFstab() {
local original="$1"
# Replace space
local escaped="${original// /\\040}"
# Replace tab
echo "${escaped//$'\t'/\\011}"
}
# Function for mounting a file system.
mountFS() {
@ -569,7 +577,7 @@ while read -u 3 mountPoint; do
continue
fi
mountFS "$device" "$mountPoint" "$options" "$fsType"
mountFS "$device" "$(escapeFstab "$mountPoint")" "$(escapeFstab "$options")" "$fsType"
done
exec 3>&-

View file

@ -167,7 +167,7 @@ let
else throw "No device specified for mount point ${fs.mountPoint}.")
+ " " + escape (rootPrefix + fs.mountPoint)
+ " " + fs.fsType
+ " " + builtins.concatStringsSep "," (fs.options ++ (extraOpts fs))
+ " " + escape (builtins.concatStringsSep "," (fs.options ++ (extraOpts fs)))
+ " " + (optionalString (!excludeChecks)
("0 " + (if skipCheck fs then "0" else if fs.mountPoint == "/" then "1" else "2")))
+ "\n"