1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-13 20:30:02 +00:00

Merge pull request #263 from LnL7/harden-installer

Harden installer
This commit is contained in:
Daiderd Jordan 2020-12-19 10:10:17 +01:00 committed by GitHub
commit 72c6e6f0d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View file

@ -25,23 +25,25 @@ with lib;
esac
fi
if ! test -L /etc/bashrc && ! grep -q /etc/static/bashrc /etc/bashrc; then
if ! test -L /etc/bashrc && ! tail -n1 /etc/bashrc | grep -q /etc/static/bashrc; then
if test -t 1; then
read -p "Would you like to load darwin configuration in /etc/bashrc? [y/n] " i
fi
case "$i" in
y|Y)
sudo ${pkgs.gnused}/bin/sed -i '\,/etc/static/bashrc,d' /etc/bashrc
echo 'if test -e /etc/static/bashrc; then . /etc/static/bashrc; fi' | sudo tee -a /etc/bashrc
;;
esac
fi
if ! test -L /etc/zshrc && ! grep -q /etc/static/zshrc /etc/zshrc; then
if ! test -L /etc/zshrc && ! tail -n1 /etc/zshrc | grep -q /etc/static/zshrc; then
if test -t 1; then
read -p "Would you like to load darwin configuration in /etc/zshrc? [y/n] " i
fi
case "$i" in
y|Y)
sudo ${pkgs.gnused}/bin/sed -i '\,/etc/static/zshrc,d' /etc/zshrc
echo 'if test -e /etc/static/zshrc; then . /etc/static/zshrc; fi' | sudo tee -a /etc/zshrc
;;
esac

View file

@ -109,17 +109,36 @@ stdenv.mkDerivation {
echo >&2 "checking /etc"
readlink /etc/static
test -e /etc/static
echo >&2 "checking /etc/static in bashrc"
cat /etc/bashrc
grep /etc/static/bashrc /etc/bashrc
echo >&2 "checking /etc/static in zshrc"
cat /etc/zshrc
grep /etc/static/zshrc /etc/zshrc
echo >&2 "checking profile"
cat /etc/profile
grep -v nix-daemon.sh /etc/profile
echo >&2 "checking /run/current-system"
readlink /run
test -e /run
readlink /run/current-system
test -e /run/current-system
echo >&2 "checking profile"
echo >&2 "checking system profile"
readlink /nix/var/nix/profiles/system
test -e /nix/var/nix/profiles/system
echo >&2 "checking bash environment"
env -i USER=john HOME=/Users/john bash -li -c 'echo $PATH'
env -i USER=john HOME=/Users/john bash -li -c 'echo $PATH' | grep /Users/john/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
env -i USER=john HOME=/Users/john bash -li -c 'echo $NIX_PATH'
env -i USER=john HOME=/Users/john bash -li -c 'echo $NIX_PATH' | grep darwin-config=/Users/john/.nixpkgs/darwin-configuration.nix:/nix/var/nix/profiles/per-user/root/channels:/Users/john/.nix-defexpr/channels
echo >&2 "checking zsh environment"
env -i USER=john HOME=/Users/john zsh -l -c 'echo $PATH'
env -i USER=john HOME=/Users/john zsh -l -c 'echo $PATH' | grep /Users/john/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
env -i USER=john HOME=/Users/john zsh -l -c 'echo $NIX_PATH' | grep darwin-config=/Users/john/.nixpkgs/darwin-configuration.nix:/nix/var/nix/profiles/per-user/root/channels:/Users/john/.nix-defexpr/channels
env -i USER=john HOME=/Users/john zsh -l -c 'echo $NIX_PATH'
echo >&2 ok
exit
'';