1Password: Difference between revisions

From NixOS Wiki
m add summary of program to top of page
copyedit: restructure headings, add links
Line 1: Line 1:
[https://1password.com/ 1Password] is a password manager.
[https://1password.com/ 1Password] is a password manager.


= Using 1Password on NixOS =
== NixOS ==
If you're using NixOS, you can enable 1Password and its GUI by:
 
=== Installation ===
 
If you're using [[NixOS]], you can enable 1Password and its GUI with:
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, ... }:
Line 27: Line 30:




== Unlocking Browser Extensions ==
=== Unlocking browser extensions ===


{{warning|1=This only works for browsers that are installed via NixOS -- Browsers installed via flatpak are not supported}}
{{warning|1=This only works for browsers that are installed via [[NixOS]]. Browsers installed via [[Flatpak]] are not supported.}}


The 1Password app can unlock your browser extension using a special NativeMessaging process.  This streamlines your 1Password experience: Once you unlock 1Password from your tray icon, your browser extensions will be unlocked as well.   
The 1Password app can unlock your browser extension using a special [https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging native messaging] process.  This streamlines your 1Password experience: Once you unlock 1Password from your tray icon, your browser extensions will be unlocked as well.   


This is automatically configured for Firefox, Chrome, and Brave browsers.  However, Vivaldi and other custom Chrome-based browsers may not unlock when you unlock 1Password.  If you find this to be the case, the solution is to set the  <code>/etc/1password/custom_allowed_browsers</code> file as follows:
This is automatically configured for [[Firefox]], [[Chrome]], and [[Brave]] browsers.  However, [[Vivaldi]] and other custom Chrome-based browsers may not unlock when you unlock 1Password.  If you find this to be the case, the solution is to set the  <code>/etc/1password/custom_allowed_browsers</code> file as follows:


* First, use <code>ps aux</code> to find the application name for the browser.  For Vivaldi, this is <code>vivaldi-bin</code>
* First, use <code>ps aux</code> to find the application name for the browser.  For Vivaldi, this is <code>vivaldi-bin</code>
* Add that binary name to <code>/etc/1password/custom_allowed_browsers</code>  
* Add that binary name to <code>/etc/1password/custom_allowed_browsers</code>:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 50: Line 53:
</syntaxhighlight>
</syntaxhighlight>


== Home Manager ==
{{warning|1=Non-[[NixOS]] installs [https://1password.community/discussion/comment/655813/#Comment_655813 will not link with browser extensions or system authentication] }}


== 1Password, SSH keys and Home Manager ==
=== Installation ===


If 1Password manages your SSH keys and you use [https://nix-community.github.io/home-manager/index.xhtml Home Manager], you may also configure your <code>~/.ssh/config</code> file using Nix:
Add the following to your [[Home Manager]] configuration:
 
<syntaxhighlight lang="nix">
  home.packages = [
    pkgs._1password
    pkgs._1password-gui
  ];
</syntaxhighlight>
 
=== SSH key management ===
 
1Password [https://developer.1password.com/docs/ssh/ can manage SSH keys].
 
==== Configuring SSH ====
 
If 1Password manages your [[SSH]] keys and you use [[Home Manager]], you may also configure your <code>~/.ssh/config</code> file using Nix:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 70: Line 91:
</syntaxhighlight>
</syntaxhighlight>


== 1Password with Git Ssh Signing ==  
==== Configuring Git ====


You can enable git ssh singing with [https://nix-community.github.io/home-manager/index.xhtml Home Manager]:
You can enable [[Git]]'s [[SSH]] singing with [[Home Manager]]:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 97: Line 118:
</syntaxhighlight>
</syntaxhighlight>


= On non-NixOS installs =
{{warning|1=non-NixOS installs [https://1password.community/discussion/comment/655813/#Comment_655813 will not link with browser extensions or system authentication] }}
Home Manager
<syntaxhighlight lang="nix">
  home.packages = [
    pkgs._1password
    pkgs._1password-gui
  ];
</syntaxhighlight>


[[Category:Software]]
[[Category:Software]]

Revision as of 04:46, 21 June 2024

1Password is a password manager.

NixOS

Installation

If you're using NixOS, you can enable 1Password and its GUI with:

/etc/nixos/configuration.nix
{ config, lib, pkgs, ... }:
{
  # Enable the unfree 1Password packages
  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "1password-gui"
    "1password"
  ];
  # Alternatively, you could also just allow all unfree packages
  # nixpkgs.config.allowUnfree = true;

  programs._1password.enable = true;
  programs._1password-gui = {
    enable = true;
    # Certain features, including CLI integration and system authentication support,
    # require enabling PolKit integration on some desktop environments (e.g. Plasma).
    polkitPolicyOwners = [ "yourUsernameHere" ];
  };
  ...
}


Unlocking browser extensions

Warning: This only works for browsers that are installed via NixOS. Browsers installed via Flatpak are not supported.

The 1Password app can unlock your browser extension using a special native messaging process. This streamlines your 1Password experience: Once you unlock 1Password from your tray icon, your browser extensions will be unlocked as well.

This is automatically configured for Firefox, Chrome, and Brave browsers. However, Vivaldi and other custom Chrome-based browsers may not unlock when you unlock 1Password. If you find this to be the case, the solution is to set the /etc/1password/custom_allowed_browsers file as follows:

  • First, use ps aux to find the application name for the browser. For Vivaldi, this is vivaldi-bin
  • Add that binary name to /etc/1password/custom_allowed_browsers:
    environment.etc = {
      "1password/custom_allowed_browsers" = {
        text = ''
          vivaldi-bin
          wavebox
        '';
        mode = "0755";
      };
    };

Home Manager

Installation

Add the following to your Home Manager configuration:

  home.packages = [
    pkgs._1password
    pkgs._1password-gui
  ];

SSH key management

1Password can manage SSH keys.

Configuring SSH

If 1Password manages your SSH keys and you use Home Manager, you may also configure your ~/.ssh/config file using Nix:

_: let
  # onePassPath = "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock";
  onePassPath = "~/.1password/agent.sock";
in {
  programs.ssh = {
    enable = true;
    extraConfig = ''
      Host *
          IdentityAgent ${onePassPath}
    '';
  };
}

Configuring Git

You can enable Git's SSH singing with Home Manager:

{
  programs.git = {
    enable = true;
    extraConfig = {
      gpg = {
        format = "ssh";
      };
      "gpg \"ssh\"" = {
        program = "${lib.getExe' pkgs._1password-gui "op-ssh-sign"}";
      };
      commit = {
        gpgsign = true;
      };

      user = {
        signingKey = "...";
      };
    };
  };
}