From a019332cf27e578da491f08f910f2204703a0341 Mon Sep 17 00:00:00 2001 From: Alexander Bantyev Date: Fri, 28 Feb 2020 02:22:04 +0300 Subject: [PATCH] Update bootstrap so that it works again --- bootstrap | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/bootstrap b/bootstrap index cb7254d..27de151 100755 --- a/bootstrap +++ b/bootstrap @@ -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 .