Skip to content

Commit

Permalink
gitAndTools.transcrypt: query dependencies in helper scripts
Browse files Browse the repository at this point in the history
adds a tool to get the paths of the dependencies needed by the helper scripts
(which are written only once and are never updated) to the output and patches
them to use it expand their path
  • Loading branch information
hyperfekt authored and Lassulus committed May 18, 2019
1 parent 13b97cf commit de5a9de
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Expand Up @@ -13,6 +13,8 @@ stdenv.mkDerivation rec {

buildInputs = [ makeWrapper git openssl coreutils utillinux gnugrep gnused gawk ];

patches = [ ./helper-scripts_depspathprefix.patch ];

installPhase = ''
install -m 755 -D transcrypt $out/bin/transcrypt
install -m 644 -D man/transcrypt.1 $out/share/man/man1/transcrypt.1
Expand All @@ -21,6 +23,12 @@ stdenv.mkDerivation rec {
wrapProgram $out/bin/transcrypt \
--prefix PATH : "${stdenv.lib.makeBinPath [ git openssl coreutils utillinux gnugrep gnused gawk ]}"
cat > $out/bin/transcrypt-depspathprefix << EOF
#!${stdenv.shell}
echo "${stdenv.lib.makeBinPath [ git openssl coreutils gawk ]}:"
EOF
chmod +x $out/bin/transcrypt-depspathprefix
'';

meta = with stdenv.lib; {
Expand Down
@@ -0,0 +1,37 @@
diff --git a/transcrypt b/transcrypt
index a0b562d..7888f5d 100755
--- a/transcrypt
+++ b/transcrypt
@@ -278,6 +278,7 @@ save_helper_scripts() {

cat <<-'EOF' > "${GIT_DIR}/crypt/clean"
#!/usr/bin/env bash
+ PATH="$(transcrypt-depspathprefix 2>/dev/null)$PATH"
filename=$1
# ignore empty files
if [[ -s $filename ]]; then
@@ -300,6 +301,7 @@ save_helper_scripts() {

cat <<-'EOF' > "${GIT_DIR}/crypt/smudge"
#!/usr/bin/env bash
+ PATH="$(transcrypt-depspathprefix 2>/dev/null)$PATH"
tempfile=$(mktemp 2> /dev/null || mktemp -t tmp)
trap 'rm -f "$tempfile"' EXIT
cipher=$(git config --get --local transcrypt.cipher)
@@ -309,6 +311,7 @@ save_helper_scripts() {

cat <<-'EOF' > "${GIT_DIR}/crypt/textconv"
#!/usr/bin/env bash
+ PATH="$(transcrypt-depspathprefix 2>/dev/null)$PATH"
filename=$1
# ignore empty files
if [[ -s $filename ]]; then
@@ -351,7 +354,7 @@ save_configuration() {
git config merge.renormalize 'true'

# add a git alias for listing encrypted files
- git config alias.ls-crypt "!git ls-files | git check-attr --stdin filter | awk 'BEGIN { FS = \":\" }; /crypt$/{ print \$1 }'"
+ git config alias.ls-crypt "!PATH=\"\$(transcrypt-depspathprefix 2>/dev/null)\$PATH\"; git ls-files | git check-attr --stdin filter | awk 'BEGIN { FS = \":\" }; /crypt$/{ print \$1 }'"
}

# display the current configuration settings

0 comments on commit de5a9de

Please sign in to comment.