forked from DeterminateSystems/macos-ephemeral
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apply.sh
54 lines (39 loc) · 1.46 KB
/
apply.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
set -eu
CONFIG_FLAKE_REF=$1
#set -x
while ! ping -c1 nixos.org; do
sleep 1
done
export HOME=/root
# mostly from darwin-installer: https://github.com/LnL7/nix-darwin/blob/d3d7db7b86c8a2f3fa9925fe5d38d29025e7cb7f/pkgs/darwin-installer/installer.nix#L40-L48
if ! grep -q '^run\b' /etc/synthetic.conf 2>/dev/null; then
printf "run\tprivate/var/run\n" | sudo tee -a /etc/synthetic.conf >/dev/null
/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B &>/dev/null || true
/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -t &>/dev/null || true
fi
if [ ! -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]; then
#curl -L -o install.xz https://hydra.nixos.org/job/nix/master/binaryTarball.aarch64-darwin/latest/download/1
#tar -xf install.xz
#cd nix-*
curl -Lo install https://nixos.org/nix/install
time sh ./install --daemon 2>&1 | tail -n5
fi
if ! hash nix; then
set +eux
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
set -eux
fi
if [ ! -d /nix/home ]; then
mkdir -p /nix/home
fi
export HOME=/nix/home
nix --extra-experimental-features 'nix-command flakes' build "$CONFIG_FLAKE_REF"
sudo rm /etc/nix/nix.conf || true
# This is essentially what `darwin-rebuild switch` does.
profile=/nix/var/nix/profiles/system
systemConfig="$(readlink -f ./result)"
nix-env -p "$profile" --set "$systemConfig"
"$systemConfig/activate-user"
"$systemConfig/activate"
echo "Done!"