on master help sign in
nix-bundle/nix-bootstrap.sh
35 lines 765 B history raw
1#!/bin/sh
3if [ $# -gt 0 ]; then
4 set -- sh
5fi
7# should download this in the future
8# but the mirror is down
9proot=$(dirname "$0")/proot-$(uname -p)
10export PROOT_NO_SECCOMP=1
12nixdir=$HOME/.nix
14OLD_NIX_PATH=$NIX_PATH
15# shellcheck disable=SC1090
16if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then . "$HOME/.nix-profile/etc/profile.d/nix.sh"; fi
17if [ -n "$OLD_NIX_PATH" ]; then NIX_PATH="$OLD_NIX_PATH"; fi
19if [ -z "$IN_PROOT" ]; then
20 export IN_PROOT=1
22 if ! [ -d "$nixdir" ]; then
23 mkdir -p "$nixdir"
24 s=$(mktemp)
25 curl https://nixos.org/nix/install -o "$s"
26 $proot -b "$nixdir:/nix" "$0" sh "$s"
27 fi
29 $proot -b "$nixdir:/nix" "$0" "$@"
31 export IN_PROOT=
32 exit
33elif [ $# -gt 0 ]; then
34 exec "$@"
35fi