Update bootstrap so that it works again

This commit is contained in:
Alexander Bantyev 2020-02-28 02:22:04 +03:00
parent 9cc36b4b38
commit a019332cf2
Signed by: balsoft
GPG Key ID: E081FF12ADCB4AD5

View File

@ -3,30 +3,44 @@
export IN_NIX_SHELL=
set -e
set -ex
mkdir -p /mnt/home/balsoft/projects
nixos-generate-config --root /mnt
echo 'import /home/balsoft/projects/nixos-config "$(hostname)"' > /mnt/etc/nixos/configuration.nix
echo import /home/balsoft/projects/nixos-config \"$(hostname)\" > /mnt/etc/nixos/configuration.nix
cd /mnt/home/balsoft/projects
git clone ssh://git@github.com/balsoft/nixos-config
[ -d nixos-config ] || git clone ssh://git@github.com/balsoft/nixos-config
cd nixos-config
touch secret.nix
while [[ -s secret.nix ]]
while [[ ! -s secret.nix ]]
do gpg -dq secret.nix.gpg > secret.nix
done
mv /mnt/etc/nixos/hardware-configuration.nix hardware-configuration/$(hostname).nix
[ -s hardware-configuration/$(hostname).nix ] || mv /mnt/etc/nixos/hardware-configuration.nix hardware-configuration/$(hostname).nix
mkdir /home/balsoft
mkdir -p /home/balsoft
mount --rbind /mnt/home/balsoft /home/balsoft
mount --rbind /mnt/etc/nixos /etc/nixos
umount -l /nix/.rw-store
cp /nix/ /mnt -r
export NIX_PATH=
nixpkgs=$(nix eval --raw '(import ./nix/sources.nix).nixpkgs')
nix-store --repair-path $nixpkgs # Evaluating doesn't actually add it to store
rm /tmp/nixpkgs -rf
cp -r $nixpkgs /tmp/nixpkgs # Because we lose everything we added to store after we unmount it
export NIX_PATH=nixpkgs=/tmp/nixpkgs:nixos-config=/etc/nixos/configuration.nix
nix copy --all --to /mnt --no-require-sigs
echo The following operation is irreversible. RET to continue.
read
umount -l /nix/.rw-store || echo "RW-store is not mounted."
mount --rbind /mnt/nix /nix
./build --substituters "https://cache.balsoft.ru https://cache.nixos.org" --no-require-sigs
nix-build /tmp/nixpkgs/nixos -A system --substituters "https://cache.balsoft.ru https://cache.nixos.org" --no-require-sigs
nixos-install --system ./result
cd /mnt/home/balsoft
chmod 777 -R .