Review shell scripts
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
install -d -m 700 "${GNUPGHOME}"
|
||||
install -d -m 700 "$GNUPGHOME"
|
||||
|
||||
for dir in "${HOME}"/.config/sops-nix/secrets/gpg/*; do
|
||||
keyfile="${dir}/key"
|
||||
passfile="${dir}/pass"
|
||||
for dir in "$HOME"/.config/sops-nix/secrets/gpg/*; do
|
||||
keyfile="$dir/key"
|
||||
passfile="$dir/pass"
|
||||
|
||||
if [[ ! -f "${keyfile}" ]]; then
|
||||
if [[ ! -f "$keyfile" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ -f "${passfile}" ]]; then
|
||||
gpg2 --batch --yes --pinentry-mode loopback --passphrase-file "${passfile}" --import "${keyfile}"
|
||||
if [[ -f "$passfile" ]]; then
|
||||
gpg2 --batch --yes --pinentry-mode loopback --passphrase-file "$passfile" --import "$keyfile"
|
||||
else
|
||||
gpg2 --batch --yes --import "${keyfile}"
|
||||
gpg2 --batch --yes --import "$keyfile"
|
||||
fi
|
||||
|
||||
gpg2 --with-colons --import-options show-only --import "${keyfile}" | grep '^fpr' | cut -d: -f10 | while read -r KEY_ID; do
|
||||
echo "${KEY_ID}:6:" >> "${GNUPGHOME}"/otrust.txt
|
||||
gpg2 --with-colons --import-options show-only --import "$keyfile" | grep '^fpr' | cut -d: -f10 | while read -r key_id; do
|
||||
echo "$key_id:6:" >> "$GNUPGHOME"/otrust.txt
|
||||
done
|
||||
done
|
||||
|
||||
gpg2 --import-ownertrust "${GNUPGHOME}"/otrust.txt
|
||||
rm "${GNUPGHOME}"/otrust.txt
|
||||
gpg2 --import-ownertrust "$GNUPGHOME"/otrust.txt
|
||||
rm "$GNUPGHOME"/otrust.txt
|
||||
|
@@ -20,16 +20,34 @@
|
||||
in
|
||||
''
|
||||
nix-develop() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: nix-develop <shell>"
|
||||
return 1
|
||||
local devshell=""
|
||||
|
||||
while getopts "s:" opt; do
|
||||
case $opt in
|
||||
s)
|
||||
devshell=$OPTARG
|
||||
;;
|
||||
*)
|
||||
echo "Usage: nix-develop [-s <devshell>]"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$devshell" ]]; then
|
||||
if [ ! -f flake.nix ]; then cp "${./template.nix}" flake.nix; fi
|
||||
nix develop -c "$SHELL"
|
||||
else
|
||||
nix develop self#"$devshell" -c "$SHELL"
|
||||
fi
|
||||
nix develop self#"$1" -c "$SHELL"
|
||||
}
|
||||
|
||||
_nix-develop_completion() {
|
||||
local shells=(${devShells})
|
||||
compadd -- $shells
|
||||
local options=(
|
||||
'-s[Dev shell from root flake]:shell:(${devShells})'
|
||||
)
|
||||
|
||||
_arguments -s $options
|
||||
}
|
||||
|
||||
compdef _nix-develop_completion nix-develop
|
||||
|
@@ -30,36 +30,38 @@
|
||||
in
|
||||
''
|
||||
nix-direnv() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "use flake" > .envrc
|
||||
local devshell=""
|
||||
local hide=false
|
||||
|
||||
if [ ! -f flake.nix ]; then
|
||||
echo "Do you want to create an empty flake.nix? (y/N)"
|
||||
read -r answer
|
||||
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
||||
cp "${./template.nix}" flake.nix
|
||||
fi
|
||||
fi
|
||||
while getopts "s:h" opt; do
|
||||
case $opt in
|
||||
s)
|
||||
devshell=$OPTARG
|
||||
;;
|
||||
h)
|
||||
hide=true
|
||||
;;
|
||||
*)
|
||||
echo "Usage: nix-direnv [-s <devshell>] [-h]"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$devshell" ]]; then
|
||||
echo "use flake" > .envrc
|
||||
if [ ! -f flake.nix ]; then cp "${../nix-develop/template.nix}" flake.nix; fi
|
||||
else
|
||||
echo "use flake self#$1" > .envrc
|
||||
echo "use flake self#$devshell" > .envrc
|
||||
fi
|
||||
|
||||
if git rev-parse --is-inside-work-tree &> /dev/null; then
|
||||
if ! grep -q "^\.envrc$" .gitignore .git/info/exclude; then
|
||||
echo "Do you want to hide the .envrc file from git? (y/N)"
|
||||
read -r answer
|
||||
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
||||
echo ".envrc" >> .git/info/exclude
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f flake.nix ] && ! grep -q "^flake.nix$" .gitignore .git/info/exclude; then
|
||||
echo "Do you want to hide the flake.nix and flake.lock files from git? (y/N)"
|
||||
read -r answer
|
||||
if [[ "$answer" =~ ^[Yy]$ ]]; then
|
||||
echo "flake.nix" >> .git/info/exclude
|
||||
echo "flake.lock" >> .git/info/exclude
|
||||
fi
|
||||
if hide && git rev-parse --is-inside-work-tree &>/dev/null; then
|
||||
local top
|
||||
top=$(git rev-parse --show-toplevel)
|
||||
if ! grep -q "^\.envrc$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "$(realpath --relative-to="$top" .envrc)" >> "$top/.git/info/exclude"; fi
|
||||
if [ -z "$devshell" ]; then
|
||||
if ! grep -q "^flake.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.nix" >> "$top/.git/info/exclude"; fi
|
||||
if ! grep -q "^flake.lock$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.lock" >> "$top/.git/info/exclude"; fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -67,8 +69,12 @@
|
||||
}
|
||||
|
||||
_nix-direnv_completion() {
|
||||
local shells=(${devShells})
|
||||
compadd -- $shells
|
||||
local options=(
|
||||
'-s[Dev shell from root flake]:shell:(${devShells})'
|
||||
'-h[Hide .envrc and flake.nix in git]'
|
||||
)
|
||||
|
||||
_arguments -s $options
|
||||
}
|
||||
|
||||
compdef _nix-direnv_completion nix-direnv
|
||||
|
@@ -19,7 +19,7 @@ in
|
||||
with cfg;
|
||||
{
|
||||
initExtra = ''
|
||||
export P10K_EXTRA_RIGHT_PROMPT_ELEMENTS=(${strings.concatStringsSep " " cfg.p10k.extraRightPromptElements})
|
||||
export P10K_EXTRA_RIGHT_PROMPT_ELEMENTS=(${strings.concatStringsSep " " p10k.extraRightPromptElements})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user