aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Weigl-Bosker <stefan@s00.xyz>2025-03-06 14:46:21 -0500
committerStefan Weigl-Bosker <stefan@s00.xyz>2025-03-06 14:46:21 -0500
commitf1480abf77a14d1427722c99604f34d37b5c45b6 (patch)
tree916c6ad21b8b509cddf1cb77607464047898c003
parent6c1001c4dcbe7393fdead33d1c33f0fecf0da88d (diff)
downloadhome-f1480abf77a14d1427722c99604f34d37b5c45b6.tar.gz
pass
-rw-r--r--modules/default.nix1
-rw-r--r--modules/pass/default.nix65
-rwxr-xr-xmodules/pass/passmenu36
-rw-r--r--modules/sway/default.nix1
-rw-r--r--modules/zsh/default.nix7
-rw-r--r--void/home.nix4
6 files changed, 113 insertions, 1 deletions
diff --git a/modules/default.nix b/modules/default.nix
index d881953..6087536 100644
--- a/modules/default.nix
+++ b/modules/default.nix
@@ -10,5 +10,6 @@
./qutebrowser
./services
./gpg
+ ./pass
];
}
diff --git a/modules/pass/default.nix b/modules/pass/default.nix
new file mode 100644
index 0000000..e73fd76
--- /dev/null
+++ b/modules/pass/default.nix
@@ -0,0 +1,65 @@
+{ config, lib, pkgs, ... }:
+let
+ cfg = config.modules.pass;
+
+ inherit (lib) mkEnableOption mkOption mkIf types;
+in
+{
+ options.modules.pass = {
+ enable = mkEnableOption "pass";
+ enableExtensions = mkEnableOption "extensions";
+ key = mkOption {
+ type = types.nullOr types.str;
+ description = "gpg key, spaces forbidden";
+ default = "";
+ };
+ wmenu = mkOption {
+ type = types.str;
+ description = "dmenu command to use for passmenu in a wayland session";
+ default = "wmenu -n 4c4c4c -N 0d0d0d -s 8aac8b -S 0d0d0d -l 10";
+ };
+ xmenu = mkOption {
+ type = types.str;
+ description = "dmenu command to use for passmenu in an x session";
+ default = "dmenu";
+ };
+ };
+
+ config = mkIf cfg.enable {
+ home.packages = with pkgs; [(writeShellScriptBin "passmenu" ''
+ shopt -s nullglob globstar
+
+ if [[ -n $WAYLAND_DISPLAY ]]; then
+ menu="${cfg.wmenu}"
+ elif [[ -n $DISPLAY ]]; then
+ menu="${cfg.xmenu}" # fallback to dmenu if running under x11
+ else
+ echo "Error: No Wayland or X11 display detected" >&2
+ exit 1
+ fi
+
+ prefix=''${PASSWORD_STORE_DIR-~/.password-store}
+ password_files=( "$prefix"/**/*.gpg )
+ password_files=( "''${password_files[@]#"$prefix"/}" )
+ password_files=( "''${password_files[@]%.gpg}" )
+
+ password=$(printf '%s\n' "''${password_files[@]}" | $menu "$@")
+
+ [[ -n $password ]] || exit
+
+ pass show -c "$password" 2>/dev/null
+ '')];
+ programs.password-store = {
+ package = pkgs.pass.override {
+ dmenuSupport = false;
+ };
+ enable = true;
+ settings = {
+ PASSWORD_STORE_CHARACTER_SET="[:alnum:]*!@^&_\-=[]|;~,./?";
+ PASSWORD_STORE_CLIP_TIME="25";
+ PASSWORD_STORE_KEY=cfg.key;
+ PASSWORD_STORE_ENABLE_EXTENSIONS = if cfg.enableExtensions then "1" else "0";
+ };
+ };
+ };
+}
diff --git a/modules/pass/passmenu b/modules/pass/passmenu
new file mode 100755
index 0000000..f20e66e
--- /dev/null
+++ b/modules/pass/passmenu
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+shopt -s nullglob globstar
+
+typeit=0
+if [[ $1 == "--type" ]]; then
+ typeit=1
+ shift
+fi
+
+if [[ -n $WAYLAND_DISPLAY ]]; then
+ dmenu=wmenu
+ dmenu="wmenu -n 4c4c4c -N 0d0d0d -s 8aac8b -S 0d0d0d -l 10"
+ xdotool="ydotool type --file -"
+elif [[ -n $DISPLAY ]]; then
+ dmenu=wmenu
+ xdotool="xdotool type --clearmodifiers --file -"
+else
+ echo "Error: No Wayland or X11 display detected" >&2
+ exit 1
+fi
+
+prefix=${PASSWORD_STORE_DIR-~/.password-store}
+password_files=( "$prefix"/**/*.gpg )
+password_files=( "${password_files[@]#"$prefix"/}" )
+password_files=( "${password_files[@]%.gpg}" )
+
+password=$(printf '%s\n' "${password_files[@]}" | $dmenu "$@")
+
+[[ -n $password ]] || exit
+
+if [[ $typeit -eq 0 ]]; then
+ pass show -c "$password" 2>/dev/null
+else
+ pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
+fi
diff --git a/modules/sway/default.nix b/modules/sway/default.nix
index 3027bad..d6b0eec 100644
--- a/modules/sway/default.nix
+++ b/modules/sway/default.nix
@@ -177,6 +177,7 @@ in
keybindings = {
"${modifier}+Return" = "exec ${terminal}";
+ "${modifier}+p" = "exec passmenu";
"${modifier}+Shift+w" = "exec browser";
"${modifier}+d" = "exec ${menu}";
diff --git a/modules/zsh/default.nix b/modules/zsh/default.nix
index 0a66a20..3997ee2 100644
--- a/modules/zsh/default.nix
+++ b/modules/zsh/default.nix
@@ -28,7 +28,7 @@ in
};
programs.zsh = {
- enable = true;
+ enable = true;
autocd = true;
enableCompletion = true;
defaultKeymap = "viins";
@@ -37,6 +37,11 @@ in
dl = "~/dl";
src = "~/src";
};
+ shellAliases = {
+ ls = "eza";
+ ll = "eza -l";
+ hide = "swayhide";
+ };
autosuggestion.enable = true;
initExtra = ''
source ~/.oh-my-zsh/themes/${cfg.theme}.zsh-theme
diff --git a/void/home.nix b/void/home.nix
index be724e6..08b9615 100644
--- a/void/home.nix
+++ b/void/home.nix
@@ -20,6 +20,10 @@
gpg.enable = true;
+ pass = {
+ enable = true;
+ };
+
neovim = {
enable = true;
};