Skip to content

Commit

Permalink
refactor: make gpg-restore work on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
flexiondotorg committed May 18, 2024
1 parent ccc6ac0 commit a8cbd55
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions home-manager/_mixins/configs/gpg-restore.fish
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
function gpg-restore
mkdir -p --mode 700 $HOME/.gnupg
gpgconf --kill gpg-agent
gpg --import --batch /run/user/(id -u)/secrets/gpg_private
gpg --import /run/user/(id -u)/secrets/gpg_public
gpg --list-secret-keys
gpg --list-keys
gpg --import-ownertrust /run/user/(id -u)/secrets/gpg_ownertrust

if test (uname) = "Darwin"
set base_temp_dir (getconf DARWIN_USER_TEMP_DIR)/secrets.d/

if test -d $base_temp_dir
set temp_dir (find $base_temp_dir -type d -maxdepth 1 -exec basename {} \; | sort -n | tail -n 1)
set temp_dir $base_temp_dir$temp_dir
else
echo "Directory $base_temp_dir does not exist."
return 1
end
else
set temp_dir /run/user/(id -u)/secrets
end

if test -d $temp_dir
gpg --import --batch $temp_dir/gpg_private
gpg --import $temp_dir/gpg_public
gpg --list-secret-keys
gpg --list-keys
gpg --import-ownertrust $temp_dir/gpg_ownertrust
else
echo "Secrets directory $temp_dir does not exist."
return 1
end
end

0 comments on commit a8cbd55

Please sign in to comment.