grimm-nixos-laptop/common/tooling/security.nix

78 lines
1.8 KiB
Nix
Raw Normal View History

2024-05-07 23:31:41 +02:00
{
pkgs,
config,
lib,
...
}:
2024-04-13 19:16:33 +02:00
let
2024-05-11 22:55:59 +02:00
inherit (config.grimmShared) enable tooling graphical;
inherit (lib)
optional
optionals
filterAttrs
mkForce
mkIf
attrNames
mkEnableOption
;
2024-04-13 19:16:33 +02:00
in
{
2024-05-11 22:55:59 +02:00
config = mkIf enable {
security.polkit.enable = true;
security.rtkit.enable = true;
2024-04-13 19:16:33 +02:00
2024-05-25 23:14:08 +02:00
security.pam.yubico = {
2024-06-13 22:56:30 +02:00
enable = true;
id = [ "26681512" ];
# debug = true;
2024-05-25 23:14:08 +02:00
mode = "challenge-response";
2024-09-21 09:43:57 +02:00
control = lib.mkDefault "sufficient";
2024-05-25 23:14:08 +02:00
};
2024-09-21 09:43:57 +02:00
# security.doas.enable = true;
security.sudo.enable = true;
2024-05-11 22:55:59 +02:00
security.doas.extraRules = [
{
users = attrNames (filterAttrs (n: v: v.isNormalUser) config.users.users);
keepEnv = true;
persist = true;
}
];
2024-04-13 19:16:33 +02:00
2024-05-11 22:55:59 +02:00
environment.systemPackages =
(with pkgs; [
mkpasswd
gnupg
libsecret
vulnix
2024-10-22 22:05:22 +02:00
# agenix
2024-06-13 22:56:30 +02:00
yubikey-manager
yubico-pam
yubikey-personalization
2024-05-11 22:55:59 +02:00
])
2024-09-21 09:43:57 +02:00
++ (optionals (tooling.enable && tooling.pass) [
2024-05-11 22:55:59 +02:00
pkgs.pass
(pkgs.writeShellScriptBin "passw" "pass $@")
2024-09-21 09:43:57 +02:00
])
++ (optional config.security.doas.enable pkgs.sudo-doas-shim)
++ (optional graphical pkgs.lxqt.lxqt-policykit);
2024-04-13 19:16:33 +02:00
2024-05-11 22:55:59 +02:00
services.passSecretService.enable = mkIf (tooling.enable && tooling.pass) true;
2024-07-02 20:04:55 +02:00
services.openssh.settings.LoginGraceTime = 0;
2024-05-11 22:55:59 +02:00
programs.gnupg.agent = {
settings = {
# default-cache-ttl = 6000;
2024-04-13 19:16:33 +02:00
};
2024-05-11 22:55:59 +02:00
pinentryPackage = mkForce (if graphical then pkgs.pinentry-qt else pkgs.pinentry-tty);
enable = true;
2024-06-13 22:56:30 +02:00
enableSSHSupport = true;
2024-04-13 19:16:33 +02:00
};
2024-09-21 09:43:57 +02:00
grimmShared.firefox.plugins = mkIf (tooling.enable && tooling.pass) { "passff@invicem.pro" = "passff"; };
2024-05-11 22:55:59 +02:00
};
2024-05-11 22:55:59 +02:00
options.grimmShared.tooling.pass = mkEnableOption "Enables password-store, gnupg and such secret handling";
2024-04-13 19:16:33 +02:00
}