From df532edf0231d7cf78f4deb546fd4d83850e611f Mon Sep 17 00:00:00 2001 From: punkfairie Date: Fri, 28 Feb 2025 19:20:41 -0800 Subject: [PATCH] feat(home): Set copy/paste cmd from apps mod --- modules/home/options/apps/default.nix | 60 +++++++++++++++++++---- modules/home/programs/cli/git/aliases.nix | 2 +- modules/home/programs/cli/git/default.nix | 2 +- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/modules/home/options/apps/default.nix b/modules/home/options/apps/default.nix index bc86e57..d8692f6 100644 --- a/modules/home/options/apps/default.nix +++ b/modules/home/options/apps/default.nix @@ -16,14 +16,56 @@ in { description = "The pinentry package to use."; }; - clipboard = lib.mkOption { - type = lib.types.package; - default = - if config.marleyos.xorg.xsession.enable - then pkgs.clipboard-jh - else pkgs.wl-clipboard; - description = "The clipboard manager to use."; - }; + clipboard = let + isXorg = config.marleyos.xorg.xsession.enable; + defaultXorg = { + package = pkgs.clipboard-jh; + copy-command = "${lib.getExe pkgs.clipboard-jh} copy"; + paste-command = "${lib.getExe pkgs.clipboard-jh} paste"; + }; + defaultWayland = { + package = pkgs.wl-clipboard; + copy-command = lib.getExe' pkgs.wl-clipboard "wl-copy"; + paste-command = lib.getExe' pkgs.wl-clipboard "wl-paste"; + }; + in + lib.mkOption { + type = lib.types.submodule { + options = { + package = lib.mkOption { + type = lib.types.package; + default = + if isXorg + then defaultXorg.package + else defaultWayland.package; + description = "The clipboard manager to use."; + }; + + copy-command = lib.mkOption { + type = lib.types.str; + default = + if isXorg + then defaultXorg.copy-command + else defaultWayland.copy-command; + description = "The command, including binary, to use for copying."; + }; + + paste-command = lib.mkOption { + type = lib.types.str; + default = + if isXorg + then defaultXorg.paste-command + else defaultWayland.paste-command; + description = "The command, including binary, to use for pasting."; + }; + }; + }; + + default = + if isXorg + then defaultXorg + else defaultWayland; + }; terminal = lib.mkOption { type = lib.types.package; @@ -63,7 +105,7 @@ in { config = lib.mkIf (is-linux system) { home.packages = [ cfg.pinentry - cfg.clipboard + cfg.clipboard.package ]; programs.rbw = lib.mkDefault { diff --git a/modules/home/programs/cli/git/aliases.nix b/modules/home/programs/cli/git/aliases.nix index 409eff5..3a8915c 100644 --- a/modules/home/programs/cli/git/aliases.nix +++ b/modules/home/programs/cli/git/aliases.nix @@ -161,7 +161,7 @@ in { open = lib.mkIf (config.programs.fish.enable && (fish_fns ? git_open)) "!fish -c git_open"; - chash = "!git log --oneline | gum filter --height 10 | cut -d' ' -f1 | ${config.marleyos.apps.clipboard} &>/dev/null"; + chash = "!git log --oneline | gum filter --height 10 | cut -d' ' -f1 | ${config.marleyos.apps.clipboard.copy-command} &>/dev/null"; }; }; } diff --git a/modules/home/programs/cli/git/default.nix b/modules/home/programs/cli/git/default.nix index 28864b0..945b7df 100644 --- a/modules/home/programs/cli/git/default.nix +++ b/modules/home/programs/cli/git/default.nix @@ -15,7 +15,7 @@ in { config = lib.mkIf cfg.enable { home.packages = with pkgs; [ gum - config.marleyos.apps.clipboard + config.marleyos.apps.clipboard.package ]; # ██████╗ ██╗████████╗