Skip to content

Instantly share code, notes, and snippets.

@abbradar
Created November 11, 2017 10:16
Show Gist options
  • Save abbradar/4233f2a8cf1a4747fe51160494d44cd7 to your computer and use it in GitHub Desktop.
Save abbradar/4233f2a8cf1a4747fe51160494d44cd7 to your computer and use it in GitHub Desktop.
Test for makeWrapper
{ stdenv, makeWrapper }:
stdenv.mkDerivation {
name = "make-wrapper-test";
buildInputs = [ makeWrapper ];
buildCommand = ''
mkdir -p $out/bin
cat > $out/bin/test <<EOF
#!${stdenv.shell}
echo "FOO=\$FOO"
echo "BAR=\$BAR"
echo "BAZ=\$BAZ"
echo "QUZ=\$QUZ"
EOF
chmod +x $out/bin/test
cat > test-contents <<EOF
test1
$test2 test3
test4
EOF
wrapProgram $out/bin/test \
--set FOO 'ahaha $ \' \
--set BAR 'ahaha $ \' \
--set BAZ 'ahaha $ \' \
--set QUZ 'ahaha $ \' \
--prefix FOO ' ' 'bar '"'"'$baz' \
--suffix BAR ' ' 'bar '"'"'$baz' \
--prefix-contents BAZ '$' test-contents \
--suffix-contents QUZ '$' test-contents
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment