Skip to content

Commit

Permalink
stdenv: Don't use sed to build the setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Aug 9, 2014
1 parent be3fc3a commit e387529
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
9 changes: 3 additions & 6 deletions pkgs/stdenv/generic/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ done

mkdir $out

echo "$preHook" > $out/setup
echo "export SHELL=$shell" > $out/setup
echo "initialPath=\"$initialPath\"" >> $out/setup
echo "$preHook" >> $out/setup
cat "$setup" >> $out/setup

sed -e "s^@initialPath@^$initialPath^g" \
-e "s^@shell@^$shell^g" \
< $out/setup > $out/setup.tmp
mv $out/setup.tmp $out/setup

# Allow the user to install stdenv using nix-env and get the packages
# in stdenv.
mkdir $out/nix-support
Expand Down
5 changes: 0 additions & 5 deletions pkgs/stdenv/generic/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ let
builder = shell;

args = ["-e" ./builder.sh];
/* TODO: special-cased @var@ substitutions are ugly.
However, using substituteAll* from setup.sh seems difficult,
as setup.sh can't be directly sourced.
Suggestion: split similar utility functions into a separate script.
*/

setup = setupScript;

Expand Down
14 changes: 6 additions & 8 deletions pkgs/stdenv/generic/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ shopt -s nullglob

# Set up the initial path.
PATH=
for i in @initialPath@; do
for i in $initialPath; do
if [ "$i" = / ]; then i=; fi
addToSearchPath PATH $i/bin
addToSearchPath PATH $i/sbin
Expand All @@ -174,17 +174,15 @@ if [ "$NIX_DEBUG" = 1 ]; then
fi


# Execute the pre-hook.
export SHELL=@shell@
export CONFIG_SHELL="$SHELL"
if [ -z "$shell" ]; then export shell=@shell@; fi
runHook preHook


# Check that the pre-hook initialised SHELL.
if [ -z "$SHELL" ]; then echo "SHELL not set"; exit 1; fi


# Execute the pre-hook.
export CONFIG_SHELL="$SHELL"
if [ -z "$shell" ]; then export shell=$SHELL; fi


envHooks=()
crossEnvHooks=()

Expand Down

0 comments on commit e387529

Please sign in to comment.