diff options
author | Kenny Ballou <kballou@devnulllabs.io> | 2021-01-20 19:18:23 -0700 |
---|---|---|
committer | Kenny Ballou <kballou@devnulllabs.io> | 2021-01-21 13:16:22 -0700 |
commit | c357715fbe477a903dc89aaab0a9b356411bd4a6 (patch) | |
tree | ebc0e2cdb6662dd252ac3d9540bed1c7e8865ecb | |
parent | a59f5bb7da82d6b54b65579432f1b7a3fb03aaa7 (diff) | |
download | dotfiles-c357715fbe477a903dc89aaab0a9b356411bd4a6.tar.gz dotfiles-c357715fbe477a903dc89aaab0a9b356411bd4a6.tar.xz |
scripts: move shell scripts into mini nix packages
Move over scripts that were symlinked into the PATH into scripts that
are installed as nix "packages".
Several docker and mount scripts are not ported and simply removed.
Signed-off-by: Kenny Ballou <kballou@devnulllabs.io>
-rw-r--r-- | overlays/kb/default.nix | 8 | ||||
-rw-r--r-- | packages.nix | 4 | ||||
-rw-r--r-- | packages/scripts/gen-sshconfig-sh/default.nix | 3 | ||||
-rwxr-xr-x | packages/scripts/gen-sshconfig-sh/gen-sshconfig.sh (renamed from scripts/.local/bin/gen_sshconfig.sh) | 6 | ||||
-rw-r--r-- | packages/scripts/git-sync-py/default.nix | 3 | ||||
-rwxr-xr-x | packages/scripts/git-sync-py/git-sync.py (renamed from scripts/.local/bin/git_sync.py) | 0 | ||||
-rw-r--r-- | packages/scripts/install-git-hooks-sh/default.nix | 3 | ||||
-rwxr-xr-x | packages/scripts/install-git-hooks-sh/install-git-hooks.sh | 9 | ||||
-rw-r--r-- | packages/scripts/shadir-sh/default.nix | 7 | ||||
-rw-r--r-- | packages/scripts/shreddir-sh/default.nix | 14 | ||||
-rwxr-xr-x | scripts/.local/bin/clean_docker | 11 | ||||
-rwxr-xr-x | scripts/.local/bin/docker-tags | 4 | ||||
-rwxr-xr-x | scripts/.local/bin/install_git_hooks.sh | 9 | ||||
-rwxr-xr-x | scripts/.local/bin/md5dir | 3 | ||||
-rwxr-xr-x | scripts/.local/bin/mount_crypt | 40 | ||||
-rwxr-xr-x | scripts/.local/bin/reap_docker_volumes | 6 | ||||
-rwxr-xr-x | scripts/.local/bin/shadir | 3 | ||||
-rwxr-xr-x | scripts/.local/bin/shreddir | 9 |
18 files changed, 54 insertions, 88 deletions
diff --git a/overlays/kb/default.nix b/overlays/kb/default.nix new file mode 100644 index 00000000..ff09c4ca --- /dev/null +++ b/overlays/kb/default.nix @@ -0,0 +1,8 @@ +self: super: +{ + gen-sshconfig-sh = super.callPackage ../../packages/scripts/gen-sshconfig-sh {}; + git-sync-py = super.callPackage ../../packages/scripts/git-sync-py {}; + install-git-hooks-sh = super.callPackage ../../packages/scripts/install-git-hooks-sh {}; + shadir-sh = super.callPackage ../../packages/scripts/shadir-sh {}; + shreddir-sh = super.callPackage ../../packages/scripts/shreddir-sh {}; +} diff --git a/packages.nix b/packages.nix index 70b656bc..027fdb06 100644 --- a/packages.nix +++ b/packages.nix @@ -37,6 +37,7 @@ with pkgs; [ fonts-overlay fzf gawk + gen-sshconfig-sh gimp git-tools global @@ -58,6 +59,7 @@ with pkgs; [ imagemagick imgcat inkscape.out + install-git-hooks-sh iotop isync jetbrains.idea-community @@ -106,7 +108,9 @@ with pkgs; [ rsync rtags screen + shadir-sh shellcheck + shreddir-sh signal-desktop silver-searcher slack diff --git a/packages/scripts/gen-sshconfig-sh/default.nix b/packages/scripts/gen-sshconfig-sh/default.nix new file mode 100644 index 00000000..0e7fa638 --- /dev/null +++ b/packages/scripts/gen-sshconfig-sh/default.nix @@ -0,0 +1,3 @@ +{ pkgs, ... }: + +pkgs.writeScriptBin "gen-sshconfig" (builtins.readFile ./gen-sshconfig.sh) diff --git a/scripts/.local/bin/gen_sshconfig.sh b/packages/scripts/gen-sshconfig-sh/gen-sshconfig.sh index cd14909e..1fd796f8 100755 --- a/scripts/.local/bin/gen_sshconfig.sh +++ b/packages/scripts/gen-sshconfig-sh/gen-sshconfig.sh @@ -20,13 +20,13 @@ SSH_CONFIG_DIR=${HOME}/.ssh SSH_CONFIG=${SSH_CONFIG_DIR}/config SSH_CONFIGS_DIR=${SSH_CONFIG_DIR}/config.d -mv ${SSH_CONFIG} ${SSH_CONFIG}-`date -Iseconds`.old +mv "${SSH_CONFIG}" "${SSH_CONFIG}-$(date -Iseconds).old" -cat << EOF > ${SSH_CONFIG} +cat << EOF > "${SSH_CONFIG}" # vim: filetype=sshconfig: # DO NOT EDIT THIS FILE! # This file is automatically generated via "gen_sshconfig.sh". # Edits will be lost the next time "gen_sshconfig.sh" is used. EOF -cat ${SSH_CONFIGS_DIR}/*.conf | grep --invert-match '^#' >> ${SSH_CONFIG} +cat "${SSH_CONFIGS_DIR}"/*.conf | grep --invert-match '^#' >> "${SSH_CONFIG}" diff --git a/packages/scripts/git-sync-py/default.nix b/packages/scripts/git-sync-py/default.nix new file mode 100644 index 00000000..273183b2 --- /dev/null +++ b/packages/scripts/git-sync-py/default.nix @@ -0,0 +1,3 @@ +{ pkgs, ...}: + +pkgs.writeScriptBin "git_sync.py" (builtins.readFile ./git-sync.py) diff --git a/scripts/.local/bin/git_sync.py b/packages/scripts/git-sync-py/git-sync.py index e449df8e..e449df8e 100755 --- a/scripts/.local/bin/git_sync.py +++ b/packages/scripts/git-sync-py/git-sync.py diff --git a/packages/scripts/install-git-hooks-sh/default.nix b/packages/scripts/install-git-hooks-sh/default.nix new file mode 100644 index 00000000..da2ca76f --- /dev/null +++ b/packages/scripts/install-git-hooks-sh/default.nix @@ -0,0 +1,3 @@ +{ pkgs, ... }: + +pkgs.writeScriptBin "install-git-hooks.sh" (builtins.readFile ./install-git-hooks.sh) diff --git a/packages/scripts/install-git-hooks-sh/install-git-hooks.sh b/packages/scripts/install-git-hooks-sh/install-git-hooks.sh new file mode 100755 index 00000000..86401e03 --- /dev/null +++ b/packages/scripts/install-git-hooks-sh/install-git-hooks.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +HOOKS="${HOME}/.git_template/hooks" +GWD="$(pwd)/.git/hooks" + +mkdir -p ${GWD} +printf "Installing hooks to: %s\n" "$GWD" + +cp --dereference "${HOOKS}"/* "${GWD}"/. diff --git a/packages/scripts/shadir-sh/default.nix b/packages/scripts/shadir-sh/default.nix new file mode 100644 index 00000000..4805f062 --- /dev/null +++ b/packages/scripts/shadir-sh/default.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: + +pkgs.writeScriptBin "shadir" '' +#!${pkgs.bash}/bin/bash + +exec ${pkgs.findutils}/bin/find "$1" -type f -exec ${pkgs.coreutils}/bin/sha256sum {} > check.sha256 \; +'' diff --git a/packages/scripts/shreddir-sh/default.nix b/packages/scripts/shreddir-sh/default.nix new file mode 100644 index 00000000..a358e7f3 --- /dev/null +++ b/packages/scripts/shreddir-sh/default.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: + +pkgs.writeScriptBin "shreddir" '' +#!${pkgs.bash}/bin/bash + +if [ "$1" = "" ]; then + echo "I'm not comfortable doing this..." + exit 1 +fi + +${pkgs.findutils}/bin/find "$1" -type f -print -exec ${pkgs.coreutils}/bin/shred -zu {} \; +rm -rf $1 + +'' diff --git a/scripts/.local/bin/clean_docker b/scripts/.local/bin/clean_docker deleted file mode 100755 index 10ba5b76..00000000 --- a/scripts/.local/bin/clean_docker +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -docker ps \ - --quiet \ - --filter 'status=exited' \ - | xargs --no-run-if-empty docker rm - -docker images \ - --quiet \ - --filter 'dangling=true' \ - | xargs --no-run-if-empty docker rmi diff --git a/scripts/.local/bin/docker-tags b/scripts/.local/bin/docker-tags deleted file mode 100755 index cde1f564..00000000 --- a/scripts/.local/bin/docker-tags +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -curl -fSsL "https://index.docker.io/v1/repositories/$1/tags" | - jq -r '.[] | .name' diff --git a/scripts/.local/bin/install_git_hooks.sh b/scripts/.local/bin/install_git_hooks.sh deleted file mode 100755 index 16c8e635..00000000 --- a/scripts/.local/bin/install_git_hooks.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -HOOKS=${HOME}/.git_template/hooks -GWD=$(pwd)/.git/hooks - -mkdir -p ${GWD} -printf "Installing hooks to: %s\n" "$GWD" - -cp --dereference $HOOKS/* $GWD/. diff --git a/scripts/.local/bin/md5dir b/scripts/.local/bin/md5dir deleted file mode 100755 index 44353a88..00000000 --- a/scripts/.local/bin/md5dir +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -find "$1" -type f -exec md5sum {} > check.md5 \; diff --git a/scripts/.local/bin/mount_crypt b/scripts/.local/bin/mount_crypt deleted file mode 100755 index 0e013ccd..00000000 --- a/scripts/.local/bin/mount_crypt +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -mount_crypt () { - DEVICE=$1 - NAME=$2 - MOUNT=$3 - sudo cryptsetup luksOpen $DEVICE $NAME - if [ $? -ne 0 ]; then - exit 1 - fi - sudo mount /dev/mapper/"$NAME" "$MOUNT" - if [ $? -ne 0 ]; then - exit 1 - fi -} -umount_crypt () { - MOUNT=$1 - NAME=$2 - killall -u $USER -q gpg-agent dirmngr - sync - sudo umount "$MOUNT" - if [ $? -ne 0 ]; then - exit 1 - fi - sync - sudo cryptsetup luksClose "$NAME" - if [ $? -ne 0 ]; then - exit 1 - fi - sync -} - -case "$1" in - mount) - mount_crypt $2 $3 $4;; - umount) - umount_crypt $2 $3;; - *) - exit 1;; -esac diff --git a/scripts/.local/bin/reap_docker_volumes b/scripts/.local/bin/reap_docker_volumes deleted file mode 100755 index 46711c7e..00000000 --- a/scripts/.local/bin/reap_docker_volumes +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -docker volume ls \ - --quiet \ - --filter dangling=true \ - | xargs --no-run-if-empty docker volume rm diff --git a/scripts/.local/bin/shadir b/scripts/.local/bin/shadir deleted file mode 100755 index 35f909da..00000000 --- a/scripts/.local/bin/shadir +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -find "$1" -type f -exec shasum {} > check.sha1 \; diff --git a/scripts/.local/bin/shreddir b/scripts/.local/bin/shreddir deleted file mode 100755 index 8a3e8569..00000000 --- a/scripts/.local/bin/shreddir +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -if [ "$1" = "" ]; then - echo "I'm not comfortable doing this..." - exit 1 -fi - -find "$1" -type f -print -exec shred -zu {} \; -rm -rf $1 |