Skip to content

Commit

Permalink
feat(nix): Configure 1Password CLI+Shell Plugins via Nix
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjones2014 committed Aug 15, 2023
1 parent 066a0a7 commit 8175ef0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
4 changes: 0 additions & 4 deletions home-manager/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ in {
keep-derivations = true
keep-outputs = true
'';
"op/plugins.sh".source = pkgs.writeScript "op_plugins.sh" ''
export OP_PLUGIN_ALIASES_SOURCED=1
alias gh="op plugin run -- gh"
'';
};
home.file."${config.home.homeDirectory}/.xprofile".text = ''
export XDG_DATA_DIRS="$XDG_DATA_DIRS:/home/mat/.nix-profile/share"
Expand Down
23 changes: 11 additions & 12 deletions home-manager/modules/fish.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{ pkgs, config, ... }:
{ pkgs, config, lib, ... }:
let
inherit (pkgs) stdenv;
inherit (stdenv) isLinux;
opSudoPasswordScript = pkgs.writeScript "opsudo.bash" ''
#!${pkgs.bash}/bin/bash
/run/wrappers/bin/op item get "System Password" --fields password
${pkgs._1password}/bin/op item get "System Password" --fields password
'';
op-shell-plugins = [ "gh" ];
in {
home.sessionVariables = {
DOTNET_CLI_TELEMETRY_OPTOUT = "1";
Expand All @@ -18,9 +19,11 @@ in {
};

home.packages = with pkgs;
[ wget thefuck gh fzf jq glow exa tealdeer tokei cachix ]
[ wget thefuck gh fzf jq glow exa tealdeer tokei cachix _1password ]
++ lib.lists.optionals isLinux [ xclip ];

programs.gh.enable = true;

programs.fish = {
enable = true;

Expand All @@ -43,14 +46,14 @@ in {
ll = "ls -l --git";
l = "ls -laH";
lg = "ls -lG";
sudo = "sudo -A";
nix-apply = if pkgs.stdenv.isDarwin then
"home-manager switch --flake ~/git/dotfiles/.#mac"
else
"sudo nixos-rebuild switch --flake ~/git/dotfiles/.#pc";
oplocal =
"./js/oph/dist/mac-arm64/1Password.app/Contents/MacOS/1Password";
} // pkgs.lib.optionalAttrs isLinux {
sudo = "sudo -A";
cfgnix = "sudo nvim /etc/nixos/configuration.nix";
restart-gui = "sudo systemctl restart display-manager.service";
};
Expand Down Expand Up @@ -82,19 +85,15 @@ in {
fish_vi_key_bindings
bind -M insert jk "if commandline -P; commandline -f cancel; else; set fish_bind_mode default; commandline -f backward-char force-repaint; end"
thefuck --alias | source
starship init fish | source
atuin init fish | source
gh completion -s fish | source
for mode in insert default normal
bind -M insert \e\[A "_atuin_search; tput cup \$LINES"
bind -M $mode \a _project_jump
end
if [ -e "$XDG_CONFIG_HOME/op/plugins.sh" ]
source "$XDG_CONFIG_HOME/op/plugins.sh"
end
export OP_PLUGIN_ALIASES_SOURCED=1
${lib.concatMapStrings
(plugin: ''alias ${plugin}="op plugin run -- ${plugin}"'')
op-shell-plugins}
# I like to keep the prompt at the bottom rather than the top
# of the terminal window so that running `clear` doesn't make
Expand Down

0 comments on commit 8175ef0

Please sign in to comment.