23
hosts/common/configs/user/gui/clipbook/copy.sh
Executable file
23
hosts/common/configs/user/gui/clipbook/copy.sh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
list() {
|
||||||
|
echo -en "\0keep-selection\x1ftrue\n"
|
||||||
|
jq -r 'keys[]' "$BOOKMARKS"
|
||||||
|
}
|
||||||
|
|
||||||
|
handle() {
|
||||||
|
key="$1"
|
||||||
|
data=$(jq -r --arg key "$key" '.[$key]' "$BOOKMARKS")
|
||||||
|
|
||||||
|
type=$(echo "$data" | jq -r '.type')
|
||||||
|
content=$(echo "$data" | jq -r '.content')
|
||||||
|
|
||||||
|
if [[ "$type" == "file" ]]; then
|
||||||
|
wl-copy < "$content"
|
||||||
|
elif [[ "$type" == "text" ]]; then
|
||||||
|
echo -n "$content" | wl-copy
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
case ${ROFI_RETV} in
|
||||||
|
0) list ;;
|
||||||
|
1) handle "$@" ;;
|
||||||
|
esac
|
28
hosts/common/configs/user/gui/clipbook/default.nix
Normal file
28
hosts/common/configs/user/gui/clipbook/default.nix
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
user ? throw "user argument is required",
|
||||||
|
home ? throw "home argument is required",
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
hmConfig = config.home-manager.users.${user};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
home-manager.users.${user} = {
|
||||||
|
imports = [ ./options.nix ];
|
||||||
|
|
||||||
|
programs.clipbook.enable = true;
|
||||||
|
|
||||||
|
wayland.windowManager.hyprland.settings.bind =
|
||||||
|
let
|
||||||
|
clipbook-rofi = lib.meta.getExe hmConfig.programs.clipbook.finalPackage;
|
||||||
|
in
|
||||||
|
[
|
||||||
|
"$mod, c, exec, ${clipbook-rofi}"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
69
hosts/common/configs/user/gui/clipbook/options.nix
Normal file
69
hosts/common/configs/user/gui/clipbook/options.nix
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.programs.clipbook;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.programs.clipbook =
|
||||||
|
with lib;
|
||||||
|
with types;
|
||||||
|
{
|
||||||
|
enable = mkEnableOption "Clipbook";
|
||||||
|
|
||||||
|
bookmarks =
|
||||||
|
let
|
||||||
|
bookmarksOptions =
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
source = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Path to the file to copy.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
text = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Text to copy.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
mkOption {
|
||||||
|
type = attrsOf (submodule bookmarksOptions);
|
||||||
|
description = "Clipboard Bookmarks.";
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
|
||||||
|
finalPackage = mkOption {
|
||||||
|
type = package;
|
||||||
|
description = "The clipbook rofi package.";
|
||||||
|
default = pkgs.callPackage ./rofi.nix {
|
||||||
|
rofi = config.programs.rofi.finalPackage;
|
||||||
|
bookmarks = builtins.mapAttrs (_: bookmark: {
|
||||||
|
type = if bookmark.source != null then "file" else "text";
|
||||||
|
content = if bookmark.source != null then bookmark.source else bookmark.text;
|
||||||
|
}) cfg.bookmarks;
|
||||||
|
};
|
||||||
|
readOnly = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = builtins.all (
|
||||||
|
bookmark:
|
||||||
|
(bookmark.source == null || bookmark.text == null)
|
||||||
|
&& (bookmark.source != null || bookmark.text != null)
|
||||||
|
) (builtins.attrValues cfg.bookmarks);
|
||||||
|
message = "Each bookmark must have one of 'source' or 'text' set.";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
25
hosts/common/configs/user/gui/clipbook/rofi.nix
Normal file
25
hosts/common/configs/user/gui/clipbook/rofi.nix
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
rofi ? throw "rofi package is required",
|
||||||
|
bookmarks ? throw "bookmarks argument is required",
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
copy = lib.meta.getExe (
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "copy";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
jq
|
||||||
|
wl-clipboard
|
||||||
|
];
|
||||||
|
runtimeEnv.BOOKMARKS = (pkgs.formats.json { }).generate "bookmarks.json" bookmarks;
|
||||||
|
text = builtins.readFile ./copy.sh;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
in
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "clipbook-rofi";
|
||||||
|
runtimeInputs = [ rofi ];
|
||||||
|
text = "rofi -modi \"copy:${copy}\" -show copy";
|
||||||
|
}
|
@@ -15,10 +15,7 @@ in
|
|||||||
environment.persistence."/cache"."${home}/.cache/cliphist" = { };
|
environment.persistence."/cache"."${home}/.cache/cliphist" = { };
|
||||||
|
|
||||||
home-manager.users.${user} = {
|
home-manager.users.${user} = {
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [ cliphist ];
|
||||||
wl-clipboard
|
|
||||||
cliphist
|
|
||||||
];
|
|
||||||
|
|
||||||
systemd.user.services = {
|
systemd.user.services = {
|
||||||
cliphist = {
|
cliphist = {
|
||||||
|
@@ -496,18 +496,21 @@ in
|
|||||||
{
|
{
|
||||||
assertion = builtins.all (
|
assertion = builtins.all (
|
||||||
vault:
|
vault:
|
||||||
builtins.all (snippet: snippet.source == null || snippet.text == null) vault.settings.cssSnippets
|
builtins.all (
|
||||||
|
snippet:
|
||||||
|
(snippet.source == null || snippet.text == null) && (snippet.source != null || snippet.text != null)
|
||||||
|
) vault.settings.cssSnippets
|
||||||
) (builtins.attrValues cfg.vaults);
|
) (builtins.attrValues cfg.vaults);
|
||||||
message = "Only one of `source` and `text` must be set";
|
message = "Each CSS snippet must have one of 'source' or 'text' set";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
assertion = builtins.all (
|
assertion = builtins.all (
|
||||||
vault:
|
vault:
|
||||||
builtins.all (file: file.source == null || file.text == null) (
|
builtins.all (
|
||||||
builtins.attrValues vault.settings.extraFiles
|
file: (file.source == null || file.text == null) && (file.source != null || file.text != null)
|
||||||
)
|
) (builtins.attrValues vault.settings.extraFiles)
|
||||||
) (builtins.attrValues cfg.vaults);
|
) (builtins.attrValues cfg.vaults);
|
||||||
message = "Only one of `source` and `text` must be set";
|
message = "Each extra file must have one of 'source' or 'text' set";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
@@ -113,6 +113,6 @@ in
|
|||||||
password-store = "basic";
|
password-store = "basic";
|
||||||
};
|
};
|
||||||
|
|
||||||
wayland.windowManager.hyprland.settings.bind = [ "$mod, c, exec, ${lib.meta.getExe pkgs.vscode}" ];
|
wayland.windowManager.hyprland.settings.bind = [ "$mod, e, exec, ${lib.meta.getExe pkgs.vscode}" ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
8
hosts/common/configs/user/gui/wl-clipboard/default.nix
Normal file
8
hosts/common/configs/user/gui/wl-clipboard/default.nix
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
user ? throw "user argument is required",
|
||||||
|
home ? throw "home argument is required",
|
||||||
|
}:
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
home-manager.users.${user}.home.packages = with pkgs; [ wl-clipboard ];
|
||||||
|
}
|
@@ -1,28 +1,27 @@
|
|||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
let
|
|
||||||
userOptions =
|
|
||||||
with lib;
|
|
||||||
with types;
|
|
||||||
{ config, ... }:
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
email = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
description = "Email address of the user.";
|
|
||||||
};
|
|
||||||
|
|
||||||
fullName = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
description = "Full name of the user.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
options =
|
options =
|
||||||
with lib;
|
with lib;
|
||||||
with types;
|
with types;
|
||||||
{
|
{
|
||||||
users.users = mkOption { type = attrsOf (submodule userOptions); };
|
users.users =
|
||||||
|
let
|
||||||
|
userOptions =
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
email = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Email address of the user.";
|
||||||
|
};
|
||||||
|
|
||||||
|
fullName = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Full name of the user.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
mkOption { type = attrsOf (submodule userOptions); };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,8 @@ let
|
|||||||
# FIXME: https://github.com/NixOS/nixpkgs/issues/305643
|
# FIXME: https://github.com/NixOS/nixpkgs/issues/305643
|
||||||
user = "nick";
|
user = "nick";
|
||||||
home = "/home/nick";
|
home = "/home/nick";
|
||||||
|
|
||||||
|
hmConfig = config.home-manager.users.${user};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
@@ -49,6 +51,7 @@ in
|
|||||||
(import ../../../common/configs/user/gui/brightnessctl { inherit user home; })
|
(import ../../../common/configs/user/gui/brightnessctl { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/btop { inherit user home; })
|
(import ../../../common/configs/user/gui/btop { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/chromium { inherit user home; })
|
(import ../../../common/configs/user/gui/chromium { inherit user home; })
|
||||||
|
(import ../../../common/configs/user/gui/clipbook { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/cliphist { inherit user home; })
|
(import ../../../common/configs/user/gui/cliphist { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/darktable { inherit user home; })
|
(import ../../../common/configs/user/gui/darktable { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/discord { inherit user home; })
|
(import ../../../common/configs/user/gui/discord { inherit user home; })
|
||||||
@@ -73,6 +76,7 @@ in
|
|||||||
(import ../../../common/configs/user/gui/transmission { inherit user home; })
|
(import ../../../common/configs/user/gui/transmission { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/vscode { inherit user home; })
|
(import ../../../common/configs/user/gui/vscode { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/wev { inherit user home; })
|
(import ../../../common/configs/user/gui/wev { inherit user home; })
|
||||||
|
(import ../../../common/configs/user/gui/wl-clipboard { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/x11 { inherit user home; })
|
(import ../../../common/configs/user/gui/x11 { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/xdg { inherit user home; })
|
(import ../../../common/configs/user/gui/xdg { inherit user home; })
|
||||||
|
|
||||||
@@ -123,6 +127,11 @@ in
|
|||||||
"gpg/pass".sopsFile = ../../../../secrets/personal/secrets.yaml;
|
"gpg/pass".sopsFile = ../../../../secrets/personal/secrets.yaml;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
programs.clipbook.bookmarks = {
|
||||||
|
"SSH Key Passphrase".source = hmConfig.sops.secrets."ssh/personal/pass".path;
|
||||||
|
"GPG Passphrase".source = hmConfig.sops.secrets."gpg/personal/pass".path;
|
||||||
|
};
|
||||||
|
|
||||||
theme.wallpaper = ../../../../static/wallpapers/clouds.png;
|
theme.wallpaper = ../../../../static/wallpapers/clouds.png;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,8 @@ let
|
|||||||
# FIXME: https://github.com/NixOS/nixpkgs/issues/305643
|
# FIXME: https://github.com/NixOS/nixpkgs/issues/305643
|
||||||
user = "nikara";
|
user = "nikara";
|
||||||
home = "/home/nikara";
|
home = "/home/nikara";
|
||||||
|
|
||||||
|
hmConfig = config.home-manager.users.${user};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
@@ -45,6 +47,7 @@ in
|
|||||||
(import ../../../common/configs/user/gui/brightnessctl { inherit user home; })
|
(import ../../../common/configs/user/gui/brightnessctl { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/btop { inherit user home; })
|
(import ../../../common/configs/user/gui/btop { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/chromium { inherit user home; })
|
(import ../../../common/configs/user/gui/chromium { inherit user home; })
|
||||||
|
(import ../../../common/configs/user/gui/clipbook { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/cliphist { inherit user home; })
|
(import ../../../common/configs/user/gui/cliphist { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/emoji { inherit user home; })
|
(import ../../../common/configs/user/gui/emoji { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/firefox { inherit user home; })
|
(import ../../../common/configs/user/gui/firefox { inherit user home; })
|
||||||
@@ -65,6 +68,7 @@ in
|
|||||||
(import ../../../common/configs/user/gui/theme { inherit user home; })
|
(import ../../../common/configs/user/gui/theme { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/vscode { inherit user home; })
|
(import ../../../common/configs/user/gui/vscode { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/wev { inherit user home; })
|
(import ../../../common/configs/user/gui/wev { inherit user home; })
|
||||||
|
(import ../../../common/configs/user/gui/wl-clipboard { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/x11 { inherit user home; })
|
(import ../../../common/configs/user/gui/x11 { inherit user home; })
|
||||||
(import ../../../common/configs/user/gui/xdg { inherit user home; })
|
(import ../../../common/configs/user/gui/xdg { inherit user home; })
|
||||||
|
|
||||||
@@ -159,6 +163,13 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
programs.clipbook.bookmarks = {
|
||||||
|
"Personal SSH Key Passphrase".source = hmConfig.sops.secrets."ssh/personal/pass".path;
|
||||||
|
"Personal GPG Passphrase".source = hmConfig.sops.secrets."gpg/personal/pass".path;
|
||||||
|
"SAS SSH Key Passphrase".source = hmConfig.sops.secrets."ssh/sas/pass".path;
|
||||||
|
"SAS GPG Passphrase".source = hmConfig.sops.secrets."gpg/sas/pass".path;
|
||||||
|
};
|
||||||
|
|
||||||
theme.wallpaper = ../../../../static/wallpapers/snow.jpg;
|
theme.wallpaper = ../../../../static/wallpapers/snow.jpg;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user