Add initial installer

This commit is contained in:
2022-02-17 15:47:24 +00:00
parent 788e476c01
commit c0414cd062
15 changed files with 169 additions and 87 deletions

View File

@@ -0,0 +1,27 @@
{ lib, pkgs, config, ... }:
let
inherit (lib) optionalAttrs filterAttrs genAttrs mkIf mkDefault;
inherit (lib.my) mkOpt' mkBoolOpt';
cfg = config.my.dynamic-motd;
scriptBin = pkgs.writeShellScript "dynamic-motd-script" cfg.script;
in
{
options.my.dynamic-motd = with lib.types; {
enable = mkBoolOpt' true "Whether to enable the dynamic message of the day PAM module.";
services = mkOpt' (listOf str) [ "login" "ssh" ] "PAM services to enable the dynamic message of the day module for.";
script = mkOpt' (nullOr lines) null "Script that generates message of the day.";
};
config = mkIf (cfg.enable && cfg.script != null) {
security.pam.services = genAttrs cfg.services (s: {
text = mkDefault
''
session optional ${pkgs.pam}/lib/security/pam_exec.so stdout quiet ${scriptBin}
'';
});
};
meta.buildDocsInSandbox = false;
}