mirror of
https://github.com/kittywitch/nixfiles.git
synced 2026-02-09 04:19:19 -08:00
style: alejandra, deadnix, statix
This commit is contained in:
parent
2e7ee0e4ca
commit
17c69c99de
78 changed files with 1051 additions and 878 deletions
|
|
@ -1,32 +1,38 @@
|
|||
{ pkgs, lib, config, ... }: let
|
||||
inherit (lib.modules) mkAfter mkDefault;
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkAfter mkDefault;
|
||||
in {
|
||||
sops.secrets.sshd-environment = {
|
||||
sopsFile = ./secrets.yaml;
|
||||
};
|
||||
security.pam.services.sshd.text = let
|
||||
sops.secrets.sshd-environment = {
|
||||
sopsFile = ./secrets.yaml;
|
||||
};
|
||||
security.pam.services.sshd.text = let
|
||||
notify = pkgs.writeShellScriptBin "notify" ''
|
||||
export $(cat ${config.sops.secrets.sshd-environment.path} | xargs)
|
||||
export $(cat ${config.sops.secrets.sshd-environment.path} | xargs)
|
||||
|
||||
if [ "$PAM_USER" = "deploy" ]; then
|
||||
if [ "$PAM_TYPE" = "open_session" ]; then
|
||||
message="''${PAM_RHOST} has opened an SSH session as part of doing a Nix deployment on ${config.networking.hostName}."
|
||||
elif [ "$PAM_TYPE" = "close_session" ]; then
|
||||
message="''${PAM_RHOST} has closed an SSH session as part of doing a Nix deployment on ${config.networking.hostName}."
|
||||
fi
|
||||
else
|
||||
if [ "$PAM_TYPE" = "open_session" ]; then
|
||||
message="''${PAM_RHOST} opened an SSH session with ${config.networking.hostName} as user ''${PAM_USER}."
|
||||
elif [ "$PAM_TYPE" = "close_session" ]; then
|
||||
message="''${PAM_RHOST} closed their SSH session with ${config.networking.hostName} for user ''${PAM_USER}."
|
||||
fi
|
||||
fi
|
||||
if [ "$PAM_USER" = "deploy" ]; then
|
||||
if [ "$PAM_TYPE" = "open_session" ]; then
|
||||
message="''${PAM_RHOST} has opened an SSH session as part of doing a Nix deployment on ${config.networking.hostName}."
|
||||
elif [ "$PAM_TYPE" = "close_session" ]; then
|
||||
message="''${PAM_RHOST} has closed an SSH session as part of doing a Nix deployment on ${config.networking.hostName}."
|
||||
fi
|
||||
else
|
||||
if [ "$PAM_TYPE" = "open_session" ]; then
|
||||
message="''${PAM_RHOST} opened an SSH session with ${config.networking.hostName} as user ''${PAM_USER}."
|
||||
elif [ "$PAM_TYPE" = "close_session" ]; then
|
||||
message="''${PAM_RHOST} closed their SSH session with ${config.networking.hostName} for user ''${PAM_USER}."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$message" ]; then
|
||||
${pkgs.curl}/bin/curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{\"content\": \"$message\"}" $DISCORD_WEBHOOK_LINK
|
||||
fi
|
||||
if [ -n "$message" ]; then
|
||||
${pkgs.curl}/bin/curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{\"content\": \"$message\"}" $DISCORD_WEBHOOK_LINK
|
||||
fi
|
||||
'';
|
||||
in mkDefault (mkAfter ''
|
||||
session required pam_exec.so seteuid ${notify}/bin/notify
|
||||
'');
|
||||
}
|
||||
in
|
||||
mkDefault (mkAfter ''
|
||||
session required pam_exec.so seteuid ${notify}/bin/notify
|
||||
'');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue