nix: modules: knot: add options for configuring motd #383

merged
opened by ptr.pet targeting master from ptr.pet/core: master
Changed files
+33 -1
nix
modules
+32 -1
nix/modules/knot.nix
···
};
};
+
motd = mkOption {
+
type = types.nullOr types.str;
+
default = null;
+
description = ''
+
Message of the day
+
+
The contents are shown as-is; eg. you will want to add a newline if
+
setting a non-empty message since the knot won't do this for you.
+
'';
+
};
+
+
motdFile = mkOption {
+
type = types.nullOr types.path;
+
default = null;
+
description = ''
+
File containing message of the day
+
+
The contents are shown as-is; eg. you will want to add a newline if
+
setting a non-empty message since the knot won't do this for you.
+
'';
+
};
+
server = {
listenAddr = mkOption {
type = types.str;
···
cfg.package
];
-
system.activationScripts.gitConfig = ''
+
system.activationScripts.gitConfig = let
+
setMotd =
+
if cfg.motdFile != null && cfg.motd != null then
+
throw "motdFile and motd cannot be both set"
+
else ''
+
${if cfg.motdFile != null then "cat ${cfg.motdFile} > ${cfg.stateDir}/motd" else ""}
+
${if cfg.motd != null then ''printf "${cfg.motd}" > ${cfg.stateDir}/motd'' else ""}
+
'';
+
in ''
mkdir -p "${cfg.repo.scanPath}"
chown -R ${cfg.gitUser}:${cfg.gitUser} "${cfg.repo.scanPath}"
···
[receive]
advertisePushOptions = true
EOF
+
${setMotd}
chown -R ${cfg.gitUser}:${cfg.gitUser} "${cfg.stateDir}"
'';
+1
nix/vm.nix
···
];
services.tangled-knot = {
enable = true;
+
motd = "Welcome to the development knot!\n";
server = {
secretFile = "/var/lib/knot/secret";
hostname = "localhost:6000";