Add launch-nix
This commit is contained in:
commit
6c71975bb6
1 changed files with 24 additions and 0 deletions
24
launch-nix
Normal file
24
launch-nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ADDITIONAL_BINDS= #"--bind $HOME /home/maix"
|
||||
RUN_BWRAP="/usr/bin/bwrap --bind $(mktemp -d) / --dev-bind /dev /dev --bind /home/maiboyer/nix-location /nix --bind /usr/lib32 /lib32 --bind /usr/libx32 /libx32 --bind /osquery.flags /osquery.flags --bind /usr/lib64 /lib64 --bind /media /media --bind /root /root --bind /cdrom /cdrom --bind /sgoinfre /sgoinfre --bind /.cache /.cache --bind /var /var --bind /sys /sys --bind /usr/sbin /sbin --bind /boot /boot --bind /snap /snap --bind /usr/bin /bin --bind /.dumped /.dumped --bind /tmp /tmp --bind /opt /opt --bind /lost+found /lost+found --bind /usr /usr --bind /home /home --bind /usr/lib /lib --bind /run /run --bind /proc /proc --bind /mnt /mnt --bind /swap.img /swap.img --bind /etc /etc --bind /goinfre /goinfre --bind /srv /srv --bind /etc/host.conf /etc/host.conf --bind /etc/hosts /etc/hosts --bind /etc/networks /etc/networks --bind /etc/passwd /etc/passwd --bind /etc/group /etc/group --bind /etc/nsswitch.conf /etc/nsswitch.conf --bind /run/systemd/resolve/stub-resolv.conf /run/systemd/resolve/stub-resolv.conf --bind /usr/share/zoneinfo/Europe/Paris /usr/share/zoneinfo/Europe/Paris --bind $HOME $HOME $ADDITIONAL_BINDS --bind /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt"
|
||||
|
||||
if [ -e '/nix' ]; then
|
||||
echo "already in nix" >&2
|
||||
exit 0
|
||||
fi
|
||||
if ! [ -e "$HOME/nix-location/store" ]; then
|
||||
echo -n "installing nix..." >&2
|
||||
$RUN_BWRAP mkdir -p "/nix/var/nix/profiles/per-user/maiboyer/";
|
||||
$RUN_BWRAP -- /usr/bin/env /bin/sh -c 'curl -L https://nixos.org/nix/install | sh -s -- --no-daemon --no-modify-profile --yes'
|
||||
echo "done" >&2
|
||||
fi
|
||||
|
||||
if ! [ "$#" -eq 0 ]; then
|
||||
CMD="$@"
|
||||
else
|
||||
CMD="$SHELL"
|
||||
fi
|
||||
|
||||
|
||||
exec $RUN_BWRAP -- /usr/bin/env $CMD
|
||||
Loading…
Add table
Add a link
Reference in a new issue