From cdbcb7bca2f73f02d8e13e4b6dac73e4e45fa53c Mon Sep 17 00:00:00 2001 From: Myned Date: Tue, 28 Jan 2025 15:29:19 -0600 Subject: [PATCH] 1password: add background service instead of spawn-at-startup Signed-off-by: Myned --- options/custom/desktops/niri/misc.nix | 1 - options/custom/programs/1password.nix | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/options/custom/desktops/niri/misc.nix b/options/custom/desktops/niri/misc.nix index dfc3550..2c0b6f9 100644 --- a/options/custom/desktops/niri/misc.nix +++ b/options/custom/desktops/niri/misc.nix @@ -53,7 +53,6 @@ in { home = hm.home.homeDirectory; in [ - {command = [_1password "--silent"];} # Launch password manager in background {command = [audio "--init"];} # Enforce audio profile state {command = [rm "${home}/.cache/walker/clipboard.gob"];} # Clear clipboard history {command = [sway-audio-idle-inhibit];} # Inhibit while audio is playing diff --git a/options/custom/programs/1password.nix b/options/custom/programs/1password.nix index 899a7b3..470328f 100644 --- a/options/custom/programs/1password.nix +++ b/options/custom/programs/1password.nix @@ -6,11 +6,14 @@ }: with lib; let cfg = config.custom.programs._1password; + + _1password = getExe config.programs._1password-gui.package; in { options.custom.programs._1password = { enable = mkOption {default = false;}; agent = mkOption {default = true;}; browser = mkOption {default = null;}; + service = mkOption {default = true;}; }; config = mkIf cfg.enable { @@ -38,6 +41,26 @@ in { }; }; + systemd.user.services."1password" = mkIf cfg.service { + enable = true; + wantedBy = ["graphical-session.target"]; + + unitConfig = { + Description = "Launch 1Password in the background"; + + After = + ["graphical-session.target"] + ++ optionals config.custom.services.xwayland-satellite.enable ["xwayland-satellite.service"]; + }; + + serviceConfig = { + Type = "simple"; + + # FIXME: 1password clipboard does not work in wayland + ExecStart = "${_1password} --silent --ozone-platform=x11"; + }; + }; + home-manager.users.${config.custom.username} = { programs.ssh.extraConfig = mkIf cfg.agent '' Host *