add gpg agent forwarding

This commit is contained in:
Gabriel Fontes
2022-07-06 00:43:10 -03:00
parent 46d3b0f65e
commit ff581b6818
3 changed files with 20 additions and 9 deletions
+11 -6
View File
@@ -1,12 +1,17 @@
{ hostnames, ... }:
{
programs.ssh = {
programs.ssh = {
enable = true;
matchBlocks = {
"gitlab.com" = {
addressFamily = "inet";
};
"*.local" = {
addressFamily = "inet";
"gitlab.com".addressFamily = "inet";
# Forward gpg-agent
home = {
host = "${builtins.concatStringsSep " " hostnames}";
forwardAgent = true;
remoteForwards = [{
bind.address = "/run/user/1000/gnupg/S.gpg-agent";
host.address = "/run/user/1000/gnupg/S.gpg-agent.extra";
}];
};
};
};
+4
View File
@@ -8,6 +8,10 @@ in
# Harden
passwordAuthentication = false;
permitRootLogin = "no";
# Automatically remove stale sockets
extraConfig = ''
StreamLocalBindUnlink yes
'';
};
services.openssh.hostKeys = [
+5 -3
View File
@@ -2,7 +2,7 @@
let
inherit (builtins) mapAttrs attrValues;
inherit (inputs) self home-manager nixpkgs deploy-rs;
inherit (nixpkgs.lib) nixosSystem hasSuffix removeSuffix filterAttrs mapAttrs';
inherit (nixpkgs.lib) nixosSystem hasSuffix removeSuffix filterAttrs mapAttrs' attrNames concatStrings;
inherit (home-manager.lib) homeManagerConfiguration;
# Given hostname, get system kind
getSystemKind = hostname: self.outputs.nixosConfigurations.${hostname}.pkgs.system;
@@ -11,6 +11,8 @@ let
let suffix = "@${hostname}";
in mapAttrs' (name: value: { name = removeSuffix suffix name; inherit value; })
(filterAttrs (name: _: hasSuffix suffix name) self.outputs.homeConfigurations);
# List of all hostnames
hostnames = attrNames self.outputs.nixosConfigurations;
mylib = {
importAttrset = path: mapAttrs (_: import) (import path);
@@ -25,7 +27,7 @@ let
inherit system;
pkgs = packages.${system};
specialArgs = {
inherit mylib inputs system hostname persistence;
inherit mylib inputs system hostname hostnames persistence;
homeConfigurations = getHomes hostname;
};
modules = attrValues (import ../modules/nixos) ++ [
@@ -47,7 +49,7 @@ let
homeManagerConfiguration {
pkgs = packages.${system};
extraSpecialArgs = {
inherit mylib inputs system hostname username persistence colorscheme wallpaper features desktop;
inherit mylib inputs system hostname hostnames username persistence colorscheme wallpaper features desktop;
};
modules = attrValues (import ../modules/home-manager) ++ [
../home/${username}