Skip to content

Instantly share code, notes, and snippets.

@dramforever
Last active March 29, 2021 15:02
Show Gist options
  • Save dramforever/b249b7b7f09376cb88e70b7c6e7c88d2 to your computer and use it in GitHub Desktop.
Save dramforever/b249b7b7f09376cb88e70b7c6e7c88d2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
nix build --no-link "$@" nixpkgs#stdenv
stdenv="$(nix eval --raw nixpkgs\#stdenv)"
store="$(nix eval --raw --expr builtins.storeDir)"
bashPath="$(dirname "$(realpath "$(type -p bash)")")"
exec bash --rcfile /proc/self/fd/19 19<<END
declare -x NIX_BUILD_TOP="$(pwd)"
declare -x NIX_STORE="$store"
declare -x out="/var/empty"
declare -x buildInputs="$(for i in "$@"; do nix eval --raw "$i"; echo -n ' '; done)"
export savedPath="\$PATH"
source "$stdenv"/setup
unset NIX_ENFORCE_PURITY
export PATH="$bashPath:\$PATH:\$savedPath"
[ -f ~/.bashrc ] && source ~/.bashrc
set +e
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment