This commit is contained in:
parent
7780eca7a9
commit
5341b761ad
15 changed files with 29 additions and 38 deletions
|
@ -1,21 +0,0 @@
|
|||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "create-script";
|
||||
|
||||
text = ''
|
||||
cat > "$1" << EOF
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
|
||||
EOF
|
||||
|
||||
chmod +x "$1"
|
||||
|
||||
$EDITOR "$1";
|
||||
'';
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
# TODO: separate desktop-only scripts?
|
||||
home.packages =
|
||||
let
|
||||
scriptNames = [
|
||||
"create-script"
|
||||
"mounter"
|
||||
"move-firefox-screenshots"
|
||||
"setbg"
|
||||
"tag-release"
|
||||
"todos-add"
|
||||
"unmounter"
|
||||
"update-all-git-repos"
|
||||
];
|
||||
in
|
||||
map (name: pkgs.callPackage ./${name}.nix { }) scriptNames;
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "mounter";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
cryptsetup
|
||||
dmenu
|
||||
gawk
|
||||
libnotify
|
||||
util-linux
|
||||
];
|
||||
|
||||
text = ''
|
||||
lsblk_output="$(lsblk -rpo "uuid,name,type,size,label,mountpoint,mountpoints,fstype" | grep "part" | grep -Ev "/(boot|nix/store)")"
|
||||
partition_names="$(echo "$lsblk_output" | awk '{ printf "%s (%s)\n", $2, $4 }' )";
|
||||
|
||||
selected=$(echo "$partition_names" | dmenu -p "Select drive:" | awk '{ print $1 }')
|
||||
test -n "$selected"
|
||||
mount_device="$selected"
|
||||
|
||||
if sudo cryptsetup isLuks "$selected"; then
|
||||
luks_name="usb"
|
||||
|
||||
${"TERMINAL:-st"} -n floatterm -g 60x1 -e sudo cryptsetup open "$selected" "$luks_name"
|
||||
|
||||
mount_device="/dev/mapper/$luks_name"
|
||||
|
||||
test -b "/dev/mapper/$luks_name"
|
||||
fi
|
||||
|
||||
mount_point=$(echo -e "/mnt\n/media\n/run/media/$USER" | dmenu -p "Select mount point:")
|
||||
test -n "$mount_point"
|
||||
|
||||
sudo mkdir -p "$mount_point"
|
||||
|
||||
if sudo mount "$mount_device" "$mount_point"; then
|
||||
notify-send "Device mounted" "Mounted $selected at $mount_point."
|
||||
else
|
||||
notify-send "Mount failed" "Failed to mount $selected."
|
||||
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "move-firefox-screenshots";
|
||||
|
||||
runtimeInputs = with pkgs; [ findutils ];
|
||||
|
||||
text = ''
|
||||
original_directory="''${HOME}/Downloads"
|
||||
new_directory="''${HOME}/Pictures/Screenshots"
|
||||
|
||||
find "''${original_directory}" -mindepth 1 -maxdepth 1 -type f -name "Screenshot *" \
|
||||
-exec mv {} "''${new_directory}" \;
|
||||
'';
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
{ pkgs, writeShellApplication }:
|
||||
|
||||
writeShellApplication {
|
||||
name = "setbg";
|
||||
|
||||
runtimeInputs = with pkgs; [ xwallpaper ];
|
||||
|
||||
text = ''
|
||||
xwallpaper --zoom "''${XDG_REPOS_DIR}/personal/nix-config/wallpaper/wallpaper.jpg"
|
||||
'';
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
{ git, writeShellApplication }:
|
||||
|
||||
writeShellApplication {
|
||||
name = "tag-release";
|
||||
|
||||
runtimeInputs = [ git ];
|
||||
|
||||
text = ''
|
||||
commit_sha="''${1:-HEAD}"
|
||||
tag="$(date '+%Y-%m-%d-%H.%M.%S')"
|
||||
|
||||
echo "Tagging commit $(git rev-parse "''${commit_sha}") as ''${tag}."
|
||||
echo ""
|
||||
|
||||
git tag "''${tag}" "''${commit_sha}"
|
||||
'';
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "todos-add";
|
||||
|
||||
runtimeInputs = with pkgs; [ coreutils ];
|
||||
|
||||
text = ''
|
||||
TODOS_PATH="$HOME/Documents/wiki/todo.txt"
|
||||
|
||||
if [ ''${#} -eq 0 ]; then
|
||||
if [ -p "/dev/stdin" ]; then
|
||||
(cat; printf "\n\n") >> "''${TODOS_PATH}"
|
||||
else
|
||||
eval "''${TODOS_EDITOR}" "''${TODOS_PATH}"
|
||||
fi
|
||||
else
|
||||
printf "%s\n\n" "''${*}" >> "''${TODOS_PATH}"
|
||||
fi
|
||||
'';
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "unmounter";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
cryptsetup
|
||||
dmenu
|
||||
gawk
|
||||
libnotify
|
||||
util-linux
|
||||
];
|
||||
|
||||
text = ''
|
||||
lsblk_output="$(lsblk -nrpo "name,type,size,mountpoint")"
|
||||
mounted_drives="$(echo "$lsblk_output" | awk '($2=="part"||$2="crypt")&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')"
|
||||
|
||||
all_unmountable="$(echo "$mounted_drives" | sed "/^$/d;s/ *$//")"
|
||||
test -n "$all_unmountable"
|
||||
|
||||
selected="$(echo "$all_unmountable" | dmenu -i -p "Unmount which drive?")"
|
||||
selected="''${selected%% *}"
|
||||
test -n "$selected"
|
||||
|
||||
sudo -A umount -l "/''${selected#*/}"
|
||||
notify-send "Device unmounted" "$selected has been unmounted."
|
||||
|
||||
# Close the selected drive if decrypted.
|
||||
cryptid="$(echo "$lsblk_output" | grep "/''${selected#*/}$")"
|
||||
cryptid="''${cryptid%% *}"
|
||||
test -b /dev/mapper/"''${cryptid##*/}"
|
||||
sudo -A cryptsetup close "$cryptid"
|
||||
|
||||
notify-send "Device dencryption closed" "Drive is now securely locked again."
|
||||
'';
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "update-all-git-repos";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
findutils
|
||||
git
|
||||
];
|
||||
|
||||
text = ''
|
||||
# Update all top-level Git repository clones within my Code directories to their
|
||||
# latest version.
|
||||
|
||||
dirs=$(find "$XDG_REPOS_DIR" -mindepth 2 -maxdepth 3 -type d -name .git -not -path '*/*.old/*')
|
||||
|
||||
for dir in $dirs; do
|
||||
repo_path="''${dir%/.git}"
|
||||
|
||||
cd "''${repo_path}"
|
||||
|
||||
# If the repo is a bare clone, the commands need to be run within the
|
||||
# worktree directory.
|
||||
[[ -f .bare/worktrees/main/gitdir && -d main && -f main/.git ]] && cd main
|
||||
|
||||
echo "Updating $(pwd)"
|
||||
|
||||
# Update the repository.
|
||||
git fetch --all --jobs=4 --progress --prune
|
||||
git pull --rebase
|
||||
done
|
||||
'';
|
||||
}
|
|
@ -9,7 +9,6 @@
|
|||
./cli/node.nix
|
||||
./cli/notes.nix
|
||||
./cli/ranger.nix
|
||||
./cli/scripts
|
||||
./cli/starship.nix
|
||||
./cli/sxhkd.nix
|
||||
./cli/tmux-sessionizer.nix
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue