Skip to content

Instantly share code, notes, and snippets.

@71
Created November 28, 2018 17:00
Show Gist options
  • Save 71/0f14fcf523145cf457fd57251555eb9a to your computer and use it in GitHub Desktop.
Save 71/0f14fcf523145cf457fd57251555eb9a to your computer and use it in GitHub Desktop.
Run a command in a Nix-aware PRoot environment.
#!/bin/bash
# Run the given command in a Nix-aware environment installed in
# '~/opt/nix', assuming PRoot is available in '~/opt/bin/proot-x86_64'.
#
# If no arguments are given, 'zsh' is executed.
#
# Note:
# The full path to 'nix.sh' is given instead of '~/.nix-profile/etc/profile.d/nix.sh',
# because in some cases, the symlink may not be property set up when running the script.
set -- ${1:-zsh} ${@:2:$#}
$HOME/opt/bin/proot-x86_64 -b $HOME/opt/nix:/nix sh <(echo "source /nix/var/nix/profiles/per-user/$USER/profile/etc/profile.d/nix.sh && $@")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment