mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-03 21:40:12 +00:00
nixos/dendrite: add an option loadCredential
systemd-247 provides a mechanism called LoadCredential for secrets and
it is better than environment file. See the section of Environment=
in the manual of systemd.exec for more information.
Some options in config.yaml need values to be strings, which currently
can be used with environmentFile but not loadCredential. But it's
possible to use loadCredential for those options, e.g. we can
substitute their values in ExecStart, but not in ExecStartPre due to
[1].
[1]: https://github.com/systemd/systemd/issues/19604
(cherry picked from commit 37792e5766)
This commit is contained in:
@@ -74,6 +74,18 @@ in
|
||||
<literal>dendrite</literal> is running.
|
||||
'';
|
||||
};
|
||||
loadCredential = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
example = [ "private_key:/path/to/my_private_key" ];
|
||||
description = ''
|
||||
This can be used to pass secrets to the systemd service without adding them to
|
||||
the nix store.
|
||||
To use the example setting, see the example of
|
||||
<option>services.dendrite.settings.global.private_key</option>.
|
||||
See the LoadCredential section of systemd.exec manual for more information.
|
||||
'';
|
||||
};
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
freeformType = settingsFormat.type;
|
||||
@@ -88,8 +100,10 @@ in
|
||||
'';
|
||||
};
|
||||
private_key = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
example = "${workingDir}/matrix_key.pem";
|
||||
type = lib.types.either
|
||||
lib.types.path
|
||||
(lib.types.strMatching "^\\$CREDENTIALS_DIRECTORY/.+");
|
||||
example = "$CREDENTIALS_DIRECTORY/private_key";
|
||||
description = ''
|
||||
The path to the signing private key file, used to sign
|
||||
requests and events.
|
||||
@@ -256,6 +270,7 @@ in
|
||||
RuntimeDirectoryMode = "0700";
|
||||
LimitNOFILE = 65535;
|
||||
EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile;
|
||||
LoadCredential = cfg.loadCredential;
|
||||
ExecStartPre = ''
|
||||
${pkgs.envsubst}/bin/envsubst \
|
||||
-i ${configurationYaml} \
|
||||
|
||||
@@ -17,10 +17,11 @@ import ./make-test-python.nix (
|
||||
homeserver = { pkgs, ... }: {
|
||||
services.dendrite = {
|
||||
enable = true;
|
||||
loadCredential = [ "test_private_key:${private_key}" ];
|
||||
openRegistration = true;
|
||||
settings = {
|
||||
global.server_name = "test-dendrite-server.com";
|
||||
global.private_key = private_key;
|
||||
global.private_key = "$CREDENTIALS_DIRECTORY/test_private_key";
|
||||
client_api.registration_disabled = false;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user