1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 15:13:55 +02:00

install: make synthetic.conf and fstab checks stricter

(cherry picked from commit bc24c09968)
Signed-off-by: Domen Kožar <domen@dev.si>
This commit is contained in:
Daiderd Jordan 2020-03-18 20:34:46 +01:00 committed by Domen Kožar
parent 4cafd9c825
commit f9c6c0a764
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246

View file

@ -39,11 +39,15 @@ find_nix_volume() {
} }
test_fstab() { test_fstab() {
grep -q "/nix" /etc/fstab 2>/dev/null grep -q "/nix apfs rw" /etc/fstab 2>/dev/null
}
test_nix_symlink() {
[ -L "/nix" ] || grep -q "^nix." /etc/synthetic.conf 2>/dev/null
} }
test_synthetic_conf() { test_synthetic_conf() {
grep -q "^nix" /etc/synthetic.conf 2>/dev/null grep -q "^nix$" /etc/synthetic.conf 2>/dev/null
} }
test_nix() { test_nix() {
@ -60,12 +64,12 @@ main() {
echo "" echo ""
echo " 1. Remove the entry from fstab using 'sudo vifs'" echo " 1. Remove the entry from fstab using 'sudo vifs'"
echo " 2. Destroy the data volume using 'diskutil apfs deleteVolume'" echo " 2. Destroy the data volume using 'diskutil apfs deleteVolume'"
echo " 3. Delete /etc/synthetic.conf" echo " 3. Remove the 'nix' line from /etc/synthetic.conf or the file"
echo "" echo ""
) >&2 ) >&2
if [ -L "/nix" ]; then if test_nix_symlink; then
echo "error: /nix is a symlink, please remove it or edit synthetic.conf (requires reboot)" >&2 echo "error: /nix is a symlink, please remove it and make sure it's not in synthetic.conf (in which case a reboot is required)" >&2
echo " /nix -> $(readlink "/nix")" >&2 echo " /nix -> $(readlink "/nix")" >&2
exit 2 exit 2
fi fi