-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nix): Add home-manager module for 1Password Shell Plugins
- Loading branch information
1 parent
291d9e5
commit 81993de
Showing
2 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ lib, config, ... }: | ||
with lib; | ||
let cfg = config.programs.op-shell-plugins; | ||
in { | ||
options = { | ||
programs.op-shell-plugins = { | ||
enable = mkEnableOption "1Password Shell Plugins"; | ||
plugins = mkOption { | ||
type = types.listOf types.package; | ||
default = [ ]; | ||
example = literalExpression '' | ||
with pkgs; [ | ||
gh | ||
awscli2 | ||
cachix | ||
] | ||
''; | ||
description = | ||
"CLI Packages to enable 1Password Shell Plugins for; ensure that a Shell Plugin exists by checking the docs: https://developer.1password.com/docs/cli/shell-plugins/"; | ||
}; | ||
}; | ||
}; | ||
|
||
config = let | ||
aliases = '' | ||
export OP_PLUGIN_ALIASES_SOURCED=1 | ||
${concatMapStrings | ||
(plugin: ''alias ${plugin}="op plugin run -- ${plugin}"'') | ||
(map (package: builtins.baseNameOf (lib.getExe package)) cfg.plugins)} | ||
''; | ||
in mkIf cfg.enable (mkMerge [{ | ||
home.packages = cfg.plugins; | ||
programs = { | ||
fish.interactiveShellInit = '' | ||
${aliases} | ||
''; | ||
bash.initExtra = '' | ||
${aliases} | ||
''; | ||
zsh.initExtra = '' | ||
${aliases} | ||
''; | ||
}; | ||
}]); | ||
} |