-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support 1password ssh and git integration
- Loading branch information
1 parent
1445a14
commit 3b25d02
Showing
4 changed files
with
65 additions
and
33 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,68 @@ | ||
{ inputs, pkgs, ... }: | ||
{ | ||
inputs, | ||
config, | ||
pkgs, | ||
lib, | ||
... | ||
}: | ||
{ | ||
imports = [ inputs._1password-shell-plugins.hmModules.default ]; | ||
|
||
programs._1password-shell-plugins = { | ||
enable = true; | ||
plugins = with pkgs; [ gh ]; | ||
options = | ||
let | ||
inherit (lib) types mkOption; | ||
in | ||
{ | ||
programs._1password = { | ||
enable = mkOption { | ||
type = types.bool; | ||
description = '' | ||
Enables 1Password shell integration | ||
''; | ||
default = true; | ||
}; | ||
shellPluginPackages = mkOption { | ||
type = (with types; listOf package); | ||
description = '' | ||
Packages to be installed with 1Password shell integration | ||
''; | ||
default = [ pkgs.gh ]; | ||
}; | ||
enableGitSigning = mkOption { | ||
type = types.bool; | ||
description = '' | ||
Enable 1Password git commit signing integration | ||
''; | ||
default = pkgs.stdenv.isDarwin; | ||
}; | ||
enableSshAgent = mkOption { | ||
type = types.bool; | ||
description = '' | ||
Enable 1Password SSH identity handling | ||
''; | ||
default = pkgs.stdenv.isDarwin; | ||
}; | ||
}; | ||
}; | ||
|
||
config = { | ||
programs._1password-shell-plugins = { | ||
enable = true; | ||
plugins = with pkgs; [ gh ]; | ||
}; | ||
|
||
programs.ssh.extraConfig = lib.mkIf config.programs._1password.enableSshAgent "IdentityAgent \"${ | ||
if pkgs.stdenv.isDarwin then | ||
"~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" | ||
else | ||
"~/.1password/agent.sock" | ||
}\""; | ||
|
||
programs.git = lib.mkIf config.programs._1password.enableGitSigning { | ||
iniContent = { | ||
gpg.format = "ssh"; | ||
"gpg \"ssh\"".program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,13 @@ | ||
{ | ||
lib, | ||
pkgs, | ||
config, | ||
... | ||
}: | ||
{ | ||
options = { | ||
programs.ssh.enable1PasswordAgent = lib.mkOption { | ||
description = "Enable 1Password agent"; | ||
type = lib.types.bool; | ||
default = false; | ||
}; | ||
}; | ||
|
||
config.programs.ssh = { | ||
enable = true; | ||
|
||
forwardAgent = true; | ||
hashKnownHosts = true; | ||
addKeysToAgent = "yes"; | ||
|
||
extraConfig = lib.mkIf ( | ||
pkgs.stdenv.isDarwin && config.programs.ssh.enable1PasswordAgent | ||
) "IdentityAgent \"~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock\""; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters