From 71732127deddeec090105848c21b14197dac0cee Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Thu, 17 Oct 2024 07:58:29 +0700 Subject: [PATCH] hyprland: split off gnome-keyring to its own module --- home/modules/hyprland/default.nix | 1 + home/modules/hyprland/gnome-keyring.nix | 27 +++++++++++++++++++++++++ home/modules/hyprland/hyprland.nix | 8 +------- 3 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 home/modules/hyprland/gnome-keyring.nix diff --git a/home/modules/hyprland/default.nix b/home/modules/hyprland/default.nix index 6a4d7c5..f4023f7 100644 --- a/home/modules/hyprland/default.nix +++ b/home/modules/hyprland/default.nix @@ -22,6 +22,7 @@ in ./swayosd.nix ./sway-notification-center.nix ./ntfy-sh.nix + ./gnome-keyring.nix ]; config = lib.mkIf cfg.enable { home.packages = with pkgs; [ diff --git a/home/modules/hyprland/gnome-keyring.nix b/home/modules/hyprland/gnome-keyring.nix new file mode 100644 index 0000000..821f18f --- /dev/null +++ b/home/modules/hyprland/gnome-keyring.nix @@ -0,0 +1,27 @@ +{ lib, pkgs, config, ... }: +let + cfg = config.profile.hyprland; + inherit (lib) mkIf; + inherit (lib.meta) getExe; + secretKey = "gnome-keyring/${config.home.username}"; +in +{ + config = mkIf cfg.enable { + home.packages = with pkgs; [ + gnome.gnome-keyring + ]; + + sops.secrets.${secretKey} = { }; + wayland.windowManager.hyprland.settings.exec-once = + let + scriptFile = getExe (pkgs.writeShellScriptBin "gnome-keyring.sh" /*sh*/ '' + cat "${config.sops.secrets.${secretKey}.path}" | gnome-keyring-daemon --unlock + gnome-keyring-daemon --start --components=pkcs11,secrets,ssh + ''); + in + [ + ''${scriptFile}'' + ]; + }; +} + diff --git a/home/modules/hyprland/hyprland.nix b/home/modules/hyprland/hyprland.nix index 0ac962f..b69db7d 100644 --- a/home/modules/hyprland/hyprland.nix +++ b/home/modules/hyprland/hyprland.nix @@ -1,4 +1,4 @@ -{ lib, inputs, pkgs, config, ... }: +{ lib, pkgs, config, ... }: let cfg = config.profile.hyprland; select-window = rec { @@ -11,11 +11,6 @@ let script = pkgs.writeScriptBin filename (builtins.readFile (./scripts/init-wallpaper.sh)); path = "${script}/bin/${filename}"; }; - gnome-keyring = rec { - filename = "gnome-keyring.sh"; - script = pkgs.writeScriptBin filename (builtins.readFile (./scripts/gnome-keyring.sh)); - path = "${script}/bin/${filename}"; - }; in { config = lib.mkIf cfg.enable { @@ -211,7 +206,6 @@ in }; extraConfig = /*hyprlang*/ '' exec-once=dbus-update-activation-environment --all - exec-once=${gnome-keyring.path} ${config.sops.secrets."gnome-keyring/${config.home.username}".path} exec-once=foot --server exec-once=${init-wallpaper.path} ${./wallpaper.jpeg}