Skip to content

Instantly share code, notes, and snippets.

@guymers
Last active July 21, 2024 21:42
Show Gist options
  • Select an option

  • Save guymers/445a9bc7ba546ff714261e1515c5308d to your computer and use it in GitHub Desktop.

Select an option

Save guymers/445a9bc7ba546ff714261e1515c5308d to your computer and use it in GitHub Desktop.
bwrap
#!/bin/sh
# export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/config"
# $ cat ~/.config/npm/config
# prefix=${XDG_DATA_HOME}/npm
# cache=${XDG_CACHE_HOME}/npm
# init-module=${XDG_CONFIG_HOME}/npm/init.js
# audit=false
# fund=false
# update-notifier=false
exec bwrap \
--unshare-all --share-net \
--unshare-user \
--disable-userns \
--die-with-parent \
--new-session \
--clearenv \
--setenv PATH /usr/bin \
--setenv HOME "$HOME" \
--setenv XDG_CONFIG_HOME "$XDG_CONFIG_HOME" \
--setenv XDG_CACHE_HOME "$XDG_CACHE_HOME" \
--setenv XDG_DATA_HOME "$XDG_DATA_HOME" \
--setenv NPM_CONFIG_USERCONFIG "$NPM_CONFIG_USERCONFIG" \
--dev /dev \
--proc /proc \
--tmpfs /tmp \
--tmpfs /var \
--ro-bind /etc/ca-certificates /etc/ca-certificates \
--ro-bind /etc/resolv.conf /etc/resolv.conf \
--ro-bind /etc/ssl /etc/ssl \
--ro-bind /usr /usr \
--symlink /usr/bin /bin \
--symlink /usr/lib /lib \
--symlink /usr/lib64 /lib64 \
--bind "$PWD" "$PWD" \
--bind "$XDG_CONFIG_HOME/npm" "$XDG_CONFIG_HOME/npm" \
--bind-try "$XDG_CACHE_HOME/npm" "$XDG_CACHE_HOME/npm" \
--bind-try "$XDG_DATA_HOME/npm" "$XDG_DATA_HOME/npm" \
"/usr/bin/npm" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment