From 14cdb431a96bc48e5d981cd54bab64a881e1e795 Mon Sep 17 00:00:00 2001 From: Melody Renata Date: Tue, 13 Feb 2024 07:47:32 -0500 Subject: [PATCH 1/4] Nixify .ssh/config using home-manager This commit nixify's the .ssh/config using home-manager resolves #36 --- home/default.nix | 1 + home/ssh.nix | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 home/ssh.nix diff --git a/home/default.nix b/home/default.nix index b27b044..2316dcf 100644 --- a/home/default.nix +++ b/home/default.nix @@ -10,6 +10,7 @@ ./tmux.nix ./neovim.nix ./helix.nix + ./ssh.nix ./starship.nix ./terminal.nix ./git.nix diff --git a/home/ssh.nix b/home/ssh.nix new file mode 100644 index 0000000..991e693 --- /dev/null +++ b/home/ssh.nix @@ -0,0 +1,40 @@ +{ config +, pkgs +, lib +, ... +}: +with lib; +let + inherit (pkgs) stdenv; +in +{ + programs.ssh = { + enable = true; + matchBlocks = { + "*".extraOptions = mkMerge [ + (mkIf (!stdenv.isDarwin) { + identityAgent = "${config.home.homeDirectory}/.1password/agent.sock"; + }) + (mkIf (stdenv.isDarwin) { + identityAgent = "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"; + }) + ]; + actual = { + hostname = "167.205.125.179"; + forwardAgent = true; + }; + biryani = { + hostname = "100.97.32.60"; + user = "admin"; + forwardAgent = true; + }; + # To clone Juspay repos. + # https://developer.1password.com/docs/ssh/agent/advanced/#match-key-with-host + "bitbucket.org" = { + identitiesOnly = true; + identityFile = "${config.home.homeDirectory}/.ssh/juspay.pub"; + }; + }; + }; +} + From 80ba63e375511695c10a7da2ce476084c453968d Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 13 Feb 2024 08:39:30 -0500 Subject: [PATCH 2/4] Refactor --- home/ssh.nix | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/home/ssh.nix b/home/ssh.nix index 991e693..0df7788 100644 --- a/home/ssh.nix +++ b/home/ssh.nix @@ -1,24 +1,19 @@ -{ config -, pkgs -, lib -, ... -}: -with lib; +{ config, pkgs, ... }: let inherit (pkgs) stdenv; + _1passwordAgentSock = + if stdenv.isDarwin then + "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" + else + "${config.home.homeDirectory}/.1password/agent.sock"; in { programs.ssh = { enable = true; matchBlocks = { - "*".extraOptions = mkMerge [ - (mkIf (!stdenv.isDarwin) { - identityAgent = "${config.home.homeDirectory}/.1password/agent.sock"; - }) - (mkIf (stdenv.isDarwin) { - identityAgent = "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"; - }) - ]; + "*".extraOptions = { + identityAgent = _1passwordAgentSock; + }; actual = { hostname = "167.205.125.179"; forwardAgent = true; From e8fb8a6ddc06defcc4df628a6035cf1f95e5f2d2 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 13 Feb 2024 09:16:18 -0500 Subject: [PATCH 3/4] ssh: actual -> immediacy --- home/ssh.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/home/ssh.nix b/home/ssh.nix index 0df7788..22fc7ac 100644 --- a/home/ssh.nix +++ b/home/ssh.nix @@ -14,8 +14,9 @@ in "*".extraOptions = { identityAgent = _1passwordAgentSock; }; - actual = { - hostname = "167.205.125.179"; + immediacy = { + hostname = "65.109.35.172"; + user = "srid"; forwardAgent = true; }; biryani = { From 504e8452ddb74adbd0490c2858682819bf04ec7d Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 13 Feb 2024 09:18:47 -0500 Subject: [PATCH 4/4] ssh: apply quotations where necessary Also, ~ works. --- home/ssh.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/home/ssh.nix b/home/ssh.nix index 22fc7ac..02c1a1f 100644 --- a/home/ssh.nix +++ b/home/ssh.nix @@ -1,11 +1,11 @@ -{ config, pkgs, ... }: +{ pkgs, ... }: let inherit (pkgs) stdenv; _1passwordAgentSock = if stdenv.isDarwin then - "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" + ''"~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"'' else - "${config.home.homeDirectory}/.1password/agent.sock"; + "~/.1password/agent.sock"; in { programs.ssh = { @@ -28,7 +28,7 @@ in # https://developer.1password.com/docs/ssh/agent/advanced/#match-key-with-host "bitbucket.org" = { identitiesOnly = true; - identityFile = "${config.home.homeDirectory}/.ssh/juspay.pub"; + identityFile = "~/.ssh/juspay.pub"; }; }; };